2021-08-25 05:44 AM
I'm trying to build a Custom HID project to mimic a certain device.
I've prepared the description bytes packages and everything is working fine as long as I continuously send data. When I stop sending, device goes to LP and SUSPEND mode. I couldn't find the way to resume again. Please guide me through
Using HAL Libraries FW_F1 V1.8.4
Best regards
Zeki
2021-08-27 06:13 AM
Hello @e-zeki ,
Take a look at the usbd_conf.c file of the following example provided under F7 CubeFW (Path : Projects\STM32746G-Discovery\Applications\USB_Device\HID_Standalone\Src )
Make sure that you have properly configured the HAL_PCD_ResumeCallback() and HAL_PCD_SuspendCallback() functions.
I hope this help you.
BeST Regards,
Walid
2021-08-30 05:46 AM
Hello @Walid ZRELLI ,
Thanks for the help. I tried to implement L:659 void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) by software (i dont have a button to trigger it so I decided to try in debug mode)
In debug mode if I go LP mode everything goes wrong since I have no relaible data from debug due to clock issues. so I turned off LP mode and I removed Remote Wakeup bit from my descriptor.
My normal should be USB->CNTR = 0xBF00, which is if i constantly send data. its stays same.
My USB->CNTR register now = 0xBF0C which means I got suspended.
I still get suspended by my computer even I try to initiate this sequence
HAL_PCD_ActivateRemoteWakeup((&hpcd_USB_FS));
/* Remote wakeup delay */
HAL_Delay(10);
/* Disable Remote wakeup */
HAL_PCD_DeActivateRemoteWakeup((&hpcd_USB_FS));
/* change state to configured */
hUsbDeviceFS.dev_state = USBD_STATE_CONFIGURED;
/* Change remote_wakeup feature to 0*/
hUsbDeviceFS.dev_remote_wakeup=0;
My My USB->CNTR register briefly goes back to 0xBF00 and immidiatelly goes to 0xBF0C and I dont see anything on my sniffer program other than the fact I got suspended.
I still cant find a solution to this problem.
I dont need to power down to low power mode or clock down. I just need to be not suspended. I dont understand why I'm getting suspended at first place either.
is this confiurations different in standard usb mouse and keyboards? why don't they get suspended when they stay idle?
what am I missing here?
Best regards
Zeki
2021-08-31 02:10 AM
Hello @e-zeki ,
Have you tried to test your application without the LP mode?
Do you get the same result?
BeST Regards,
Walid
2021-08-31 05:30 AM
Hello @Walid ZRELLI ,
Yes I have. with or without LP mode, computer suspends me after approximatelly 10 seconds I stop sending something. if I keep the data flow, no problem. as soon as I stop, host waits around 10 seconds and suspends me. and no matter I do I cant send anything back. or reset the CNTR reg accordingly.
Best regards,
Zeki
2023-12-05 02:15 PM
If someone has the same error, I remove the code that is by default in the HAL_PCD_SuspendCallback method and it was enough to fix the problem. Thx Walid for the help