mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-17 05:32:55 +08:00
Change copy modes for new read/write functions in tusb_fifo.c
This commit is contained in:
parent
3cdb82c21c
commit
a1b07ae14c
@ -382,16 +382,6 @@ bool dcd_edpt_xfer_fifo (uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16
|
||||
num_packets++;
|
||||
}
|
||||
|
||||
// Set copy mode to constant address - required since data copied to or from the hardware USB FIFO needs to be written at a constant address
|
||||
if (dir == TUSB_DIR_IN)
|
||||
{
|
||||
tu_fifo_set_copy_mode_write(ff, TU_FIFO_COPY_CST);
|
||||
}
|
||||
else
|
||||
{
|
||||
tu_fifo_set_copy_mode_read(ff, TU_FIFO_COPY_CST);
|
||||
}
|
||||
|
||||
ESP_LOGV(TAG, "Transfer <-> EP%i, %s, pkgs: %i, bytes: %i",
|
||||
epnum, ((dir == TUSB_DIR_IN) ? "USB0.HOST (in)" : "HOST->DEV (out)"),
|
||||
num_packets, total_bytes);
|
||||
@ -527,7 +517,7 @@ static void receive_packet(xfer_ctl_t *xfer, /* usb_out_endpoint_t * out_ep, */
|
||||
if (xfer->ff)
|
||||
{
|
||||
// Ring buffer
|
||||
tu_fifo_write_n(xfer->ff, (const void *) rx_fifo, to_recv_size);
|
||||
tu_fifo_write_n_const_addr(xfer->ff, (const void *) rx_fifo, to_recv_size);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -583,7 +573,7 @@ static void transmit_packet(xfer_ctl_t *xfer, volatile usb_in_endpoint_t *in_ep,
|
||||
|
||||
if (xfer->ff)
|
||||
{
|
||||
tu_fifo_read_n(xfer->ff, (void *) tx_fifo, to_xfer_size);
|
||||
tu_fifo_read_n_const_addr(xfer->ff, (void *) tx_fifo, to_xfer_size);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -312,14 +312,11 @@ bool dcd_edpt_xfer_fifo (uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16
|
||||
|
||||
if (dir == TUSB_DIR_OUT)
|
||||
{
|
||||
tu_fifo_set_copy_mode_read(ff, TU_FIFO_COPY_CST);
|
||||
|
||||
// Enable interrupt when starting OUT transfer
|
||||
if (epnum != 0) UDP->UDP_IER |= (1 << epnum);
|
||||
}
|
||||
else
|
||||
{
|
||||
tu_fifo_set_copy_mode_write(ff, TU_FIFO_COPY_CST);
|
||||
tu_fifo_read_n(ff, (void *) &UDP->UDP_FDR[epnum], xfer_packet_len(xfer));
|
||||
|
||||
// TX ready for transfer
|
||||
@ -440,7 +437,7 @@ void dcd_int_handler(uint8_t rhport)
|
||||
// write to EP fifo
|
||||
if (xfer->ff)
|
||||
{
|
||||
tu_fifo_read_n(xfer->ff, (void *) &UDP->UDP_FDR[epnum], xact_len);
|
||||
tu_fifo_read_n_const_addr(xfer->ff, (void *) &UDP->UDP_FDR[epnum], xact_len);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -473,7 +470,7 @@ void dcd_int_handler(uint8_t rhport)
|
||||
// Read from EP fifo
|
||||
if (xfer->ff)
|
||||
{
|
||||
tu_fifo_write_n(xfer->ff, (const void *) &UDP->UDP_FDR[epnum], xact_len);
|
||||
tu_fifo_write_n_const_addr(xfer->ff, (const void *) &UDP->UDP_FDR[epnum], xact_len);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -314,12 +314,10 @@ bool dcd_edpt_xfer_fifo (uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16
|
||||
|
||||
if (TUSB_DIR_IN == dir)
|
||||
{
|
||||
tu_fifo_set_copy_mode_write(ff, TU_FIFO_COPY_INC); // For the PHY in nuc120 the source and destination pointer have to be incremented!
|
||||
dcd_in_xfer(xfer, ep);
|
||||
}
|
||||
else
|
||||
{
|
||||
tu_fifo_set_copy_mode_read(ff, TU_FIFO_COPY_INC); // For the PHY in nuc120 the source and destination pointer have to be incremented!
|
||||
xfer->out_bytes_so_far = 0;
|
||||
ep->MXPLD = xfer->max_packet_size;
|
||||
}
|
||||
|
@ -320,12 +320,10 @@ bool dcd_edpt_xfer_fifo (uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16
|
||||
|
||||
if (TUSB_DIR_IN == dir)
|
||||
{
|
||||
tu_fifo_set_copy_mode_write(ff, TU_FIFO_COPY_INC); // For the PHY in nuc120 the source and destination pointer have to be incremented!
|
||||
dcd_in_xfer(xfer, ep);
|
||||
}
|
||||
else
|
||||
{
|
||||
tu_fifo_set_copy_mode_read(ff, TU_FIFO_COPY_INC); // For the PHY in nuc120 the source and destination pointer have to be incremented!
|
||||
xfer->out_bytes_so_far = 0;
|
||||
ep->MXPLD = xfer->max_packet_size;
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ static void dcd_userEP_in_xfer(struct xfer_ctl_t *xfer, USBD_EP_T *ep)
|
||||
/* provided buffers are thankfully 32-bit aligned, allowing most data to be transfered as 32-bit */
|
||||
if (xfer->ff)
|
||||
{
|
||||
tu_fifo_read_n(xfer->ff, (void *) (&ep->EPDAT_BYTE), bytes_now);
|
||||
tu_fifo_read_n_const_addr(xfer->ff, (void *) (&ep->EPDAT_BYTE), bytes_now);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -431,12 +431,10 @@ bool dcd_edpt_xfer_fifo (uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16
|
||||
|
||||
if (TUSB_DIR_IN == dir)
|
||||
{
|
||||
tu_fifo_set_copy_mode_write(ff, TU_FIFO_COPY_CST); // For the PHY in nuc505 the source and destination pointer have to be constant!
|
||||
ep->EPINTEN = USBD_EPINTEN_BUFEMPTYIEN_Msk;
|
||||
}
|
||||
else
|
||||
{
|
||||
tu_fifo_set_copy_mode_read(ff, TU_FIFO_COPY_CST); // For the PHY in nuc505 the source and destination pointer have to be constant!
|
||||
xfer->out_bytes_so_far = 0;
|
||||
ep->EPINTEN = USBD_EPINTEN_RXPKIEN_Msk;
|
||||
}
|
||||
@ -659,7 +657,7 @@ void dcd_int_handler(uint8_t rhport)
|
||||
/* copy the data from the PC to the previously provided buffer */
|
||||
if (xfer->ff)
|
||||
{
|
||||
tu_fifo_write_n(xfer->ff, (const void *) &ep->EPDAT_BYTE, tu_min16(available_bytes, xfer->total_bytes - xfer->out_bytes_so_far));
|
||||
tu_fifo_write_n_const_addr(xfer->ff, (const void *) &ep->EPDAT_BYTE, tu_min16(available_bytes, xfer->total_bytes - xfer->out_bytes_so_far));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -105,7 +105,7 @@ bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t
|
||||
return false;
|
||||
}
|
||||
|
||||
// Submit a transfer where is managed by FIFO, When complete dcd_event_xfer_complete() is invoked to notify the stack
|
||||
// Submit a transfer where is managed by FIFO, When complete dcd_event_xfer_complete() is invoked to notify the stack - optional, however, must be listed in usbd.c
|
||||
bool dcd_edpt_xfer_fifo (uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_t total_bytes)
|
||||
{
|
||||
(void) rhport;
|
||||
|
@ -365,12 +365,10 @@ bool dcd_edpt_xfer_fifo (uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16
|
||||
|
||||
if(dir == TUSB_DIR_OUT)
|
||||
{
|
||||
tu_fifo_set_copy_mode_read(ff, TU_FIFO_COPY_INC); // For the PHY in msp430 the source and destination pointer have to be incremented!
|
||||
ep_regs[BCTX] &= ~NAK;
|
||||
}
|
||||
else
|
||||
{
|
||||
tu_fifo_set_copy_mode_write(ff, TU_FIFO_COPY_INC); // For the PHY in msp430 the source and destination pointer have to be incremented!
|
||||
USBIEPIFG |= (1 << epnum);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user