summaryrefslogtreecommitdiff
path: root/src/portable
diff options
context:
space:
mode:
authorhathach <[email protected]>2026-01-03 00:34:49 +0700
committerhathach <[email protected]>2026-01-03 00:47:40 +0700
commitc87f0db45978b6b1f11f151bf5c061b926dba245 (patch)
tree3bcac081786f7aac09615fe129e65bf713c9739a /src/portable
parentb87c2fcc9f68f6e0f5e8add653ee0c67d3467e02 (diff)
add tu_hwfifo_access_t param to hwfifo API
Diffstat (limited to 'src/portable')
-rw-r--r--src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c13
-rw-r--r--src/portable/synopsys/dwc2/dcd_dwc2.c12
-rw-r--r--src/portable/synopsys/dwc2/dwc2_common.c54
-rw-r--r--src/portable/synopsys/dwc2/hcd_dwc2.c6
4 files changed, 19 insertions, 66 deletions
diff --git a/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c b/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
index fe4f649da..2832611ff 100644
--- a/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
+++ b/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
@@ -285,7 +285,8 @@ static void handle_ctr_setup(uint32_t ep_id) {
uint16_t rx_addr = btable_get_addr(ep_id, BTABLE_BUF_RX);
uint8_t setup_packet[8] TU_ATTR_ALIGNED(4);
- tu_hwfifo_read(PMA_BUF_AT(rx_addr), setup_packet, rx_count);
+ const tu_hwfifo_access_t access_mode = {.data_stride = CFG_TUSB_FIFO_HWFIFO_DATA_STRIDE};
+ tu_hwfifo_read(PMA_BUF_AT(rx_addr), setup_packet, rx_count, &access_mode);
// Clear CTR RX if another setup packet arrived before this, it will be discarded
ep_write_clear_ctr(ep_id, TUSB_DIR_OUT);
@@ -323,10 +324,11 @@ static void handle_ctr_rx(uint32_t ep_id) {
uint16_t pma_addr = (uint16_t) btable_get_addr(ep_id, buf_id);
fsdev_pma_buf_t *pma_buf = PMA_BUF_AT(pma_addr);
+ const tu_hwfifo_access_t access_mode = {.data_stride = CFG_TUSB_FIFO_HWFIFO_DATA_STRIDE};
if (xfer->ff) {
- tu_hwfifo_read_to_fifo(pma_buf, xfer->ff, rx_count);
+ tu_hwfifo_read_to_fifo(pma_buf, xfer->ff, rx_count, &access_mode);
} else {
- tu_hwfifo_read(pma_buf, xfer->buffer + xfer->queued_len, rx_count);
+ tu_hwfifo_read(pma_buf, xfer->buffer + xfer->queued_len, rx_count, &access_mode);
}
xfer->queued_len += rx_count;
@@ -721,10 +723,11 @@ static void dcd_transmit_packet(xfer_ctl_t *xfer, uint16_t ep_ix) {
uint16_t addr_ptr = (uint16_t)btable_get_addr(ep_ix, buf_id);
fsdev_pma_buf_t *pma_buf = PMA_BUF_AT(addr_ptr);
+ const tu_hwfifo_access_t access_mode = {.data_stride = CFG_TUSB_FIFO_HWFIFO_DATA_STRIDE};
if (xfer->ff) {
- tu_hwfifo_write_from_fifo(pma_buf, xfer->ff, len);
+ tu_hwfifo_write_from_fifo(pma_buf, xfer->ff, len, &access_mode);
} else {
- tu_hwfifo_write(pma_buf, &(xfer->buffer[xfer->queued_len]), len);
+ tu_hwfifo_write(pma_buf, &(xfer->buffer[xfer->queued_len]), len, &access_mode);
}
xfer->queued_len += len;
diff --git a/src/portable/synopsys/dwc2/dcd_dwc2.c b/src/portable/synopsys/dwc2/dcd_dwc2.c
index b44b8b56e..2309afd53 100644
--- a/src/portable/synopsys/dwc2/dcd_dwc2.c
+++ b/src/portable/synopsys/dwc2/dcd_dwc2.c
@@ -365,12 +365,13 @@ static uint16_t epin_write_tx_fifo(dwc2_regs_t *dwc2, uint8_t epnum) {
}
// Push packet to Tx-FIFO
+ const tu_hwfifo_access_t access_mode = {.data_stride = CFG_TUSB_FIFO_HWFIFO_DATA_STRIDE};
+ volatile uint32_t *tx_fifo = dwc2->fifo[epnum];
if (xfer->ff) {
- volatile uint32_t* tx_fifo = dwc2->fifo[epnum];
- tu_hwfifo_write_from_fifo(tx_fifo, xfer->ff, xact_bytes);
+ tu_hwfifo_write_from_fifo(tx_fifo, xfer->ff, xact_bytes, &access_mode);
total_bytes_written += xact_bytes;
} else {
- dfifo_write_packet(dwc2, epnum, xfer->buffer, xact_bytes);
+ tu_hwfifo_write(tx_fifo, xfer->buffer, xact_bytes, &access_mode);
xfer->buffer += xact_bytes;
total_bytes_written += xact_bytes;
}
@@ -888,10 +889,11 @@ static void handle_rxflvl_irq(uint8_t rhport) {
if (byte_count != 0) {
// Read packet off RxFIFO
+ const tu_hwfifo_access_t access_mode = {.data_stride = CFG_TUSB_FIFO_HWFIFO_DATA_STRIDE};
if (xfer->ff != NULL) {
- tu_hwfifo_read_to_fifo(rx_fifo, xfer->ff, byte_count);
+ tu_hwfifo_read_to_fifo(rx_fifo, xfer->ff, byte_count, &access_mode);
} else {
- dfifo_read_packet(dwc2, xfer->buffer, byte_count);
+ tu_hwfifo_read(rx_fifo, xfer->buffer, byte_count, &access_mode);
xfer->buffer += byte_count;
}
}
diff --git a/src/portable/synopsys/dwc2/dwc2_common.c b/src/portable/synopsys/dwc2/dwc2_common.c
index 980574e12..a7e6188df 100644
--- a/src/portable/synopsys/dwc2/dwc2_common.c
+++ b/src/portable/synopsys/dwc2/dwc2_common.c
@@ -264,58 +264,4 @@ bool dwc2_core_init(uint8_t rhport, bool is_highspeed, bool is_dma) {
//
// }
-//--------------------------------------------------------------------
-// DFIFO
-//--------------------------------------------------------------------
-// Read a single data packet from receive DFIFO
-void dfifo_read_packet(dwc2_regs_t* dwc2, uint8_t* dst, uint16_t len) {
- const volatile uint32_t* rx_fifo = dwc2->fifo[0];
-
- // Reading full available 32 bit words from fifo
- uint16_t word_count = len >> 2;
- while (word_count--) {
- tu_unaligned_write32(dst, *rx_fifo);
- dst += 4;
- }
-
- // Read the remaining 1-3 bytes from fifo
- const uint8_t bytes_rem = len & 0x03;
- if (bytes_rem != 0) {
- const uint32_t tmp = *rx_fifo;
- dst[0] = tu_u32_byte0(tmp);
- if (bytes_rem > 1) {
- dst[1] = tu_u32_byte1(tmp);
- }
- if (bytes_rem > 2) {
- dst[2] = tu_u32_byte2(tmp);
- }
- }
-}
-
-// Write a single data packet to DFIFO
-void dfifo_write_packet(dwc2_regs_t* dwc2, uint8_t fifo_num, const uint8_t* src, uint16_t len) {
- volatile uint32_t* tx_fifo = dwc2->fifo[fifo_num];
-
- // Pushing full available 32 bit words to fifo
- uint16_t word_count = len >> 2;
- while (word_count--) {
- *tx_fifo = tu_unaligned_read32(src);
- src += 4;
- }
-
- // Write the remaining 1-3 bytes into fifo
- const uint8_t bytes_rem = len & 0x03;
- if (bytes_rem) {
- uint32_t tmp_word = src[0];
- if (bytes_rem > 1) {
- tmp_word |= (src[1] << 8);
- }
- if (bytes_rem > 2) {
- tmp_word |= (src[2] << 16);
- }
-
- *tx_fifo = tmp_word;
- }
-}
-
#endif
diff --git a/src/portable/synopsys/dwc2/hcd_dwc2.c b/src/portable/synopsys/dwc2/hcd_dwc2.c
index fc748c85f..570b1c14c 100644
--- a/src/portable/synopsys/dwc2/hcd_dwc2.c
+++ b/src/portable/synopsys/dwc2/hcd_dwc2.c
@@ -856,7 +856,8 @@ static void handle_rxflvl_irq(uint8_t rhport) {
hcd_endpoint_t* edpt = &_hcd_data.edpt[xfer->ep_id];
if (byte_count > 0) {
- dfifo_read_packet(dwc2, edpt->buffer + xfer->xferred_bytes, byte_count);
+ const tu_hwfifo_access_t access_mode = {.data_stride = CFG_TUSB_FIFO_HWFIFO_DATA_STRIDE};
+ tu_hwfifo_read(dwc2->fifo[0], edpt->buffer + xfer->xferred_bytes, byte_count, &access_mode);
xfer->xferred_bytes += byte_count;
xfer->fifo_bytes = byte_count;
}
@@ -907,7 +908,8 @@ static bool handle_txfifo_empty(dwc2_regs_t* dwc2, bool is_periodic) {
return true;
}
- dfifo_write_packet(dwc2, ch_id, edpt->buffer + xfer->fifo_bytes, xact_bytes);
+ const tu_hwfifo_access_t access_mode = {.data_stride = CFG_TUSB_FIFO_HWFIFO_DATA_STRIDE};
+ tu_hwfifo_write(dwc2->fifo[ch_id], edpt->buffer + xfer->fifo_bytes, xact_bytes, &access_mode);
xfer->fifo_bytes += xact_bytes;
}
}