Skip to content

Commit

Permalink
Flush FTDI buffer to avoid 16ms latency timeout and speed up the SPI
Browse files Browse the repository at this point in the history
Based on the original work of @denis2342 at
BusPirate#169
- I have reviewed this commit and believe it is OK.
Also improved the ifdef, works fine both for v3 and v4.

Co-authored-by: denis2342 <[email protected]>
Signed-off-by: Mike Banon <[email protected]>
  • Loading branch information
mikebdp2 and denis2342 committed Feb 11, 2024
1 parent 455d3b6 commit 8febbb9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Firmware/base.c
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,9 @@ void user_serial_initialise(void) {
U1STA = 0x0400;

IFS0bits.U1RXIF = NO;

/* FTDI CTS setup. */
FTDI_CTS_DIR = OUTPUT;
}

bool user_serial_transmit_done(void) { return U1STAbits.TRMT; }
Expand Down
4 changes: 4 additions & 0 deletions Firmware/spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -942,6 +942,10 @@ void spi_enter_binary_io(void) {
REPORT_IO_FAILURE();
break;
}
#ifdef BUSPIRATEV3
/* avoid the 16ms FTDI buffer send latency */
FTDI_CTS = !FTDI_CTS;
#endif /* BUSPIRATEV3 */
}
}

Expand Down

0 comments on commit 8febbb9

Please sign in to comment.