USBX CDC-ACM + Sleep Mode: How to wake STM32U5 on USB activity?
Hi everyone,
I'm working with an STM32U5 and using USBX with the CDC-ACM class.
My setup is as follows:
I have a USBX CDC ACM receive thread that calls usbx_cdc_acm_read_thread_entry() in ux_device_cdc_acm.c file.
Alongside, I have a state machine running in another context (main loop).
If the device stays idle (no USB activity) for a certain timeout, the state machine puts the MCU into Sleep Mode using:
HAL_SuspendTick();
HAL_PWR_EnterSLEEPMode(PWR_LOWPOWERREGULATOR_ON, PWR_SLEEPENTRY_WFI);
HAL_ResumeTick();
The goal is to wake up the MCU only when data is received on the USB.
To achieve this, I tried relying on USB interrupts:
OTG_FS_IRQn is enabled in NVIC.
The USB OTG FS peripheral is initialized properly via HAL_PCD_Init().
OTG_FS_IRQHandler() is defined and calls HAL_PCD_IRQHandler()
But I'm not getting out from the Sleep mode, I'm completely stuck and running out of ideas.
Any assistance would be greatly appreciated.
Thank you!
