summaryrefslogtreecommitdiff
path: root/src/device/usbd.c
diff options
context:
space:
mode:
authorhathach <[email protected]>2019-03-27 16:09:49 +0700
committerhathach <[email protected]>2019-03-27 16:09:49 +0700
commit1e9848d917550b0af2115bc629d5e7e4743f23c7 (patch)
tree4642aacd58b24f96a5c8ac86364297f1f388112e /src/device/usbd.c
parent472237665479961a714b6775e7fc9289e5e6c9ee (diff)
replace dcd_edpt_(clear)stall by usbd_edpt_(clear)stall
- remove dcd_edpt_stalled() from dcd porting
Diffstat (limited to 'src/device/usbd.c')
-rw-r--r--src/device/usbd.c41
1 files changed, 37 insertions, 4 deletions
diff --git a/src/device/usbd.c b/src/device/usbd.c
index 877837fae..b79ccae2b 100644
--- a/src/device/usbd.c
+++ b/src/device/usbd.c
@@ -44,9 +44,11 @@
typedef struct {
uint8_t config_num;
- uint8_t itf2drv[16]; // map interface number to driver (0xff is invalid)
- uint8_t ep2drv[8][2]; // map endpoint to driver ( 0xff is invalid )
+ uint8_t itf2drv[16]; // map interface number to driver (0xff is invalid)
+ uint8_t ep2drv[8][2]; // map endpoint to driver ( 0xff is invalid )
+ uint8_t ep_busy_mask[2]; // bit mask for busy endpoint
+ uint8_t ep_stall_mask[2]; // bit mask for stalled endpoint
}usbd_device_t;
static usbd_device_t _usbd_dev = { 0 };
@@ -379,7 +381,7 @@ static bool process_control_request(uint8_t rhport, tusb_control_request_t const
{
case TUSB_REQ_GET_STATUS:
{
- uint16_t status = dcd_edpt_stalled(rhport, tu_u16_low(p_request->wIndex)) ? 0x0001 : 0x0000;
+ uint16_t status = usbd_edpt_stalled(rhport, tu_u16_low(p_request->wIndex)) ? 0x0001 : 0x0000;
usbd_control_xfer(rhport, p_request, &status, 2);
}
break;
@@ -392,7 +394,7 @@ static bool process_control_request(uint8_t rhport, tusb_control_request_t const
case TUSB_REQ_SET_FEATURE:
// only endpoint feature is halted/stalled
- dcd_edpt_stall(rhport, tu_u16_low(p_request->wIndex));
+ usbd_edpt_stall(rhport, tu_u16_low(p_request->wIndex));
usbd_control_status(rhport, p_request);
break;
@@ -650,4 +652,35 @@ void usbd_defer_func(osal_task_func_t func, void* param, bool in_isr)
dcd_event_handler(&event, in_isr);
}
+//--------------------------------------------------------------------+
+// USBD Endpoint API
+//--------------------------------------------------------------------+
+void usbd_edpt_stall(uint8_t rhport, uint8_t ep_addr)
+{
+ uint8_t const epnum = tu_edpt_number(ep_addr);
+ uint8_t const dir = tu_edpt_dir(ep_addr);
+
+ dcd_edpt_stall(rhport, ep_addr);
+ _usbd_dev.ep_stall_mask[dir] = tu_bit_set(_usbd_dev.ep_stall_mask[dir], epnum);
+}
+
+void usbd_edpt_clear_stall(uint8_t rhport, uint8_t ep_addr)
+{
+ uint8_t const epnum = tu_edpt_number(ep_addr);
+ uint8_t const dir = tu_edpt_dir(ep_addr);
+
+ dcd_edpt_clear_stall(rhport, ep_addr);
+ _usbd_dev.ep_stall_mask[dir] = tu_bit_clear(_usbd_dev.ep_stall_mask[dir], epnum);
+}
+
+bool usbd_edpt_stalled(uint8_t rhport, uint8_t ep_addr)
+{
+ (void) rhport;
+
+ uint8_t const epnum = tu_edpt_number(ep_addr);
+ uint8_t const dir = tu_edpt_dir(ep_addr);
+
+ return tu_bit_test(_usbd_dev.ep_stall_mask[dir], epnum);
+}
+
#endif