summaryrefslogtreecommitdiff
path: root/src/device/dcd.h
diff options
context:
space:
mode:
authorhathach <[email protected]>2018-10-23 15:08:31 +0700
committerhathach <[email protected]>2018-10-23 15:08:31 +0700
commite97b14848baef164a92000da83fb43d1bdd704cb (patch)
tree20a6e2f942b677da12eaddcfb16a94a89c1849e7 /src/device/dcd.h
parent959480d82c9964d8534d25e2832c6c89f3994c2a (diff)
rename usbd_event_t to dcd_event_t
Diffstat (limited to 'src/device/dcd.h')
-rw-r--r--src/device/dcd.h42
1 files changed, 42 insertions, 0 deletions
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
*------------------------------------------------------------------*/