Browse Source

add default usb irq name for USBD_IRQHandler

sakumisu 4 years ago
parent
commit
574b79b9ea
2 changed files with 9 additions and 4 deletions
  1. 2 0
      port/fsdev/usb_dc_fsdev.c
  2. 7 4
      port/mm32/usb_dc.c

+ 2 - 0
port/fsdev/usb_dc_fsdev.c

@@ -1,7 +1,9 @@
 #include "usbd_core.h"
 #include "usb_fsdev_regs.h"
 
+#ifndef USBD_IRQHandler
 #define USBD_IRQHandler USB_LP_CAN1_RX0_IRQHandler //use actual usb irq name instead
+#endif
 
 #ifndef USB_NUM_BIDIR_ENDPOINTS
 #define USB_NUM_BIDIR_ENDPOINTS 8

+ 7 - 4
port/mm32/usb_dc.c

@@ -10,6 +10,10 @@
 #define USB_GET_EP_FIFO(ep_idx)            (*(volatile uint32_t *)(&USB->rEP0_FIFO + ep_idx))
 #define USB_SET_EP_FIFO(ep_idx, val)       (*(volatile uint32_t *)(&USB->rEP0_FIFO + ep_idx) = val)
 
+#ifndef USBD_IRQHandler
+#define USBD_IRQHandler USB_HP_CAN1_TX_IRQHandler //use actual usb irq name instead
+#endif
+
 #ifndef USB_NUM_BIDIR_ENDPOINTS
 #define USB_NUM_BIDIR_ENDPOINTS 5
 #endif
@@ -121,13 +125,12 @@ int usbd_ep_close(const uint8_t ep)
 
 int usbd_ep_set_stall(const uint8_t ep)
 {
-    while (USB->rEP0_CTRL & 0x80)
-        ;
-    USB->rEP_HALT = (1 << (ep & 0x7f));
+    USB->rEP_HALT |= (1 << (ep & 0x7f));
     return 0;
 }
 int usbd_ep_clear_stall(const uint8_t ep)
 {
+    USB->rEP_HALT &= ~(1 << (ep & 0x7f));
     return 0;
 }
 int usbd_ep_is_stalled(const uint8_t ep, uint8_t *stalled)
@@ -208,7 +211,7 @@ int usbd_ep_read(const uint8_t ep, uint8_t *data, uint32_t max_data_len, uint32_
   * @param  hpcd PCD handle
   * @retval HAL status
   */
-void USB_HP_CAN1_TX_IRQHandler(void)
+void USBD_IRQHandler(void)
 {
     uint32_t int_status;
     uint32_t epindex;