Permalink
Browse files

Pull the SPI race condition fix over to the teensy 3.6 spi code as we…

…ll. Fixes #419 for teensy 3.6 as well
  • Loading branch information...
focalintent committed Aug 16, 2017
1 parent 06521a4 commit 6f445905267b0b1c4d1fd9f2a8ee6cb0ce6e968b
Showing with 13 additions and 7 deletions.
  1. +13 −7 platforms/arm/k66/fastspi_arm_k66.h
@@ -285,13 +285,19 @@ class ARMHardwareSPIOutput {
static void waitFully() __attribute__((always_inline)) {
// Wait for the last byte to get shifted into the register
cli();
while( (SPIX.SR & 0xF000) > 0) {
// reset the TCF flag
SPIX.SR |= SPI_SR_TCF;
}
sei();
bool empty = false;
do {
cli();
if ((SPIX.SR & 0xF000) > 0) {
// reset the TCF flag
SPIX.SR |= SPI_SR_TCF;
} else {
empty = true;
}
sei();
} while (!empty);
// wait for the TCF flag to get set
while (!(SPIX.SR & SPI_SR_TCF));
SPIX.SR |= (SPI_SR_TCF | SPI_SR_EOQF);

0 comments on commit 6f44590

Please sign in to comment.