From e97b14848baef164a92000da83fb43d1bdd704cb Mon Sep 17 00:00:00 2001 From: hathach Date: Tue, 23 Oct 2018 15:08:31 +0700 Subject: rename usbd_event_t to dcd_event_t --- src/device/dcd.h | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'src/device/dcd.h') diff --git a/src/device/dcd.h b/src/device/dcd.h index e246f0521..91c034489 100644 --- a/src/device/dcd.h +++ b/src/device/dcd.h @@ -58,6 +58,46 @@ typedef enum USBD_BUS_EVENT_RESUME }usbd_bus_event_type_t; +typedef enum +{ + USBD_EVT_BUS_RESET = 1, + USBD_EVT_UNPLUGGED, + USBD_EVT_SOF, + USBD_EVT_SUSPENDED, + USBD_EVT_RESUME, + + USBD_EVT_SETUP_RECEIVED, + USBD_EVT_XFER_COMPLETE, + + USBD_EVT_FUNC_CALL +}usbd_eventid_t; + +typedef struct ATTR_ALIGNED(4) +{ + uint8_t rhport; + uint8_t event_id; + + union { + // USBD_EVT_SETUP_RECEIVED + tusb_control_request_t setup_received; + + // USBD_EVT_XFER_COMPLETE + struct { + uint8_t ep_addr; + uint8_t result; + uint32_t len; + }xfer_complete; + + // USBD_EVT_FUNC_CALL + struct { + void (*func) (void*); + void* param; + }func_call; + }; +} dcd_event_t; + +TU_VERIFY_STATIC(sizeof(dcd_event_t) <= 12, "size is not correct"); + /*------------------------------------------------------------------*/ /* Device API (Weak is optional) *------------------------------------------------------------------*/ @@ -82,6 +122,8 @@ static inline void dcd_control_complete(uint8_t rhport, uint32_t xferred_bytes) dcd_xfer_complete(rhport, 0, xferred_bytes, true); } +void dcd_event_handler(dcd_event_t const * event, bool in_isr); + /*------------------------------------------------------------------*/ /* Endpoint API *------------------------------------------------------------------*/ -- cgit v1.3.1