add dcd_edpt_stalled() API

- implement control endpoint get status, endpoint set feature
This commit is contained in:
hathach
2018-07-25 21:21:33 +07:00
parent 9365794623
commit 544f9c1315
3 changed files with 32 additions and 3 deletions
+13
View File
@@ -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();
}
}