summaryrefslogtreecommitdiff
path: root/src/device
diff options
context:
space:
mode:
authorhathach <[email protected]>2018-10-25 15:02:43 +0700
committerhathach <[email protected]>2018-10-25 15:02:43 +0700
commitb2f18744feefa77b30c7547d7aff11c53024570f (patch)
tree466f06ced61ec9846011dd109c79e594c4d86249 /src/device
parent8144be262bf418c96d16e26418e058a622c37007 (diff)
add dcd event helper setup_recieved and bus_signal
Diffstat (limited to 'src/device')
-rw-r--r--src/device/dcd.h33
1 files changed, 24 insertions, 9 deletions
diff --git a/src/device/dcd.h b/src/device/dcd.h
index 662496701..87837df20 100644
--- a/src/device/dcd.h
+++ b/src/device/dcd.h
@@ -68,7 +68,7 @@ typedef enum
DCD_EVENT_XFER_COMPLETE,
USBD_EVT_FUNC_CALL
-}usbd_eventid_t;
+} dcd_eventid_t;
typedef struct ATTR_ALIGNED(4)
{
@@ -112,21 +112,35 @@ void dcd_disconnect (uint8_t rhport) ATTR_WEAK;
*------------------------------------------------------------------*/
void dcd_event_handler(dcd_event_t const * event, bool in_isr);
-static inline void dcd_event_xfer_complete(uint8_t rhport, uint8_t ep_addr, uint32_t xferred_bytes, uint8_t result, bool in_isr)
+// helper to send bus signal event
+static inline void dcd_event_bus_signal (uint8_t rhport, dcd_eventid_t eid, bool in_isr)
{
- dcd_event_t event =
- {
- .rhport = 0,
- .event_id = DCD_EVENT_XFER_COMPLETE,
- };
+ dcd_event_t event = { .rhport = 0, .event_id = eid, };
+ dcd_event_handler(&event, in_isr);
+}
+
+// helper to send setup received
+static inline void dcd_event_setup_recieved(uint8_t rhport, uint8_t const * setup, bool in_isr)
+{
+ dcd_event_t event = { .rhport = 0, .event_id = DCD_EVENT_SETUP_RECEIVED };
+ memcpy(&event.setup_received, setup, 8);
+
+ dcd_event_handler(&event, true);
+}
+
+// helper to send transfer complete event
+static inline void dcd_event_xfer_complete (uint8_t rhport, uint8_t ep_addr, uint32_t xferred_bytes, uint8_t result, bool in_isr)
+{
+ dcd_event_t event = { .rhport = 0, .event_id = DCD_EVENT_XFER_COMPLETE };
event.xfer_complete.ep_addr = ep_addr;
event.xfer_complete.len = xferred_bytes;
event.xfer_complete.result = result;
- dcd_event_handler(&event, true);
+ dcd_event_handler(&event, in_isr);
}
+
/*------------------------------------------------------------------*/
/* Endpoint API
*------------------------------------------------------------------*/
@@ -143,7 +157,8 @@ bool dcd_edpt_stalled (uint8_t rhport, uint8_t ep_addr);
//------------- Control Endpoint -------------//
bool dcd_control_xfer (uint8_t rhport, uint8_t dir, uint8_t * buffer, uint16_t length);
-// Note input dir is value of direction bit in setup packet (i.e DATA stage direction)
+// Helper to send STATUS (zero length) packet
+// Note dir is value of direction bit in setup packet (i.e DATA stage direction)
static inline bool dcd_control_status(uint8_t rhport, uint8_t dir)
{
// status direction is reversed to one in the setup packet