Permalink
Browse files

Better fix to ensure no adjacent register write opcodes to optimize o…

…ut on esp32
  • Loading branch information...
Daniel Garcia
Daniel Garcia committed Jan 20, 2019
1 parent db26028 commit 5618f234a6c68b72413322f34d0f832e998b3ce0
Showing with 11 additions and 2 deletions.
  1. +11 −2 fastspi_bitbang.h
@@ -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();
}

0 comments on commit 5618f23

Please sign in to comment.