File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -124,14 +124,23 @@ class AVRSoftwareSPIOutput {
124
124
if (b & (1 << BIT)) {
125
125
FastPin<DATA_PIN>::hi ();
126
126
#ifdef ESP32
127
- FastPin<CLOCK_PIN>::lo (); // kick a different register, block premature optimizations?
128
- #endif
127
+ // try to ensure we never have adjacent write opcodes to the same register
128
+ FastPin<CLOCK_PIN>::lo ();
129
+ FastPin<CLOCK_PIN>::hi (); CLOCK_HI_DELAY;
130
+ FastPin<CLOCK_PIN>::toggle (); CLOCK_LO_DELAY;
131
+ #else
129
132
FastPin<CLOCK_PIN>::hi (); CLOCK_HI_DELAY;
130
133
FastPin<CLOCK_PIN>::lo (); CLOCK_LO_DELAY;
134
+ #endif
131
135
} else {
132
136
FastPin<DATA_PIN>::lo ();
133
137
FastPin<CLOCK_PIN>::hi (); CLOCK_HI_DELAY;
138
+ #ifdef ESP32
139
+ // try to ensure we never have adjacent write opcodes to the same register
140
+ FastPin<CLOCK_PIN>::toggle (); CLOCK_HI_DELAY;
141
+ #else
134
142
FastPin<CLOCK_PIN>::lo (); CLOCK_LO_DELAY;
143
+ #endif
135
144
}
136
145
// sei();
137
146
}
You can’t perform that action at this time.
0 commit comments