I'm trying to get acquainted with the NRFX_GPIOTE driver by writing a program to do the following:
initialize TIMER to generate three compare events:
- channel0 compare event triggers a set event on a gpio pin
- channel1 compare event triggers a clear event on the same gpio pin
- channel2 compare events reset the timer
...all done via the PPI, of course. And since the migration document recommends it, I'd like to use nrfx_ functions wherever possible.
My stumbling blocks:
- The led_blinking gpiote example in the nRF5_SDK_15.0.0 shows how to toggle a GPIO pin, but not how to set it using one PPI channel and clear it using another. Do you use the nrfx_gpiote_out_init() function for this? If so, do you initialize the same GPIO with two different configurations?
- It's not clear where I can use nrfx_ methods and where I should (or must) use nrf_drv_ methods.
- In the sketch that I've started, the linker complains that all the nrfx_xxx functions are undefined. What must I do to get them loaded?
A code example, updated for nrfx_ methods, would be super useful! Here's the framework I'm using for my main() function:
static const nrf_drv_timer_t m_timer = NRF_DRV_TIMER_INSTANCE(0); const int m_gpio_pin = 13; int main() { uint32_t err_code; err_code = NRF_LOG_INIT(NULL); APP_ERROR_CHECK(err_code); NRF_LOG_DEFAULT_BACKENDS_INIT(); err_code = nrf_pwr_mgmt_init(); APP_ERROR_CHECK(err_code); peripherals_init(); // ready, set... nfrx_timer_enable(&m_timer); // ... go! while(1) { nrf_pwr_mgmt_run(); NRF_LOG_FLUSH(); } }
I'd be happy to show what I've got for peripherals_init(), but chances are good that I'm overthinking it.