Serasidis / STM32_HID_Bootloader

Driverless USB HID bootloader and flashing tool for STM32F10X devices

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

USB_LP_CAN1_RX0_IRQHandler possible issues

Squonk42 opened this issue · comments

void USB_LP_CAN1_RX0_IRQHandler() {

I have 2 concerns here:

  1. the line just above is:
    _SetCNTR(CNTR_RESETM | CNTR_SUSPM | CNTR_WKUPM);, so I don't see the point to test for DOVR, ERR, SOF and ESOF. For ERR, the Reference Manual clearly says that "The USB software can usually ignore errors". We don't care about SOF and ESOF, and data overrun is unlikely with HID

  2. More importantly, the Reference Manual states that:

The upper part of this register contains single bits, each of them representing a specific
event. These bits are set by the hardware when the related event occurs; if the
corresponding bit in the USB_CNTR register is set, a generic interrupt request is generated.
The interrupt routine, examining each bit, will perform all necessary actions, and finally it will
clear the serviced bits. If any of them is not cleared, the interrupt is considered to be still
pending, and the interrupt line will be kept high again. If several bits are set simultaneously,
only a single interrupt will be generated.

So, my understanding is that we should not return after testing each condition, but run though all of them in sequence, or we get a chance to miss one or even lock the transfer.