Hello,
I base on migration guide:
My board is nrf52840.
I have strange problem with migration to new NRFX drivers fo GPIOTE. I did the following:
1. I deleted all legacy layers' defines in sdk_config.h,
2. I defined NRFX_GPIOTE_ENABLED
This is my code:
void init_gpiote() { if(not nrfx_gpiote_is_init()) { nrfx_gpiote_init(); } } void init_digital_simple_output(nrfx_gpiote_pin_t pin, nrfx_gpiote_port_t port) { nrfx_gpiote_out_config_t config_out = NRFX_GPIOTE_CONFIG_OUT_SIMPLE(true); nrfx_err_t err_code = nrfx_gpiote_out_init(NRF_GPIO_PIN_MAP(port, pin), &config_out); if(err_code != NRFX_SUCCESS) { // Error during initialization: NRFX_ERROR_INVALID_STATE or NRFX_ERROR_NO_MEM } } void blink_led(nrfx_gpiote_pin_t pin, nrfx_gpiote_port_t port) { for(uint8_t i = 0; i < 4; ++i) { nrfx_gpiote_out_set(NRF_GPIO_PIN_MAP(port, pin)); for(int i = 0; i < 1000000; ++i); nrfx_gpiote_out_clear(NRF_GPIO_PIN_MAP(port, pin)); for(int i = 0; i < 1000000; ++i); } } void in_event_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action) { nrfx_gpiote_out_toggle(NRF_GPIO_PIN_MAP(0, 13)); } void init_digital_input(nrfx_gpiote_pin_t pin, nrfx_gpiote_port_t port) { if(not nrfx_gpiote_in_is_set(NRF_GPIO_PIN_MAP(port, pin))) { nrfx_gpiote_in_config_t config_in = NRFX_GPIOTE_CONFIG_IN_SENSE_LOTOHI(true); config_in.pull = NRF_GPIO_PIN_PULLUP; nrfx_err_t err_code = nrfx_gpiote_in_init(NRF_GPIO_PIN_MAP(port, pin), &config_in, in_event_handler); if(err_code != NRFX_SUCCESS) { // Error during initialization: NRFX_ERROR_INVALID_STATE or NRFX_ERROR_NO_MEM } nrfx_gpiote_in_event_enable(NRF_GPIO_PIN_MAP(port, pin), true); blink_led(13, 0); } }
And here the main loop:
void main(void) { static const nrfx_gpiote_port_t PORT_LED1 = 0; static const nrfx_gpiote_pin_t PIN_LED1 = 13; static const nrfx_gpiote_port_t PORT_BUTTON1 = 0; static const nrfx_gpiote_pin_t PIN_BUTTON1 = 3; init_gpiote(); init_digital_simple_output(PIN_LED1, PORT_LED1); init_digital_input(PIN_BUTTON1, PORT_BUTTON1); while(true) { } }
When I debug the code I see that everything behave as expected - all peripherals are initiated properly. Unfortunately, I am not able to detect any event on IN pin. I have been struggling for a long time with this simple migration but still without result. Did I forget about some detail?
I can add that when I did not delete legacy defines in sdk_config.h it also did not work at all. It works only when I use nrf_drv* drivers but I really want to use new drivers as they will be supported in the future, thus it is important to me to use the new ones. I would really appreciate if someone can help me.
Best regards,
Pawel