mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-31 05:52:55 +08:00
dcd_synopsys: Fix off-by-one error in FIFO allocation.
This commit is contained in:
parent
77cc5b1b0c
commit
108f756e22
@ -305,18 +305,22 @@ bool dcd_edpt_open (uint8_t rhport, tusb_desc_endpoint_t const * desc_edpt)
|
||||
// Since OUT FIFO = GRXFSIZ, FIFO 0 = 16, for simplicity, we equally allocated for the rest of endpoints
|
||||
// - Size : (FIFO_SIZE/4 - GRXFSIZ - 16) / (EP_MAX-1)
|
||||
// - Offset: GRXFSIZ + 16 + Size*(epnum-1)
|
||||
// - IN EP 1 gets FIFO 1, IN EP "n" gets FIFO "n".
|
||||
|
||||
in_ep[epnum].DIEPCTL |= (1 << USB_OTG_DIEPCTL_USBAEP_Pos) | \
|
||||
(epnum - 1) << USB_OTG_DIEPCTL_TXFNUM_Pos | \
|
||||
epnum << USB_OTG_DIEPCTL_TXFNUM_Pos | \
|
||||
desc_edpt->bmAttributes.xfer << USB_OTG_DIEPCTL_EPTYP_Pos | \
|
||||
(desc_edpt->bmAttributes.xfer != TUSB_XFER_ISOCHRONOUS ? USB_OTG_DOEPCTL_SD0PID_SEVNFRM : 0) | \
|
||||
desc_edpt->wMaxPacketSize.size << USB_OTG_DIEPCTL_MPSIZ_Pos;
|
||||
dev->DAINTMSK |= (1 << (USB_OTG_DAINTMSK_IEPM_Pos + epnum));
|
||||
|
||||
// Both TXFD and TXSA are in unit of 32-bit words
|
||||
// Both TXFD and TXSA are in unit of 32-bit words.
|
||||
// IN FIFO 0 was configured during enumeration, hence the "+ 16".
|
||||
uint16_t const allocated_size = (USB_OTG_FS->GRXFSIZ & 0x0000ffff) + 16;
|
||||
uint16_t const fifo_size = (EP_FIFO_SIZE/4 - allocated_size) / (EP_MAX-1);
|
||||
uint32_t const fifo_offset = allocated_size + fifo_size*(epnum-1);
|
||||
|
||||
// DIEPTXF starts at FIFO #1.
|
||||
USB_OTG_FS->DIEPTXF[epnum - 1] = (fifo_size << USB_OTG_DIEPTXF_INEPTXFD_Pos) | fifo_offset;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user