add dcd event helper setup_recieved and bus_signal
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user