2012-09-16 11:51 AM
Hi All;
For people who interested by connecting a mouse or a keyboard to the STM32F4 Discovery:Attached a project that I have ported from the example provided in ''USB On-The-Go host and device library'' that works on STM3240G-EVAL board.IAR 6.40 is used to compile the project. I didn't port it to other toolchains: keil, Tasking ...When a mouse is connected:The Blue Led should turn on.. Otherwise, desconnect the mouse or push the RESET button.Clicking on the Left button of the mouse the green LED togglesClicking on the right button of the mouse the Red LED togglesClicking on the middle button of the mouse the orange LED togglesmoving the mose toggle the blue LEDDisconnecting the mouse from the Discovery board turns off all LEDsWhen a Keyboard is connected:The Blue Led should turn on.. Otherwise, desconnect the mouse or push the RESET button.Hitting any key on the keyboard toggles the orange LED.Disconnecting the mouse from the Discovery board turns off all LEDsThe port is done by:Modifying the clock configuration: HSE clock from 25Mhz to 8MhzRemoving all related LCD functions.Configuring LEDs for the Discovery board. Deleting the polling on the user button in order to launch the HID application without waiting on user key press.Have fun ;)STM322013-01-12 07:48 AM
Thank you very much for this !
I've built the example with IAR 6.40 KickStart : my keyboard will work very well but neither of my two mouses...The one rated at 50mA light on for 1 s then lights off.The other one rated at 100mA won't light on.What could be the problem ?Cheers,Xavier2013-01-14 08:49 AM
Please could anybody try this piece of code with a mouse and tell me wether it works or not ? (You need an adapter micro male USB <--> USB A female to plug the mouse)
I've tried many different configs but I've got nothing...THX2013-01-14 11:51 PM
It's a shame I don't know how to compile it with truestudio. Can you post a .hex or .elf so I can upload it directly? (if I can figure that out) I at least want to know if I've wired my usb A to micro B correctly (soldered together my own; yes I'm a hack)
2013-01-15 03:59 PM
Thank you Ivan to accept to try it !
I've attached the (non functionning) hex file... In the meantime I have applied fixes coming from here: It greatly improve the situation as my Logitech mice sometimes work now but not always.... The mouse is not recognized at each startup, it's very unpredictable ! The corresponding hex file is also attached. ________________ Attachments : USBH_HID_bad.hex : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006Hzyc&d=%2Fa%2F0X0000000bS4%2FIlErl5s6OBfZnR6b9oFsvQuwavCu9F0MV.IIpUn3ihM&asPdf=falseUSBH_HID_better.hex : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I00N&d=%2Fa%2F0X0000000bS3%2FgBTapHdo2BYV0JhWkPhDSKEHs._bOWoHKeoiAIZnMDA&asPdf=false2013-01-15 06:28 PM
No problem, thanks for hex files. Both bad.hex and better.hex work with my 100mA mouse, but neither work with my keyboard. better.hex causes the green led to be lit up along with the blue one when the device is recognized. Now I just need to port this into TrueSTUDIO.
2013-01-16 04:35 AM
This forum is a PITA, it routed 4 posts of mine to /dev/null ...
But back to the topic. Have you tried an ext. powered hub ? I doubt your board can supply so many USB devices.2013-01-16 09:31 AM
fm : It's just about plugging *one* mouse on the OTG connector !
Well the original file seems to work only with USB 2.0 mice or keyboards. My low-end USB 1.10 mouse will never be recognized...2013-01-16 01:26 PM
Ivan : thank you for testing !
I'm going to try to compile this project with GNU ARM gcc and makefiles...2013-01-28 10:12 AM
Work done !
If you use the GNU tool chain, see : https://github.com/MrBlueXav/USB_host_HID_demo Enjoy !