Determine USB-cable connected/disconnected status and transmit-in-progress status without being dependent on interrupts?
I'm working with the Nucleo-64 development board with an STM32L476 microcontroller and I'm using the USB source code that STM32CubeMX has generated for me. In my project the peripheral interrupts have the same priority as OTG_FS_IRQHandler and hence, they can't interrupt each other. I wish to transmit a USB-packet from within a peripheral interrupt, but before doing so I need to make sure a cable is (still) connected and no transmit is currently ongoing (remember, CDC_Transmit_FS is asynchronous). I understand that HAL_PCD_ResumeCallback and HAL_PCD_SuspendCallback will be called when the cable is connected/disconnected and that USBD_CDC_HandleTypeDef -> TxState tells me when transmit is ongoing. However, these will not be updated properly in time in case OTG_FS_IRQHandler has the same priority as the interrupt I wish to send the USB-packet from. Is there a solution to this that does not require me to raise the priority level of OTG_FS_IRQHandler?
