diff options
| author | hathach <[email protected]> | 2019-03-27 16:09:49 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2019-03-27 16:09:49 +0700 |
| commit | 1e9848d917550b0af2115bc629d5e7e4743f23c7 (patch) | |
| tree | 4642aacd58b24f96a5c8ac86364297f1f388112e /src/device | |
| parent | 472237665479961a714b6775e7fc9289e5e6c9ee (diff) | |
replace dcd_edpt_(clear)stall by usbd_edpt_(clear)stall
- remove dcd_edpt_stalled() from dcd porting
Diffstat (limited to 'src/device')
| -rw-r--r-- | src/device/dcd.h | 2 | ||||
| -rw-r--r-- | src/device/usbd.c | 41 | ||||
| -rw-r--r-- | src/device/usbd.h | 1 | ||||
| -rw-r--r-- | src/device/usbd_pvt.h | 5 |
4 files changed, 42 insertions, 7 deletions
diff --git a/src/device/dcd.h b/src/device/dcd.h index 588839ccb..186c4af0c 100644 --- a/src/device/dcd.h +++ b/src/device/dcd.h @@ -102,7 +102,6 @@ void dcd_set_config (uint8_t rhport, uint8_t config_num); * - busy : Check if endpoint transferring is complete (TODO remove)
* - stall : stall endpoint
* - clear_stall : clear stall
- * - stalled : check if stalled ( TODO remove )
*------------------------------------------------------------------*/
bool dcd_edpt_open (uint8_t rhport, tusb_desc_endpoint_t const * p_endpoint_desc);
bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes);
@@ -110,7 +109,6 @@ bool dcd_edpt_busy (uint8_t rhport, uint8_t ep_addr); void dcd_edpt_stall (uint8_t rhport, uint8_t ep_addr);
void dcd_edpt_clear_stall (uint8_t rhport, uint8_t ep_addr);
-bool dcd_edpt_stalled (uint8_t rhport, uint8_t ep_addr);
/*------------------------------------------------------------------*/
/* Event Function
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
diff --git a/src/device/usbd.h b/src/device/usbd.h index 11ef63887..e8f3f2bc8 100644 --- a/src/device/usbd.h +++ b/src/device/usbd.h @@ -38,7 +38,6 @@ // INCLUDE
//--------------------------------------------------------------------+
#include <common/tusb_common.h>
-#include "osal/osal.h"
#include "device/dcd.h"
//--------------------------------------------------------------------+
diff --git a/src/device/usbd_pvt.h b/src/device/usbd_pvt.h index d2562d298..dee194f0f 100644 --- a/src/device/usbd_pvt.h +++ b/src/device/usbd_pvt.h @@ -52,6 +52,11 @@ bool usbd_control_status(uint8_t rhport, tusb_control_request_t const * request) // Stall control endpoint (both IN and OUT) until new setup packet arrived void usbd_control_stall(uint8_t rhport); + +void usbd_edpt_stall(uint8_t rhport, uint8_t ep_addr); +void usbd_edpt_clear_stall(uint8_t rhport, uint8_t ep_addr); +bool usbd_edpt_stalled(uint8_t rhport, uint8_t ep_addr); + /*------------------------------------------------------------------*/ /* Helper *------------------------------------------------------------------*/ |
