Skip to content

Commit

Permalink
Better fix to ensure no adjacent register write opcodes to optimize o…
Browse files Browse the repository at this point in the history
…ut on esp32
  • Loading branch information
Daniel Garcia committed Jan 20, 2019
1 parent db26028 commit 5618f23
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions fastspi_bitbang.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,23 @@ class AVRSoftwareSPIOutput {
if(b & (1 << BIT)) {
FastPin<DATA_PIN>::hi();
#ifdef ESP32
FastPin<CLOCK_PIN>::lo(); // kick a different register, block premature optimizations?
#endif
// try to ensure we never have adjacent write opcodes to the same register
FastPin<CLOCK_PIN>::lo();
FastPin<CLOCK_PIN>::hi(); CLOCK_HI_DELAY;
FastPin<CLOCK_PIN>::toggle(); CLOCK_LO_DELAY;
#else
FastPin<CLOCK_PIN>::hi(); CLOCK_HI_DELAY;
FastPin<CLOCK_PIN>::lo(); CLOCK_LO_DELAY;
#endif
} else {
FastPin<DATA_PIN>::lo();
FastPin<CLOCK_PIN>::hi(); CLOCK_HI_DELAY;
#ifdef ESP32
// try to ensure we never have adjacent write opcodes to the same register
FastPin<CLOCK_PIN>::toggle(); CLOCK_HI_DELAY;
#else
FastPin<CLOCK_PIN>::lo(); CLOCK_LO_DELAY;
#endif
}
//sei();
}
Expand Down

0 comments on commit 5618f23

Please sign in to comment.