mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-17 05:32:55 +08:00
add dcd_edpt_stalled() API
- implement control endpoint get status, endpoint set feature
This commit is contained in:
parent
9365794623
commit
544f9c1315
@ -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);
|
||||
|
@ -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 )
|
||||
{
|
||||
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
|
||||
}
|
||||
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
|
||||
{
|
||||
dcd_control_stall(rhport); // Stall unsupported request
|
||||
}
|
||||
|
@ -333,6 +333,17 @@ bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dcd_edpt_stalled (uint8_t rhport, uint8_t ep_addr)
|
||||
{
|
||||
(void) rhport;
|
||||
|
||||
// control is never got halted
|
||||
if ( ep_addr == 0 ) return false;
|
||||
|
||||
uint8_t const epnum = edpt_number(ep_addr);
|
||||
return (edpt_dir(ep_addr) == TUSB_DIR_IN ) ? NRF_USBD->HALTED.EPIN[epnum] : NRF_USBD->HALTED.EPOUT[epnum];
|
||||
}
|
||||
|
||||
void dcd_edpt_stall (uint8_t rhport, uint8_t ep_addr)
|
||||
{
|
||||
(void) rhport;
|
||||
@ -351,9 +362,11 @@ void dcd_edpt_stall (uint8_t rhport, uint8_t ep_addr)
|
||||
void dcd_edpt_clear_stall (uint8_t rhport, uint8_t ep_addr)
|
||||
{
|
||||
(void) rhport;
|
||||
|
||||
if ( ep_addr )
|
||||
{
|
||||
NRF_USBD->EPSTALL = (USBD_EPSTALL_STALL_UnStall << USBD_EPSTALL_STALL_Pos) | ep_addr;
|
||||
__ISB(); __DSB();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user