summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/tusb_fifo.c8
-rw-r--r--src/common/tusb_fifo.h10
2 files changed, 14 insertions, 4 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