summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHiFiPhile <[email protected]>2024-04-09 22:15:18 +0200
committerHiFiPhile <[email protected]>2024-04-09 22:15:18 +0200
commitc0824472e8741ba67b660f34f27b5b4fcfe6c295 (patch)
treeab7c04252ffa462be849eb7212122d856c0da82c /src
parent472996e2bfbd14341e99aa58e9f0c24e69a5043e (diff)
Enable double buffer only for PMA > 1024b
Diffstat (limited to 'src')
-rw-r--r--src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c b/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
index a6d92c7c0..d85adfe95 100644
--- a/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
+++ b/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
@@ -950,20 +950,26 @@ bool dcd_edpt_iso_alloc(uint8_t rhport, uint8_t ep_addr, uint16_t largest_packet
{
(void)rhport;
- TU_ASSERT(largest_packet_size <= 1024);
+ TU_ASSERT(largest_packet_size < 1024);
uint8_t const ep_idx = dcd_ep_alloc(ep_addr, TUSB_XFER_ISOCHRONOUS);
const uint16_t buffer_size = pcd_aligned_buffer_size(largest_packet_size);
- /* Create a packet memory buffer area. Enable double buffering */
+ /* Create a packet memory buffer area. Enable double buffering for devices with 2048 bytes PMA,
+ for smaller devices double buffering occupy too much space. */
+#if FSDEV_PMA_SIZE > 1024u
uint32_t pma_addr = dcd_pma_alloc(ep_addr, buffer_size, true);
-
- xfer_ctl_ptr(ep_addr)->ep_idx = ep_idx;
+ uint16_t pma_addr2 = pma_addr >> 16;
+#else
+ uint32_t pma_addr = dcd_pma_alloc(ep_addr, buffer_size, true);
+ uint16_t pma_addr2 = pma_addr;
+#endif
+ pcd_set_ep_tx_address(USB, ep_idx, pma_addr);
+ pcd_set_ep_rx_address(USB, ep_idx, pma_addr2);
pcd_set_eptype(USB, ep_idx, USB_EP_ISOCHRONOUS);
- pcd_set_ep_tx_address(USB, ep_idx, pma_addr & 0xFFFF);
- pcd_set_ep_rx_address(USB, ep_idx, pma_addr >> 16);
+ xfer_ctl_ptr(ep_addr)->ep_idx = ep_idx;
return true;
}