Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions src/portable/renesas/rusb2/dcd_rusb2.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,17 +213,26 @@ static void pipe_write_packet_ff(rusb2_reg_t * rusb, tu_fifo_t *f, volatile void
tu_fifo_buffer_info_t info;
tu_fifo_get_read_info(f, &info);

uint16_t count = tu_min16(total_len, info.linear.len);
pipe_write_packet(rusb, info.linear.ptr, fifo, count);
uint16_t cnt_lin = tu_min16(total_len, info.linear.len);
uint16_t cnt_wrap = tu_min16(total_len - cnt_lin, info.wrapped.len);
uint16_t const cnt_written = cnt_lin + cnt_wrap;

uint16_t rem = total_len - count;
if (rem) {
rem = tu_min16(rem, info.wrapped.len);
pipe_write_packet(rusb, info.wrapped.ptr, fifo, rem);
count += rem;
}
// Ensure only the last write is odd if total_len is odd
if (cnt_wrap == 0) {
pipe_write_packet(rusb, info.linear.ptr, fifo, cnt_lin);
} else {
pipe_write_packet(rusb, info.linear.ptr, fifo, cnt_lin & ~1);

tu_fifo_advance_read_pointer(f, count);
if (cnt_lin & 1) {
uint8_t glue[2] = {info.linear.ptr[cnt_lin & ~1], info.wrapped.ptr[0]};
pipe_write_packet(rusb, glue, fifo, 2);
cnt_wrap--;
info.wrapped.ptr++;
}

pipe_write_packet(rusb, info.wrapped.ptr, fifo, cnt_wrap);
}
tu_fifo_advance_read_pointer(f, cnt_written);
}

// Read data sw fifo <-- hw fifo
Expand Down
2 changes: 1 addition & 1 deletion src/tusb_option.h
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@

//------------ RUSB2 --------------//
#if defined(TUP_USBIP_RUSB2)
#define CFG_TUD_EDPT_DEDICATED_HWFIFO 0 // need testing to enable
#define CFG_TUD_EDPT_DEDICATED_HWFIFO 1
#endif

//--------------------------------------------------------------------
Expand Down