mirror of
https://github.com/hathach/tinyusb.git
synced 2025-04-16 05:42:56 +00:00
Fixing NAKed OUT xfer
This commit is contained in:
parent
d0dd3c77ff
commit
8cae17bfc8
@ -60,7 +60,8 @@
|
|||||||
#define EP_GET_FIFO_PTR(ep, scale) (((TU_XSTRCAT(TU_STRCAT(uint, scale),_t) (*)[0x8000 / ((scale) / 8)])USBHS_RAM_ADDR)[(ep)])
|
#define EP_GET_FIFO_PTR(ep, scale) (((TU_XSTRCAT(TU_STRCAT(uint, scale),_t) (*)[0x8000 / ((scale) / 8)])USBHS_RAM_ADDR)[(ep)])
|
||||||
|
|
||||||
// Errata: The DMA feature is not available for Pipe/Endpoint 7
|
// Errata: The DMA feature is not available for Pipe/Endpoint 7
|
||||||
#define EP_DMA_SUPPORT(epnum) (epnum >= 1 && epnum <= 6)
|
// #define EP_DMA_SUPPORT(epnum) (epnum >= 1 && epnum <= 6)
|
||||||
|
#define EP_DMA_SUPPORT(epnum) 0
|
||||||
|
|
||||||
// DMA Channel Transfer Descriptor
|
// DMA Channel Transfer Descriptor
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -294,8 +295,6 @@ static void dcd_ep_handler(uint8_t ep_ix)
|
|||||||
}
|
}
|
||||||
// Acknowledge the interrupt
|
// Acknowledge the interrupt
|
||||||
USBHS->USBHS_DEVEPTICR[ep_ix] = USBHS_DEVEPTICR_RXOUTIC;
|
USBHS->USBHS_DEVEPTICR[ep_ix] = USBHS_DEVEPTICR_RXOUTIC;
|
||||||
// Clear the FIFO control flag to receive more data.
|
|
||||||
USBHS->USBHS_DEVEPTIDR[ep_ix] = USBHS_DEVEPTIDR_FIFOCONC;
|
|
||||||
if ((count < xfer->max_packet_size) || (xfer->queued_len == xfer->total_len))
|
if ((count < xfer->max_packet_size) || (xfer->queued_len == xfer->total_len))
|
||||||
{
|
{
|
||||||
// RX COMPLETE
|
// RX COMPLETE
|
||||||
@ -314,10 +313,10 @@ static void dcd_ep_handler(uint8_t ep_ix)
|
|||||||
{
|
{
|
||||||
// TX not complete
|
// TX not complete
|
||||||
dcd_transmit_packet(xfer, ep_ix);
|
dcd_transmit_packet(xfer, ep_ix);
|
||||||
} else {
|
} else
|
||||||
|
{
|
||||||
// TX complete
|
// TX complete
|
||||||
dcd_event_xfer_complete(0, 0x80 + ep_ix, xfer->total_len, XFER_RESULT_SUCCESS, true);
|
dcd_event_xfer_complete(0, 0x80 + ep_ix, xfer->total_len, XFER_RESULT_SUCCESS, true);
|
||||||
USBHS->USBHS_DEVEPTIDR[ep_ix] = USBHS_DEVEPTIDR_TXINEC;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -338,7 +337,8 @@ static void dcd_dma_handler(uint8_t ep_ix)
|
|||||||
if(USBHS->USBHS_DEVEPTCFG[ep_ix] & USBHS_DEVEPTCFG_EPDIR)
|
if(USBHS->USBHS_DEVEPTCFG[ep_ix] & USBHS_DEVEPTCFG_EPDIR)
|
||||||
{
|
{
|
||||||
dcd_event_xfer_complete(0, 0x80 + ep_ix, count, XFER_RESULT_SUCCESS, true);
|
dcd_event_xfer_complete(0, 0x80 + ep_ix, count, XFER_RESULT_SUCCESS, true);
|
||||||
} else {
|
} else
|
||||||
|
{
|
||||||
dcd_event_xfer_complete(0, ep_ix, count, XFER_RESULT_SUCCESS, true);
|
dcd_event_xfer_complete(0, ep_ix, count, XFER_RESULT_SUCCESS, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -483,14 +483,17 @@ bool dcd_edpt_open (uint8_t rhport, tusb_desc_endpoint_t const * ep_desc)
|
|||||||
{
|
{
|
||||||
// Endpoint configuration is successful
|
// Endpoint configuration is successful
|
||||||
USBHS->USBHS_DEVEPTIER[0] = USBHS_DEVEPTIER_CTRL_RXSTPES;
|
USBHS->USBHS_DEVEPTIER[0] = USBHS_DEVEPTIER_CTRL_RXSTPES;
|
||||||
|
USBHS->USBHS_DEVEPTIER[0] = USBHS_DEVEPTIER_RXOUTES;
|
||||||
// Enable Endpoint 0 Interrupts
|
// Enable Endpoint 0 Interrupts
|
||||||
USBHS->USBHS_DEVIER = USBHS_DEVIER_PEP_0;
|
USBHS->USBHS_DEVIER = USBHS_DEVIER_PEP_0;
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else
|
||||||
|
{
|
||||||
// Endpoint configuration is not successful
|
// Endpoint configuration is not successful
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else
|
||||||
|
{
|
||||||
// Enable the endpoint
|
// Enable the endpoint
|
||||||
USBHS->USBHS_DEVEPT |= ((0x01 << epnum) << USBHS_DEVEPT_EPEN0_Pos);
|
USBHS->USBHS_DEVEPT |= ((0x01 << epnum) << USBHS_DEVEPT_EPEN0_Pos);
|
||||||
// Set up the maxpacket size, fifo start address fifosize
|
// Set up the maxpacket size, fifo start address fifosize
|
||||||
@ -520,8 +523,17 @@ bool dcd_edpt_open (uint8_t rhport, tusb_desc_endpoint_t const * ep_desc)
|
|||||||
if (USBHS_DEVEPTISR_CFGOK == (USBHS->USBHS_DEVEPTISR[epnum] & USBHS_DEVEPTISR_CFGOK))
|
if (USBHS_DEVEPTISR_CFGOK == (USBHS->USBHS_DEVEPTISR[epnum] & USBHS_DEVEPTISR_CFGOK))
|
||||||
{
|
{
|
||||||
USBHS->USBHS_DEVIER = ((0x01 << epnum) << USBHS_DEVIER_PEP_0_Pos);
|
USBHS->USBHS_DEVIER = ((0x01 << epnum) << USBHS_DEVIER_PEP_0_Pos);
|
||||||
|
if (dir)
|
||||||
|
{
|
||||||
|
USBHS->USBHS_DEVEPTICR[epnum] = USBHS_DEVEPTICR_TXINIC;
|
||||||
|
USBHS->USBHS_DEVEPTIER[epnum] = USBHS_DEVEPTIER_TXINES;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
USBHS->USBHS_DEVEPTIER[epnum] = USBHS_DEVEPTIER_RXOUTES;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else
|
||||||
|
{
|
||||||
// Endpoint configuration is not successful
|
// Endpoint configuration is not successful
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -553,7 +565,8 @@ static void dcd_transmit_packet(xfer_ctl_t * xfer, uint8_t ep_ix)
|
|||||||
{
|
{
|
||||||
memcpy(ptr, xfer->buffer + xfer->queued_len, len);
|
memcpy(ptr, xfer->buffer + xfer->queued_len, len);
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
tu_fifo_read_n(xfer->fifo, ptr, len);
|
tu_fifo_read_n(xfer->fifo, ptr, len);
|
||||||
}
|
}
|
||||||
__DSB();
|
__DSB();
|
||||||
@ -564,11 +577,12 @@ static void dcd_transmit_packet(xfer_ctl_t * xfer, uint8_t ep_ix)
|
|||||||
{
|
{
|
||||||
// Control endpoint: clear the interrupt flag to send the data
|
// Control endpoint: clear the interrupt flag to send the data
|
||||||
USBHS->USBHS_DEVEPTICR[0] = USBHS_DEVEPTICR_TXINIC;
|
USBHS->USBHS_DEVEPTICR[0] = USBHS_DEVEPTICR_TXINIC;
|
||||||
} else {
|
USBHS->USBHS_DEVEPTIER[0] = USBHS_DEVEPTIER_TXINES;
|
||||||
|
} else
|
||||||
|
{
|
||||||
// Other endpoint types: clear the FIFO control flag to send the data
|
// Other endpoint types: clear the FIFO control flag to send the data
|
||||||
USBHS->USBHS_DEVEPTIDR[ep_ix] = USBHS_DEVEPTIDR_FIFOCONC;
|
USBHS->USBHS_DEVEPTIDR[ep_ix] = USBHS_DEVEPTIDR_FIFOCONC;
|
||||||
}
|
}
|
||||||
USBHS->USBHS_DEVEPTIER[ep_ix] = USBHS_DEVEPTIER_TXINES;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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
|
||||||
@ -615,11 +629,14 @@ bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t
|
|||||||
// and the DMA transfer must be not started.
|
// and the DMA transfer must be not started.
|
||||||
// It is the end of transfer
|
// It is the end of transfer
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else
|
||||||
|
{
|
||||||
if (dir == TUSB_DIR_OUT)
|
if (dir == TUSB_DIR_OUT)
|
||||||
{
|
{
|
||||||
USBHS->USBHS_DEVEPTIER[epnum] = USBHS_DEVEPTIER_RXOUTES;
|
// Clear the FIFO control flag to receive more data.
|
||||||
} else {
|
USBHS->USBHS_DEVEPTIDR[epnum] = USBHS_DEVEPTIDR_FIFOCONC;
|
||||||
|
} else
|
||||||
|
{
|
||||||
dcd_transmit_packet(xfer,epnum);
|
dcd_transmit_packet(xfer,epnum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -696,11 +713,13 @@ bool dcd_edpt_xfer_fifo (uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16
|
|||||||
// and the DMA transfer must be not started.
|
// and the DMA transfer must be not started.
|
||||||
// It is the end of transfer
|
// It is the end of transfer
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else
|
||||||
|
{
|
||||||
if (dir == TUSB_DIR_OUT)
|
if (dir == TUSB_DIR_OUT)
|
||||||
{
|
{
|
||||||
USBHS->USBHS_DEVEPTIER[epnum] = USBHS_DEVEPTIER_RXOUTES;
|
USBHS->USBHS_DEVEPTIER[epnum] = USBHS_DEVEPTIER_RXOUTES;
|
||||||
} else {
|
} else
|
||||||
|
{
|
||||||
dcd_transmit_packet(xfer,epnum);
|
dcd_transmit_packet(xfer,epnum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user