change signature of tu_hwfifo_* to have hwfifo as first parameter

This commit is contained in:
hathach
2026-01-01 12:51:05 +07:00
parent 009750c747
commit 9ab605ef0b
4 changed files with 18 additions and 8 deletions

View File

@ -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

View File

@ -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

View File

@ -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);
}

View File

@ -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;