diff --git a/os/hal/ports/STM32/LLD/OTGv1/hal_usb_lld.c b/os/hal/ports/STM32/LLD/OTGv1/hal_usb_lld.c index 069de3753..5069a915a 100644 --- a/os/hal/ports/STM32/LLD/OTGv1/hal_usb_lld.c +++ b/os/hal/ports/STM32/LLD/OTGv1/hal_usb_lld.c @@ -600,36 +600,6 @@ static void usb_lld_serve_interrupt(USBDriver *usbp) { /* IN/OUT endpoints event handling.*/ src = otgp->DAINT; - if (sts & GINTSTS_IEPINT) { - if (src & (1 << 0)) - otg_epin_handler(usbp, 0); - if (src & (1 << 1)) - otg_epin_handler(usbp, 1); - if (src & (1 << 2)) - otg_epin_handler(usbp, 2); - if (src & (1 << 3)) - otg_epin_handler(usbp, 3); -#if USB_MAX_ENDPOINTS >= 4 - if (src & (1 << 4)) - otg_epin_handler(usbp, 4); -#endif -#if USB_MAX_ENDPOINTS >= 5 - if (src & (1 << 5)) - otg_epin_handler(usbp, 5); -#endif -#if USB_MAX_ENDPOINTS >= 6 - if (src & (1 << 6)) - otg_epin_handler(usbp, 6); -#endif -#if USB_MAX_ENDPOINTS >= 7 - if (src & (1 << 7)) - otg_epin_handler(usbp, 7); -#endif -#if USB_MAX_ENDPOINTS >= 8 - if (src & (1 << 8)) - otg_epin_handler(usbp, 8); -#endif - } if (sts & GINTSTS_OEPINT) { if (src & (1 << 16)) otg_epout_handler(usbp, 0); @@ -658,6 +628,36 @@ static void usb_lld_serve_interrupt(USBDriver *usbp) { #if USB_MAX_ENDPOINTS >= 8 if (src & (1 << 24)) otg_epout_handler(usbp, 8); +#endif + } + if (sts & GINTSTS_IEPINT) { + if (src & (1 << 0)) + otg_epin_handler(usbp, 0); + if (src & (1 << 1)) + otg_epin_handler(usbp, 1); + if (src & (1 << 2)) + otg_epin_handler(usbp, 2); + if (src & (1 << 3)) + otg_epin_handler(usbp, 3); +#if USB_MAX_ENDPOINTS >= 4 + if (src & (1 << 4)) + otg_epin_handler(usbp, 4); +#endif +#if USB_MAX_ENDPOINTS >= 5 + if (src & (1 << 5)) + otg_epin_handler(usbp, 5); +#endif +#if USB_MAX_ENDPOINTS >= 6 + if (src & (1 << 6)) + otg_epin_handler(usbp, 6); +#endif +#if USB_MAX_ENDPOINTS >= 7 + if (src & (1 << 7)) + otg_epin_handler(usbp, 7); +#endif +#if USB_MAX_ENDPOINTS >= 8 + if (src & (1 << 8)) + otg_epin_handler(usbp, 8); #endif } }