Skip to content

Commit 8a9f44b

Browse files
authored
Merge pull request #3560 from hathach/rp2-disable-hwifo
rp2 disable hwfifo
2 parents 418501e + 9b17d55 commit 8a9f44b

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

src/portable/raspberrypi/rp2040/dcd_rp2040.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,13 +505,15 @@ bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t *buffer, uint16_t to
505505
return true;
506506
}
507507

508+
#if CFG_TUD_EDPT_DEDICATED_HWFIFO
508509
bool dcd_edpt_xfer_fifo(uint8_t rhport, uint8_t ep_addr, tu_fifo_t *ff, uint16_t total_bytes, bool is_isr) {
509510
(void)rhport;
510511
(void)is_isr;
511512
hw_endpoint_t *ep = hw_endpoint_get_by_addr(ep_addr);
512513
hw_endpoint_xfer_start(ep, NULL, ff, total_bytes);
513514
return true;
514515
}
516+
#endif
515517

516518
void dcd_edpt_stall(uint8_t rhport, uint8_t ep_addr) {
517519
(void)rhport;

src/portable/raspberrypi/rp2040/rp2040_usb.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ static void unaligned_memcpy(uint8_t *dst, const uint8_t *src, size_t n) {
5353
}
5454
}
5555

56+
#if CFG_TUD_EDPT_DEDICATED_HWFIFO
5657
void tu_hwfifo_write(volatile void *hwfifo, const uint8_t *src, uint16_t len, const tu_hwfifo_access_t *access_mode) {
5758
(void)access_mode;
5859
unaligned_memcpy((uint8_t *)(uintptr_t)hwfifo, src, len);
@@ -62,6 +63,7 @@ void tu_hwfifo_read(const volatile void *hwfifo, uint8_t *dest, uint16_t len, co
6263
(void)access_mode;
6364
unaligned_memcpy(dest, (const uint8_t *)(uintptr_t)hwfifo, len);
6465
}
66+
#endif
6567

6668
void rp2usb_init(void) {
6769
// Reset usb controller
@@ -138,10 +140,13 @@ static uint32_t __tusb_irq_path_func(prepare_ep_buffer)(struct hw_endpoint *ep,
138140
if (buflen) {
139141
// Copy data from user buffer/fifo to hw buffer
140142
uint8_t *hw_buf = ep->hw_data_buf + buf_id * 64;
143+
#if CFG_TUD_EDPT_DEDICATED_HWFIFO
141144
if (ep->is_xfer_fifo) {
142145
// not in sram, may mess up timing with E15 workaround
143146
tu_hwfifo_write_from_fifo(hw_buf, ep->user_fifo, buflen, NULL);
144-
} else {
147+
} else
148+
#endif
149+
{
145150
unaligned_memcpy(hw_buf, ep->user_buf, buflen);
146151
ep->user_buf += buflen;
147152
}
@@ -227,6 +232,7 @@ void __tusb_irq_path_func(hw_endpoint_start_next_buffer)(struct hw_endpoint* ep)
227232
}
228233

229234
void hw_endpoint_xfer_start(struct hw_endpoint *ep, uint8_t *buffer, tu_fifo_t *ff, uint16_t total_len) {
235+
(void) ff;
230236
hw_endpoint_lock_update(ep, 1);
231237

232238
if (ep->active) {
@@ -240,10 +246,13 @@ void hw_endpoint_xfer_start(struct hw_endpoint *ep, uint8_t *buffer, tu_fifo_t *
240246
ep->xferred_len = 0;
241247
ep->active = true;
242248

249+
#if CFG_TUD_EDPT_DEDICATED_HWFIFO
243250
if (ff != NULL) {
244251
ep->user_fifo = ff;
245252
ep->is_xfer_fifo = true;
246-
} else {
253+
} else
254+
#endif
255+
{
247256
ep->user_buf = buffer;
248257
ep->is_xfer_fifo = false;
249258
}
@@ -284,10 +293,13 @@ static uint16_t __tusb_irq_path_func(sync_ep_buffer)(hw_endpoint_t *ep, io_rw_32
284293
assert(buf_ctrl & USB_BUF_CTRL_FULL);
285294

286295
uint8_t *hw_buf = ep->hw_data_buf + buf_id * 64;
296+
#if CFG_TUD_EDPT_DEDICATED_HWFIFO
287297
if (ep->is_xfer_fifo) {
288298
// not in sram, may mess up timing with E15 workaround
289299
tu_hwfifo_read_to_fifo(hw_buf, ep->user_fifo, xferred_bytes, NULL);
290-
} else {
300+
} else
301+
#endif
302+
{
291303
unaligned_memcpy(ep->user_buf, hw_buf, xferred_bytes);
292304
ep->user_buf += xferred_bytes;
293305
}

src/tusb_option.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@
381381
#endif
382382

383383
#if (CFG_TUSB_MCU == OPT_MCU_RP2040) && !CFG_TUD_RPI_PIO_USB
384-
#define CFG_TUD_EDPT_DEDICATED_HWFIFO 1
384+
#define CFG_TUD_EDPT_DEDICATED_HWFIFO 0
385385
#define CFG_TUSB_FIFO_HWFIFO_DATA_STRIDE 1
386386
#define CFG_TUSB_FIFO_HWFIFO_ADDR_STRIDE 1
387387
#define CFG_TUSB_FIFO_HWFIFO_CUSTOM_WRITE

0 commit comments

Comments
 (0)