mirror of
https://github.com/hathach/tinyusb.git
synced 2025-05-08 23:01:36 +08:00
dwc2: configure fifo size to be twice the max_size
This is needed in order to always be able to fit a packet in the fifo. Writing to the fifo is done from an interrupts that fires when the fifo is half-empty, so the fifo must be twice the packet size.
This commit is contained in:
parent
2afef458be
commit
5ade917805
@ -534,6 +534,9 @@ void dcd_init (uint8_t rhport)
|
||||
int_mask = dwc2->gotgint;
|
||||
dwc2->gotgint |= int_mask;
|
||||
|
||||
// Configure TX FIFO to set the TX FIFO empty interrupt when half-empty
|
||||
dwc2->gahbcfg &= ~GAHBCFG_TXFELVL;
|
||||
|
||||
// Required as part of core initialization.
|
||||
// TODO: How should mode mismatch be handled? It will cause
|
||||
// the core to stop working/require reset.
|
||||
@ -645,7 +648,10 @@ bool dcd_edpt_open (uint8_t rhport, tusb_desc_endpoint_t const * desc_edpt)
|
||||
xfer->max_size = tu_edpt_packet_size(desc_edpt);
|
||||
xfer->interval = desc_edpt->bInterval;
|
||||
|
||||
uint16_t const fifo_size = tu_div_ceil(xfer->max_size, 4);
|
||||
// The fifo-empty interrupt fires when the interrupt is half empty. In order
|
||||
// to be able to write a packet at that point, the fifo must be twice the
|
||||
// max_size.
|
||||
uint16_t const fifo_size = tu_div_ceil(xfer->max_size * 2, 4);
|
||||
|
||||
if(dir == TUSB_DIR_OUT)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user