You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Changed to use compiler intrinsics
* Significantly reduced comments near memory barrier usage, as per request
* Updating `attachInterrupt()` loops to more closely match requested style
tmp |= newRegBits; // for existing channel, effectively updates only the polarity
138
+
channelMap[ch] =pin; // harmless for existing channel
139
+
callbacksInt[ch] =callback; // caller might be updating this for existing channel
140
+
callbackDeferred[ch] =deferred; // caller might be updating this for existing channel
141
+
NRF_GPIOTE->CONFIG[ch] =tmp;
142
+
143
+
// For a new channel, additionally ensure no old events existed, and enable the interrupt
144
+
if (newChannel) {
145
+
// Why the memory barrier and NOPs?
146
+
// See page 4 at https://web.archive.org/web/20190823222657/http://infocenter.arm.com/help/topic/com.arm.doc.dai0321a/DAI0321A_programming_guide_memory_barriers_for_m_profile.pdf
147
+
// and recall the AHB runs at 16MHz, so may take 4 cycles before peripheral register is actually updated.
// Unfortunately, simply marking a variable as volatile is not enough to
177
-
// prevent GCC from reordering or combining memory accesses, without also
178
-
// having an explicit sequence point.
179
-
// See https://gcc.gnu.org/onlinedocs/gcc/Volatiles.html
180
-
//
181
-
// Here, ensure a sequence point by adding a memory barrier
182
-
// followed with four nops after having disabled the interrupt,
183
-
// to ensure the peripheral registers have been updated.
171
+
// Why the memory barrier and NOPs?
172
+
// See page 4 at https://web.archive.org/web/20190823222657/http://infocenter.arm.com/help/topic/com.arm.doc.dai0321a/DAI0321A_programming_guide_memory_barriers_for_m_profile.pdf
173
+
// and recall the AHB runs at 16MHz, so may take 4 cycles before peripheral register is actually updated.
0 commit comments