diff options
author | Daniel Garcia <dgarcia@dgarcia.net> | 2019-01-20 04:17:18 +0300 |
---|---|---|
committer | Daniel Garcia <dgarcia@dgarcia.net> | 2019-01-20 04:17:18 +0300 |
commit | 5618f234a6c68b72413322f34d0f832e998b3ce0 (patch) | |
tree | e76c65b72528f455a289c8d15b885e6a6e73011e | |
parent | db26028f9173b27713d1ad524214d7ad47206828 (diff) |
Better fix to ensure no adjacent register write opcodes to optimize out on esp32
-rw-r--r-- | fastspi_bitbang.h | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/fastspi_bitbang.h b/fastspi_bitbang.h index dacdc237..d48e32bc 100644 --- a/fastspi_bitbang.h +++ b/fastspi_bitbang.h @@ -124,14 +124,23 @@ public: 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(); } |