merge tusb_dcd_control_stall() to tusb_dcd_edpt_stall()

This commit is contained in:
hathach
2018-03-21 16:08:42 +07:00
parent 9a487a238a
commit 3ed83c4d98
4 changed files with 45 additions and 24 deletions

View File

@@ -85,7 +85,7 @@ typedef struct
}_dcd;
/*------------------------------------------------------------------*/
/* Controller API
/* Controller Start up Sequence
*------------------------------------------------------------------*/
static bool hfclk_running(void)
{
@@ -351,12 +351,6 @@ bool tusb_dcd_control_xfer (uint8_t port, tusb_dir_t dir, uint8_t * buffer, uint
return true;
}
void tusb_dcd_control_stall (uint8_t port)
{
(void) port;
NRF_USBD->TASKS_EP0STALL = 1;
__ISB(); __DSB();
}
/*------------------------------------------------------------------*/
/*
@@ -449,12 +443,26 @@ bool tusb_dcd_edpt_queue_xfer (uint8_t port, uint8_t ep_addr, uint8_t * buffer,
void tusb_dcd_edpt_stall (uint8_t port, uint8_t ep_addr)
{
(void) port;
if ( ep_addr == 0)
{
NRF_USBD->TASKS_EP0STALL = 1;
}else
{
NRF_USBD->EPSTALL = (USBD_EPSTALL_STALL_Stall << USBD_EPSTALL_STALL_Pos) | ep_addr;
}
__ISB(); __DSB();
}
void tusb_dcd_edpt_clear_stall (uint8_t port, uint8_t ep_addr)
{
(void) port;
if ( ep_addr )
{
NRF_USBD->EPSTALL = (USBD_EPSTALL_STALL_UnStall << USBD_EPSTALL_STALL_Pos) | ep_addr;
}
}
bool tusb_dcd_edpt_busy (uint8_t port, uint8_t ep_addr)

View File

@@ -230,10 +230,6 @@ static inline uint8_t qtd_find_free(uint8_t port)
//--------------------------------------------------------------------+
// CONTROL PIPE API
//--------------------------------------------------------------------+
void tusb_dcd_control_stall(uint8_t port)
{
LPC_USB[port]->ENDPTCTRL0 |= (ENDPTCTRL_MASK_STALL << 16); // stall Control IN TODO stall control OUT as well
}
// control transfer does not need to use qtd find function
// follows UM 24.10.8.1.1 Setup packet handling using setup lockout mechanism
@@ -277,7 +273,14 @@ void tusb_dcd_edpt_stall(uint8_t port, uint8_t ep_addr)
uint8_t ep_idx = edpt_addr2phy(ep_addr);
volatile uint32_t * reg_control = get_reg_control_addr(port, ep_idx);
(*reg_control) |= ENDPTCTRL_MASK_STALL << (ep_idx & 0x01 ? 16 : 0);
if ( ep_addr == 0)
{
// Stall both Control IN and OUT
(*reg_control) |= ( (ENDPTCTRL_MASK_STALL << 16) || (ENDPTCTRL_MASK_STALL << 0) );
}else
{
(*reg_control) |= ENDPTCTRL_MASK_STALL << (ep_idx & 0x01 ? 16 : 0);
}
}
void tusb_dcd_edpt_clear_stall(uint8_t port, uint8_t ep_addr)
@@ -475,7 +478,9 @@ void hal_dcd_isr(uint8_t port)
if ( p_qtd->int_on_complete )
{
bool succeeded = ( p_qtd->xact_err || p_qtd->halted || p_qtd->buffer_err ) ? false : true;
tusb_dcd_xfer_complete(port, 0, 0, succeeded); // TODO xferred bytes for control xfer is not needed yet !!!!
(void) succeeded;
tusb_dcd_control_complete(port);
}
}
}