Hi,
I'm porting code from Simblee/Arduino to Laird's BL651/Nordic SDK (nRF52810, SDK 15.3, S112). (Simblee discontinued.) For accurate timing of a GPIO pin, I use TIMER1, TIMER2, GPIOTE and PPI. GPIOTE watches an input pin for transition LOTOHI and HITOLO. PPI is used to start TIMER2 (timer mode) on input pin transition LOTOHI, then stop TIMER2 on transition HITOLO. PPI is also used to increment (COUNT) TIMER1 (counter mode) each time TIMER2 overflows. GPIOTE triggers interrupt call on input pin transition LOTOHI where code captures TIMER1 and TIMER2 values and calculates time between LOTOHI and HITOLO transitions of input pin and sends to BLE Central.
Here's the current code that works well on Simblee:
As you can see, I access all peripherals directly rather than using TIMER, GPIOTE and PPI drivers. I read somewhere that it's better to use the peripheral drivers rather than direct manipulation (this is understandable). So I did so in porting to Nordic SDK (15.3 with SoftDevice S112. However, I've discovered that you cannot use the GPIOTE driver (routines like nrfx_gpiote_init(), etc.) to watch for more than one event per pin. I cannot use it to watch for both LoToHi and HiToLo. I could use toggle (NRF_GPIOTE_POLARITY_TOGGLE polarity), but would need to check transition in the interrupt routine to know which transition triggered the interrupt.
My questions are:
1) Is it critical to use the peripheral drivers rather than accessing peripherals directly?
2) Given the above limitation in GPIOTE, is it okay to manipulate GPIOTE directly?
The code that is working (using nRF52 dev kit) is below, but manipulates GPIOTE directly:
Thanks for any help!
Tim