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.
* Changed to use compiler intrinsics
* Significantly reduced comments near memory barrier usage, as per request
* Updating `attachInterrupt()` loops to more closely match requested style
* First loop should not be checking pinmap for -1.
* Second loop should ensure no pending event when
first allocating the GPIOTE channel.
* Second loop needs to update pinmap with pin when
allocated the GPIOTE channel.
Reduce the number of cycles spent in the GPIOTE ISR,
by reading common volatile registers across AHB only
once, and using a safer hack to prevent spurious ISR
firing when the last channel's event was cleared.
First, when looking for a channel, first loop through
all mapped channels to see if the GPIO was already mapped.
This prevents a single GPIO being configured for more than
one channel at a time.
Second, do not use a GPIOTE channel if the channel is
already in use (e.g., by a library, sketch, or other code
outside the Board Support Package).
Nordic SoftDevice needs to have control over lowest priority interrupts
for reliable, timing sensitive operation. If user code tries to use
such a low priority level, SoftDevice refuses to start.
One way to overcome this limitation is to start the SoftDevice before
attaching pin change interrupts, though in such a case, SD will
cap the effective priority of the user interrupt anyway and it is
a common mistake API users do. This change simply changes the priority
to 2, which is legal (for fast interrupt handlers anyway) under SoftDevice,
no matter if attached before of after SD start.