diff options
Diffstat (limited to 'chip/stm32/usb_hw.h')
-rw-r--r-- | chip/stm32/usb_hw.h | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/chip/stm32/usb_hw.h b/chip/stm32/usb_hw.h index ef231c4567..89c8e9d6f0 100644 --- a/chip/stm32/usb_hw.h +++ b/chip/stm32/usb_hw.h @@ -6,6 +6,12 @@ #ifndef __CROS_EC_USB_HW_H #define __CROS_EC_USB_HW_H +/* Event types for the endpoint event handler. */ +enum usb_ep_event { + USB_EVENT_RESET, + USB_EVENT_DEVICE_RESUME, /* Device-initiated wake completed. */ +}; + #if defined(CHIP_FAMILY_STM32F4) #include "usb_dwc_hw.h" #else @@ -64,20 +70,31 @@ void *memcpy_from_usbram(void *dest, const void *src, size_t n); #define _EP_HANDLER2(num, suffix) CONCAT3(ep_, num, suffix) #define _EP_TX_HANDLER(num) _EP_HANDLER2(num, _tx) #define _EP_RX_HANDLER(num) _EP_HANDLER2(num, _rx) -#define _EP_RESET_HANDLER(num) _EP_HANDLER2(num, _rst) +#define _EP_EVENT_HANDLER(num) _EP_HANDLER2(num, _evt) +/* Used to check function types are correct (attribute alias does not do it) */ +#define _EP_TX_HANDLER_TYPECHECK(num) _EP_HANDLER2(num, _tx_typecheck) +#define _EP_RX_HANDLER_TYPECHECK(num) _EP_HANDLER2(num, _rx_typecheck) +#define _EP_EVENT_HANDLER_TYPECHECK(num) _EP_HANDLER2(num, _evt_typecheck) -#define USB_DECLARE_EP(num, tx_handler, rx_handler, rst_handler) \ +#define USB_DECLARE_EP(num, tx_handler, rx_handler, evt_handler) \ void _EP_TX_HANDLER(num)(void) \ __attribute__ ((alias(STRINGIFY(tx_handler)))); \ void _EP_RX_HANDLER(num)(void) \ __attribute__ ((alias(STRINGIFY(rx_handler)))); \ - void _EP_RESET_HANDLER(num)(void) \ - __attribute__ ((alias(STRINGIFY(rst_handler)))); + void _EP_EVENT_HANDLER(num)(enum usb_ep_event evt) \ + __attribute__ ((alias(STRINGIFY(evt_handler)))); \ + static __unused void \ + (*_EP_TX_HANDLER_TYPECHECK(num))(void) = tx_handler; \ + static __unused void \ + (*_EP_RX_HANDLER_TYPECHECK(num))(void) = rx_handler; \ + static __unused void \ + (*_EP_EVENT_HANDLER_TYPECHECK(num))(enum usb_ep_event evt)\ + = evt_handler /* arrays with all endpoint callbacks */ extern void (*usb_ep_tx[]) (void); extern void (*usb_ep_rx[]) (void); -extern void (*usb_ep_reset[]) (void); +extern void (*usb_ep_event[]) (enum usb_ep_event evt); /* array with interface-specific control request callbacks */ extern int (*usb_iface_request[]) (usb_uint *ep0_buf_rx, usb_uint *ep0_buf_tx); |