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
when programming the GPIOTE peripheral.
the memory barrier is still used once in the ISR,
to prevent spurious interrupts caused by delay
writing over the (16MHz) AHB bus.
tmp |= newRegBits; // for existing channel, effectively updates only the polarity
138
135
channelMap[ch] =pin; // harmless for existing channel
139
136
callbacksInt[ch] =callback; // caller might be updating this for existing channel
140
137
callbackDeferred[ch] =deferred; // caller might be updating this for existing channel
138
+
139
+
uint32_ttmp=NRF_GPIOTE->CONFIG[ch];
140
+
tmp &= oldRegMask;
141
+
tmp |= newRegBits; // for existing channel, effectively updates only the polarity
141
142
NRF_GPIOTE->CONFIG[ch] =tmp;
142
143
143
144
// For a new channel, additionally ensure no old events existed, and enable the interrupt
144
145
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.
// 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.
174
167
NRF_GPIOTE->INTENCLR= (1 << ch);
175
-
__DSB(); __NOP();__NOP();__NOP();__NOP();
176
168
NRF_GPIOTE->CONFIG[ch] =0;
177
-
__DSB(); __NOP();__NOP();__NOP();__NOP();
178
169
NRF_GPIOTE->EVENTS_IN[ch] =0; // clear any final events
0 commit comments