summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkkitayam <[email protected]>2021-07-31 12:20:19 +0900
committerkkitayam <[email protected]>2021-07-31 12:20:19 +0900
commit45e55a8ea05d1101626addb74c9a2059030f6ff2 (patch)
tree0a81b945f41c512f34a811793266b8f00b09d8bb
parentff20e4d6bcffc5d66666050c57719031fa2820e8 (diff)
fix: D0FIFOSEL setting was incorrectly when big-endian is selected.
In pipe_xfer_in(), the endianness setting of D0FIFOSEL was lacking due to refactoring. And add type cast operation to avoid warnings by CCRX.
-rw-r--r--src/portable/renesas/usba/dcd_usba.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/portable/renesas/usba/dcd_usba.c b/src/portable/renesas/usba/dcd_usba.c
index 09622d894..739861413 100644
--- a/src/portable/renesas/usba/dcd_usba.c
+++ b/src/portable/renesas/usba/dcd_usba.c
@@ -313,9 +313,9 @@ static bool pipe0_xfer_in(void)
void *buf = pipe->buf;
if (len) {
if (pipe->ff) {
- pipe_read_write_packet_ff((tu_fifo_t*)buf, &USB0.CFIFO.WORD, len, TUSB_DIR_IN);
+ pipe_read_write_packet_ff((tu_fifo_t*)buf, (volatile void*)&USB0.CFIFO.WORD, len, TUSB_DIR_IN);
} else {
- pipe_write_packet(buf, &USB0.CFIFO.WORD, len);
+ pipe_write_packet(buf, (volatile void*)&USB0.CFIFO.WORD, len);
pipe->buf = (uint8_t*)buf + len;
}
}
@@ -335,9 +335,9 @@ static bool pipe0_xfer_out(void)
void *buf = pipe->buf;
if (len) {
if (pipe->ff) {
- pipe_read_write_packet_ff((tu_fifo_t*)buf, &USB0.CFIFO.WORD, len, TUSB_DIR_OUT);
+ pipe_read_write_packet_ff((tu_fifo_t*)buf, (volatile void*)&USB0.CFIFO.WORD, len, TUSB_DIR_OUT);
} else {
- pipe_read_packet(buf, &USB0.CFIFO.WORD, len);
+ pipe_read_packet(buf, (volatile void*)&USB0.CFIFO.WORD, len);
pipe->buf = (uint8_t*)buf + len;
}
}
@@ -360,16 +360,16 @@ static bool pipe_xfer_in(unsigned num)
return true;
}
- USB0.D0FIFOSEL.WORD = num | USB_FIFOSEL_MBW_16;
+ USB0.D0FIFOSEL.WORD = num | USB_FIFOSEL_MBW_16 | (TU_BYTE_ORDER == TU_BIG_ENDIAN ? USB_FIFOSEL_BIGEND : 0);
const unsigned mps = edpt_max_packet_size(num);
pipe_wait_for_ready(num);
const unsigned len = TU_MIN(rem, mps);
void *buf = pipe->buf;
if (len) {
if (pipe->ff) {
- pipe_read_write_packet_ff((tu_fifo_t*)buf, &USB0.D0FIFO.WORD, len, TUSB_DIR_IN);
+ pipe_read_write_packet_ff((tu_fifo_t*)buf, (volatile void*)&USB0.D0FIFO.WORD, len, TUSB_DIR_IN);
} else {
- pipe_write_packet(buf, &USB0.D0FIFO.WORD, len);
+ pipe_write_packet(buf, (volatile void*)&USB0.D0FIFO.WORD, len);
pipe->buf = (uint8_t*)buf + len;
}
}
@@ -393,9 +393,9 @@ static bool pipe_xfer_out(unsigned num)
void *buf = pipe->buf;
if (len) {
if (pipe->ff) {
- pipe_read_write_packet_ff((tu_fifo_t*)buf, &USB0.D0FIFO.WORD, len, TUSB_DIR_OUT);
+ pipe_read_write_packet_ff((tu_fifo_t*)buf, (volatile void*)&USB0.D0FIFO.WORD, len, TUSB_DIR_OUT);
} else {
- pipe_read_packet(buf, &USB0.D0FIFO.WORD, len);
+ pipe_read_packet(buf, (volatile void*)&USB0.D0FIFO.WORD, len);
pipe->buf = (uint8_t*)buf + len;
}
}
@@ -488,6 +488,7 @@ static bool process_pipe_xfer(int buffer_type, uint8_t ep_addr, void* buffer, ui
pipe_wait_for_ready(num);
USB0.D0FIFOCTR.WORD = USB_FIFOCTR_BVAL;
USB0.D0FIFOSEL.WORD = 0;
+ while (USB0.D0FIFOSEL.BIT.CURPIPE) ; /* if CURPIPE bits changes, check written value */
}
} else {
volatile reg_pipetre_t *pt = get_pipetre(num);