mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-17 05:32:55 +08:00
remove dcd_edpt_busy()
This commit is contained in:
parent
7156bfb54d
commit
73d7ab201e
@ -110,9 +110,6 @@ bool dcd_edpt_open (uint8_t rhport, tusb_desc_endpoint_t const * p_endpoi
|
|||||||
// Submit a transfer, When complete dcd_event_xfer_complete() is invoked to notify the stack
|
// Submit a transfer, When complete dcd_event_xfer_complete() is invoked to notify the stack
|
||||||
bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes);
|
bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes);
|
||||||
|
|
||||||
// Check if endpoint transferring is complete (TODO remove)
|
|
||||||
bool dcd_edpt_busy (uint8_t rhport, uint8_t ep_addr);
|
|
||||||
|
|
||||||
// Stall endpoint
|
// Stall endpoint
|
||||||
void dcd_edpt_stall (uint8_t rhport, uint8_t ep_addr);
|
void dcd_edpt_stall (uint8_t rhport, uint8_t ep_addr);
|
||||||
|
|
||||||
|
@ -229,22 +229,6 @@ void dcd_edpt_clear_stall (uint8_t rhport, uint8_t ep_addr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool dcd_edpt_busy (uint8_t rhport, uint8_t ep_addr)
|
|
||||||
{
|
|
||||||
(void) rhport;
|
|
||||||
|
|
||||||
// USBD shouldn't check control endpoint state
|
|
||||||
if ( 0 == ep_addr ) return false;
|
|
||||||
|
|
||||||
uint8_t const epnum = tu_edpt_number(ep_addr);
|
|
||||||
UsbDeviceEndpoint* ep = &USB->DEVICE.DeviceEndpoint[epnum];
|
|
||||||
|
|
||||||
if (tu_edpt_dir(ep_addr) == TUSB_DIR_IN) {
|
|
||||||
return ep->EPINTFLAG.bit.TRCPT1 == 0 && ep->EPSTATUS.bit.BK1RDY == 1;
|
|
||||||
}
|
|
||||||
return ep->EPINTFLAG.bit.TRCPT0 == 0 && ep->EPSTATUS.bit.BK0RDY == 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------*/
|
/*------------------------------------------------------------------*/
|
||||||
|
|
||||||
static bool maybe_handle_setup_packet(void) {
|
static bool maybe_handle_setup_packet(void) {
|
||||||
|
@ -233,22 +233,6 @@ void dcd_edpt_clear_stall (uint8_t rhport, uint8_t ep_addr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool dcd_edpt_busy (uint8_t rhport, uint8_t ep_addr)
|
|
||||||
{
|
|
||||||
(void) rhport;
|
|
||||||
|
|
||||||
// USBD shouldn't check control endpoint state
|
|
||||||
if ( 0 == ep_addr ) return false;
|
|
||||||
|
|
||||||
uint8_t const epnum = tu_edpt_number(ep_addr);
|
|
||||||
UsbDeviceEndpoint* ep = &USB->DEVICE.DeviceEndpoint[epnum];
|
|
||||||
|
|
||||||
if (tu_edpt_dir(ep_addr) == TUSB_DIR_IN) {
|
|
||||||
return ep->EPINTFLAG.bit.TRCPT1 == 0 && ep->EPSTATUS.bit.BK1RDY == 1;
|
|
||||||
}
|
|
||||||
return ep->EPINTFLAG.bit.TRCPT0 == 0 && ep->EPSTATUS.bit.BK0RDY == 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------*/
|
/*------------------------------------------------------------------*/
|
||||||
|
|
||||||
static bool maybe_handle_setup_packet(void) {
|
static bool maybe_handle_setup_packet(void) {
|
||||||
|
@ -332,21 +332,6 @@ void dcd_edpt_clear_stall (uint8_t rhport, uint8_t ep_addr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool dcd_edpt_busy (uint8_t rhport, uint8_t ep_addr)
|
|
||||||
{
|
|
||||||
(void) rhport;
|
|
||||||
|
|
||||||
// USBD shouldn't check control endpoint state
|
|
||||||
if ( 0 == tu_edpt_number(ep_addr) ) return false;
|
|
||||||
|
|
||||||
uint8_t const epnum = tu_edpt_number(ep_addr);
|
|
||||||
uint8_t const dir = tu_edpt_dir(ep_addr);
|
|
||||||
|
|
||||||
xfer_td_t* xfer = get_td(epnum, dir);
|
|
||||||
|
|
||||||
return xfer->actual_len < xfer->total_len;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------*/
|
/*------------------------------------------------------------------*/
|
||||||
/* Interrupt Handler
|
/* Interrupt Handler
|
||||||
*------------------------------------------------------------------*/
|
*------------------------------------------------------------------*/
|
||||||
|
@ -218,14 +218,6 @@ bool dcd_edpt_open(uint8_t rhport, tusb_desc_endpoint_t const * p_endpoint_desc)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool dcd_edpt_busy(uint8_t rhport, uint8_t ep_addr)
|
|
||||||
{
|
|
||||||
(void) rhport;
|
|
||||||
|
|
||||||
uint8_t const ep_id = ep_addr2id(ep_addr);
|
|
||||||
return _dcd.ep[ep_id][0].active;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void prepare_ep_xfer(uint8_t ep_id, uint16_t buf_offset, uint16_t total_bytes)
|
static void prepare_ep_xfer(uint8_t ep_id, uint16_t buf_offset, uint16_t total_bytes)
|
||||||
{
|
{
|
||||||
uint16_t const nbytes = tu_min16(total_bytes, DMA_NBYTES_MAX);
|
uint16_t const nbytes = tu_min16(total_bytes, DMA_NBYTES_MAX);
|
||||||
|
@ -316,14 +316,6 @@ bool dcd_edpt_open(uint8_t rhport, tusb_desc_endpoint_t const * p_endpoint_desc)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool dcd_edpt_busy(uint8_t rhport, uint8_t ep_addr)
|
|
||||||
{
|
|
||||||
(void) rhport;
|
|
||||||
|
|
||||||
uint8_t ep_id = ep_addr2idx( ep_addr );
|
|
||||||
return (_dcd.udca[ep_id] != NULL && !_dcd.udca[ep_id]->retired);
|
|
||||||
}
|
|
||||||
|
|
||||||
void dcd_edpt_stall(uint8_t rhport, uint8_t ep_addr)
|
void dcd_edpt_stall(uint8_t rhport, uint8_t ep_addr)
|
||||||
{
|
{
|
||||||
(void) rhport;
|
(void) rhport;
|
||||||
|
@ -240,18 +240,6 @@ bool dcd_edpt_open(uint8_t rhport, tusb_desc_endpoint_t const * p_endpoint_desc)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool dcd_edpt_busy(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);
|
|
||||||
uint8_t const ep_idx = 2*epnum + dir;
|
|
||||||
|
|
||||||
dcd_qtd_t * p_qtd = &dcd_data_ptr[rhport]->qtd[ep_idx];
|
|
||||||
|
|
||||||
return p_qtd->active;
|
|
||||||
// return !p_qhd->qtd_overlay.halted && p_qhd->qtd_overlay.active;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes)
|
bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes)
|
||||||
{
|
{
|
||||||
uint8_t const epnum = tu_edpt_number(ep_addr);
|
uint8_t const epnum = tu_edpt_number(ep_addr);
|
||||||
|
@ -67,15 +67,19 @@ bool dcd_edpt_open (uint8_t rhport, tusb_desc_endpoint_t const * p_endpoint_desc
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes)
|
bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes)
|
||||||
{ return false;}
|
{
|
||||||
bool dcd_edpt_busy (uint8_t rhport, uint8_t ep_addr)
|
return false;
|
||||||
{ return false;}
|
}
|
||||||
|
|
||||||
void dcd_edpt_stall (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)
|
void dcd_edpt_clear_stall (uint8_t rhport, uint8_t ep_addr)
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -397,32 +397,6 @@ void dcd_edpt_clear_stall (uint8_t rhport, uint8_t ep_addr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool dcd_edpt_busy (uint8_t rhport, uint8_t ep_addr)
|
|
||||||
{
|
|
||||||
(void) rhport;
|
|
||||||
USB_OTG_OUTEndpointTypeDef * out_ep = OUT_EP_BASE;
|
|
||||||
USB_OTG_INEndpointTypeDef * in_ep = IN_EP_BASE;
|
|
||||||
|
|
||||||
// USBD shouldn't check control endpoint state
|
|
||||||
if ( 0 == ep_addr ) return false;
|
|
||||||
|
|
||||||
uint8_t const epnum = tu_edpt_number(ep_addr);
|
|
||||||
|
|
||||||
bool enabled = false;
|
|
||||||
bool xferring = true;
|
|
||||||
|
|
||||||
if (tu_edpt_dir(ep_addr) == TUSB_DIR_IN) {
|
|
||||||
enabled = (in_ep[epnum].DIEPCTL & USB_OTG_DIEPCTL_EPENA_Msk);
|
|
||||||
xferring = (in_ep[epnum].DIEPTSIZ & USB_OTG_DIEPTSIZ_PKTCNT_Msk);
|
|
||||||
} else {
|
|
||||||
enabled = (out_ep[epnum].DOEPCTL & USB_OTG_DOEPCTL_EPENA_Msk);
|
|
||||||
xferring = (out_ep[epnum].DOEPTSIZ & USB_OTG_DOEPTSIZ_PKTCNT_Msk);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Also check that endpoint is active (not just enabled)?
|
|
||||||
return (enabled && xferring);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------*/
|
/*------------------------------------------------------------------*/
|
||||||
|
|
||||||
// TODO: Split into "receive on endpoint 0" and "receive generic"; endpoint 0's
|
// TODO: Split into "receive on endpoint 0" and "receive generic"; endpoint 0's
|
||||||
|
Loading…
x
Reference in New Issue
Block a user