Skip to content

Commit 6f44590

Browse files
committed
Pull the SPI race condition fix over to the teensy 3.6 spi code as well. Fixes FastLED#419 for teensy 3.6 as well
1 parent 06521a4 commit 6f44590

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

platforms/arm/k66/fastspi_arm_k66.h

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -285,13 +285,19 @@ class ARMHardwareSPIOutput {
285285

286286
static void waitFully() __attribute__((always_inline)) {
287287
// Wait for the last byte to get shifted into the register
288-
cli();
289-
while( (SPIX.SR & 0xF000) > 0) {
290-
// reset the TCF flag
291-
SPIX.SR |= SPI_SR_TCF;
292-
}
293-
sei();
294-
288+
bool empty = false;
289+
290+
do {
291+
cli();
292+
if ((SPIX.SR & 0xF000) > 0) {
293+
// reset the TCF flag
294+
SPIX.SR |= SPI_SR_TCF;
295+
} else {
296+
empty = true;
297+
}
298+
sei();
299+
} while (!empty);
300+
295301
// wait for the TCF flag to get set
296302
while (!(SPIX.SR & SPI_SR_TCF));
297303
SPIX.SR |= (SPI_SR_TCF | SPI_SR_EOQF);

0 commit comments

Comments
 (0)