summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhathach <[email protected]>2026-01-01 12:51:05 +0700
committerhathach <[email protected]>2026-01-01 12:51:05 +0700
commit9ab605ef0b7402e72f9540d4b54af607d60cfd7a (patch)
tree63c60876da6833d6339c7c361e246e2bf807cd63 /src
parent009750c747ff1d5a25d976de9161b974eb5f18e7 (diff)
change signature of tu_hwfifo_* to have hwfifo as first parameter
Diffstat (limited to 'src')
-rw-r--r--src/common/tusb_fifo.c8
-rw-r--r--src/common/tusb_fifo.h10
-rw-r--r--src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c4
-rw-r--r--src/portable/synopsys/dwc2/dcd_dwc2.c4
4 files changed, 18 insertions, 8 deletions
diff --git a/src/common/tusb_fifo.c b/src/common/tusb_fifo.c
index 38b00d9d6..828240b6c 100644
--- a/src/common/tusb_fifo.c
+++ b/src/common/tusb_fifo.c
@@ -167,9 +167,17 @@ void tu_hwfifo_write(volatile void *hwfifo, const uint8_t *src, uint16_t len) {
// Write the remaining 1 byte (16bit) or 1-3 bytes (32bit)
if (len > 0) {
+ #ifdef CFG_TUSB_FIFO_HWFIFO_DATA_STRIDE_ODD_BYTE
+ // odd byte access, write byte per byte e.g for rusb2. No address stride needed
+ volatile uint8_t *dest8 = (volatile uint8_t *)dest;
+ for (uint16_t i = 0; i < len; ++i) {
+ *dest8 = src[i];
+ }
+ #else
hwfifo_item_t tmp = 0u;
memcpy(&tmp, src, len);
*dest = tmp;
+ #endif
}
}
#endif
diff --git a/src/common/tusb_fifo.h b/src/common/tusb_fifo.h
index 2473a5605..e1ea1126c 100644
--- a/src/common/tusb_fifo.h
+++ b/src/common/tusb_fifo.h
@@ -226,12 +226,14 @@ TU_ATTR_ALWAYS_INLINE static inline uint16_t tu_fifo_write_n(tu_fifo_t *f, const
// CFG_TUSB_FIFO_HWFIFO_DATA_STRIDE (data width) and CFG_TUSB_FIFO_HWFIFO_ADDR_STRIDE (address increment)
// Note: these usually has opposiite direction (read/write) to/from our software FIFO (tu_fifo_t)
//--------------------------------------------------------------------+
-TU_ATTR_ALWAYS_INLINE static inline uint16_t tu_hwfifo_write_from_fifo(tu_fifo_t *f, void *hwfifo, uint16_t n) {
- return tu_fifo_read_n_access_mode(f, hwfifo, n, true);
+TU_ATTR_ALWAYS_INLINE static inline uint16_t tu_hwfifo_write_from_fifo(volatile void *hwfifo, tu_fifo_t *f,
+ uint16_t n) {
+ return tu_fifo_read_n_access_mode(f, (void *)(uintptr_t)hwfifo, n, true);
}
-TU_ATTR_ALWAYS_INLINE static inline uint16_t tu_hwfifo_read_to_fifo(tu_fifo_t *f, const void *hwfifo, uint16_t n) {
- return tu_fifo_write_n_access_mode(f, hwfifo, n, true);
+TU_ATTR_ALWAYS_INLINE static inline uint16_t tu_hwfifo_read_to_fifo(const volatile void *hwfifo, tu_fifo_t *f,
+ uint16_t n) {
+ return tu_fifo_write_n_access_mode(f, (const void *)(uintptr_t)hwfifo, n, true);
}
#if CFG_TUSB_FIFO_HWFIFO_API
diff --git a/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c b/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
index dae921049..fe4f649da 100644
--- a/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
+++ b/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
@@ -324,7 +324,7 @@ static void handle_ctr_rx(uint32_t ep_id) {
fsdev_pma_buf_t *pma_buf = PMA_BUF_AT(pma_addr);
if (xfer->ff) {
- tu_hwfifo_read_to_fifo(xfer->ff, (void *)pma_buf, rx_count);
+ tu_hwfifo_read_to_fifo(pma_buf, xfer->ff, rx_count);
} else {
tu_hwfifo_read(pma_buf, xfer->buffer + xfer->queued_len, rx_count);
}
@@ -722,7 +722,7 @@ static void dcd_transmit_packet(xfer_ctl_t *xfer, uint16_t ep_ix) {
fsdev_pma_buf_t *pma_buf = PMA_BUF_AT(addr_ptr);
if (xfer->ff) {
- tu_hwfifo_write_from_fifo(xfer->ff, (void *)(uintptr_t)pma_buf, len);
+ tu_hwfifo_write_from_fifo(pma_buf, xfer->ff, len);
} else {
tu_hwfifo_write(pma_buf, &(xfer->buffer[xfer->queued_len]), len);
}
diff --git a/src/portable/synopsys/dwc2/dcd_dwc2.c b/src/portable/synopsys/dwc2/dcd_dwc2.c
index ea952dbcc..b44b8b56e 100644
--- a/src/portable/synopsys/dwc2/dcd_dwc2.c
+++ b/src/portable/synopsys/dwc2/dcd_dwc2.c
@@ -367,7 +367,7 @@ static uint16_t epin_write_tx_fifo(dwc2_regs_t *dwc2, uint8_t epnum) {
// Push packet to Tx-FIFO
if (xfer->ff) {
volatile uint32_t* tx_fifo = dwc2->fifo[epnum];
- tu_hwfifo_write_from_fifo(xfer->ff, (void *)(uintptr_t)tx_fifo, xact_bytes);
+ tu_hwfifo_write_from_fifo(tx_fifo, xfer->ff, xact_bytes);
total_bytes_written += xact_bytes;
} else {
dfifo_write_packet(dwc2, epnum, xfer->buffer, xact_bytes);
@@ -889,7 +889,7 @@ static void handle_rxflvl_irq(uint8_t rhport) {
if (byte_count != 0) {
// Read packet off RxFIFO
if (xfer->ff != NULL) {
- tu_hwfifo_read_to_fifo(xfer->ff, (const void *)(uintptr_t)rx_fifo, byte_count);
+ tu_hwfifo_read_to_fifo(rx_fifo, xfer->ff, byte_count);
} else {
dfifo_read_packet(dwc2, xfer->buffer, byte_count);
xfer->buffer += byte_count;