2009-09-21 02:00 AM
Issues with JoystickMouse demo
2011-05-17 04:16 AM
I have two issues with the JoystickMouse demo, w.r.t ''Host Suspend''.
1) The new version 3.0.1 of this project does not seem to be able to resume at all from host suspend using the Key button. I've tried it on the same STM3210E_EVAL board as always, but it never resumes. Can anyone else confirm? 2) When I try version 2.2.1 of this project, it does resume correctly. However, it seems that it can only resume from ''Host Suspend'' a single time. If I put the host to Stand By (for Windows) a second time, the key button does not wake it up. I've traced it down to the part in the code where it checks the current feature to see if remote wake-up is enabled, and for this second time it fails (where it succeeded the first time). Can anyone else confirm? Any ideas on these two errors? - Matt2011-05-17 04:16 AM
I am implementing this feature in my own device and can confirm that the unit fails to startup from the 2nd standby.
Looking at the pInformation->Current_Feature BEFORE the 1st sleep mode, it is 0xE0. After the Resume functions have run, pInformation->Current_Feature is now 0xC0. Somewhere (either a bug in the code or the STM32 device) the remote wakeup feature is being turned off in this register. This is why the 2nd startup from resume fails. I haven't found out where in the code this feature is turned off, but will report back if I find anything. SteveO.2011-05-17 04:16 AM
Adding support for this feature seems to have been more complicated than it needed to be, but my setup is now working.
(FWIW, I think that this would make a good example to be added to the USB library code.) The issues I came up against are mainly surrounding NoData_Setup0 in usb_core.c (FW lib 3.0.0) the function Standard_SetFeature ... a) Will set bit 5 of the pInformation->Current_Feature to 1. b) Will only run if pInformation->Current_Feature is 1. c) Calls User_SetDeviceFeature() the function Standard_ClearFeature ... a) Will set bit 5 of the pInformation->Current_Feature to 0. b) Will only run if pInformation->Current_Feature is 1. c) Does NOT call User_ClearFeature() when Type_Rec = STANDARD|DEVICE If you shutdown your PC, Windows will call SetFeature(DEVICE_REMOTE_WAKEUP) just before it goes to sleep and then it calls ClearFeature(DEVICE_REMOTE_WAKEUP) just after it has woken up (I am no WinExpert, so my info comes from here ) Thefore, after the first shutdown/wakeup the STM32 USB code can no longer be used to get your device to wakeup from sleep (Current_Feature[5]is 0 because of the call to Standard_ClearFeature(). Therefore, I had to add code at the application level to make sure that pInformation->Current_Feature[5] is set back to 1. This makes it complicated to track when the user has unticked the box ''Allow this device to bring the computer out of standby'' To get around this, I used the variable fSuspendEnabled that is provided in the example code. This var is set ... a) to FALSE by default (example code has this set to TRUE by default). You will also need to remove the call to Resume(RESUME_WAIT) in the example code. b) to TRUE in User_SetDeviceFeature() (i.e. this will be run when windows calls Standard_SetDeviceFeature() as PC is going to sleep) c) is set back to FALSE in the application code after the PC has woken up. Hope this helps someone, SteveO.