summaryrefslogtreecommitdiff
path: root/src/device
diff options
context:
space:
mode:
authorhathach <[email protected]>2018-07-25 21:21:33 +0700
committerhathach <[email protected]>2018-07-25 21:21:33 +0700
commit544f9c1315e318884f62565dc1698a3f8c4412be (patch)
tree2bb98ae25d765ec8150c6cd6431b6a9650e508f1 /src/device
parent936579462384a977ff637c111fce78535149df2d (diff)
add dcd_edpt_stalled() API
- implement control endpoint get status, endpoint set feature
Diffstat (limited to 'src/device')
-rw-r--r--src/device/dcd.h1
-rw-r--r--src/device/usbd.c21
2 files changed, 19 insertions, 3 deletions
diff --git a/src/device/dcd.h b/src/device/dcd.h
index bee787d03..cbce366cc 100644
--- a/src/device/dcd.h
+++ b/src/device/dcd.h
@@ -93,6 +93,7 @@ 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);
//------------- Control Endpoint -------------//
bool dcd_control_xfer (uint8_t rhport, tusb_dir_t dir, uint8_t * buffer, uint16_t length);
diff --git a/src/device/usbd.c b/src/device/usbd.c
index bd169bb6f..443ca8056 100644
--- a/src/device/usbd.c
+++ b/src/device/usbd.c
@@ -411,11 +411,26 @@ static tusb_error_t proc_control_request_st(uint8_t rhport, tusb_control_request
else if ( TUSB_REQ_RCPT_ENDPOINT == p_request->bmRequestType_bit.recipient &&
TUSB_REQ_TYPE_STANDARD == p_request->bmRequestType_bit.type)
{
- if (TUSB_REQ_CLEAR_FEATURE == p_request->bRequest )
+ if (TUSB_REQ_GET_STATUS == p_request->bRequest )
{
- dcd_edpt_clear_stall(rhport, u16_low_u8(p_request->wIndex) );
+ uint16_t status = dcd_edpt_stalled(rhport, u16_low_u8(p_request->wIndex)) ? 0x0001 : 0x0000;
+ memcpy(_usbd_ctrl_buf, &status, 2);
+
+ usbd_control_xfer_st(rhport, p_request->bmRequestType_bit.direction, _usbd_ctrl_buf, 2);
+ }
+ else if (TUSB_REQ_CLEAR_FEATURE == p_request->bRequest )
+ {
+ // only endpoint feature is halted/stalled
+ dcd_edpt_clear_stall(rhport, u16_low_u8(p_request->wIndex));
+ dcd_control_status(rhport, p_request->bmRequestType_bit.direction);
+ }
+ else if (TUSB_REQ_SET_FEATURE == p_request->bRequest )
+ {
+ // only endpoint feature is halted/stalled
+ dcd_edpt_stall(rhport, u16_low_u8(p_request->wIndex));
dcd_control_status(rhport, p_request->bmRequestType_bit.direction);
- } else
+ }
+ else
{
dcd_control_stall(rhport); // Stall unsupported request
}