Ver código fonte

update: add USBH_IRQHandler & USBD_IRQHandler function declaration

Signed-off-by: sakumisu <1203593632@qq.com>
sakumisu 1 ano atrás
pai
commit
64394bf246
4 arquivos alterados com 12 adições e 22 exclusões
  1. 4 1
      common/usb_dc.h
  2. 3 0
      common/usb_hc.h
  3. 4 12
      port/template/usb_dc.c
  4. 1 9
      port/template/usb_hc.c

+ 4 - 1
common/usb_dc.h

@@ -136,7 +136,7 @@ int usbd_ep_start_write(uint8_t busid, const uint8_t ep, const uint8_t *data, ui
  */
 int usbd_ep_start_read(uint8_t busid, const uint8_t ep, uint8_t *data, uint32_t data_len);
 
-/* usb dcd irq callback */
+/* usb dcd irq callback, called by user */
 
 /**
  * @brief Usb connect irq callback.
@@ -194,6 +194,9 @@ void usbd_event_ep_out_complete_handler(uint8_t busid, uint8_t ep, uint32_t nbyt
 void usbd_execute_test_mode(uint8_t busid, uint8_t test_mode);
 #endif
 
+/* called by user */
+void USBD_IRQHandler(uint8_t busid);
+
 #ifdef __cplusplus
 }
 #endif

+ 3 - 0
common/usb_hc.h

@@ -108,6 +108,9 @@ int usbh_submit_urb(struct usbh_urb *urb);
  */
 int usbh_kill_urb(struct usbh_urb *urb);
 
+/* called by user */
+void USBH_IRQHandler(uint8_t busid);
+
 #ifdef __cplusplus
 }
 #endif

+ 4 - 12
port/template/usb_dc.c

@@ -1,13 +1,5 @@
 #include "usbd_core.h"
 
-#ifndef USBD_IRQHandler
-#define USBD_IRQHandler USBD_IRQHandler
-#endif
-
-#ifndef USB_NUM_BIDIR_ENDPOINTS
-#define USB_NUM_BIDIR_ENDPOINTS 5
-#endif
-
 /* Endpoint state */
 struct usb_dc_ep_state {
     uint16_t ep_mps;    /* Endpoint max packet size */
@@ -21,8 +13,8 @@ struct usb_dc_ep_state {
 /* Driver state */
 struct xxx_udc {
     volatile uint8_t dev_addr;
-    struct usb_dc_ep_state in_ep[USB_NUM_BIDIR_ENDPOINTS];  /*!< IN endpoint parameters*/
-    struct usb_dc_ep_state out_ep[USB_NUM_BIDIR_ENDPOINTS]; /*!< OUT endpoint parameters */
+    struct usb_dc_ep_state in_ep[CONFIG_USBDEV_EP_NUM];  /*!< IN endpoint parameters*/
+    struct usb_dc_ep_state out_ep[CONFIG_USBDEV_EP_NUM]; /*!< OUT endpoint parameters */
 } g_xxx_udc;
 
 __WEAK void usb_dc_low_level_init(void)
@@ -121,6 +113,6 @@ int usbd_ep_start_read(uint8_t busid, const uint8_t ep, uint8_t *data, uint32_t
     return 0;
 }
 
-void USBD_IRQHandler(void)
+void USBD_IRQHandler(uint8_t busid)
 {
-}
+}

+ 1 - 9
port/template/usb_hc.c

@@ -7,14 +7,6 @@
 #include "usbh_hub.h"
 #include "usb_xxx_reg.h"
 
-#ifndef USBH_IRQHandler
-#define USBH_IRQHandler OTG_HS_IRQHandler
-#endif
-
-#ifndef USB_BASE
-#define USB_BASE (0x40040000UL)
-#endif
-
 struct dwc2_pipe {
     bool inuse;
     uint32_t xfrd;
@@ -300,6 +292,6 @@ static inline void dwc2_urb_waitup(struct usbh_urb *urb)
     }
 }
 
-void USBH_IRQHandler(void)
+void USBH_IRQHandler(uint8_t busid)
 {
 }