This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to enable a TASK for a zephyr GPIO pin?

How do we enable a PPI TASK for a GPIO output pin configured using zephyr GPIO driver API? ex: gpio_pin_configure_dt(&ex_pin, GPIO_OUTPUT);

If I just call nrfx_gpiote_out_task_enable(EX_PIN), I get the following runtime assertion error: 

I believe we need a way to inform the gpio driver to allocate a GPIOTE channel even though the pin is an output pin. Currently, the nrfx implementation for the zephyr GPIO API only allocate GPIOTE channels for input pins.

Can you please provide some guidance on how are supposed to do this? Thank you.

Parents
  • Hi,

    Initialize the output pin with nrfx_gpiote_out_init before enabling the GPIOTE output pin task:

    #define OUTPUT_PIN	DT_GPIO_PIN(DT_ALIAS(led0), gpios)
    
    nrfx_gpiote_out_config_t const out_config = {
    	.action = NRF_GPIOTE_POLARITY_TOGGLE,
    	.init_state = 1,
    	.task_pin = true,
    };
    
    
    err = nrfx_gpiote_out_init(OUTPUT_PIN, &out_config);
    if (err != NRFX_SUCCESS) {
    	LOG_ERR("nrfx_gpiote_out_init error: %08x", err);
    	return;
    }
    
    nrfx_gpiote_out_task_enable(OUTPUT_PIN);

    Best regards,

    Marte

Reply
  • Hi,

    Initialize the output pin with nrfx_gpiote_out_init before enabling the GPIOTE output pin task:

    #define OUTPUT_PIN	DT_GPIO_PIN(DT_ALIAS(led0), gpios)
    
    nrfx_gpiote_out_config_t const out_config = {
    	.action = NRF_GPIOTE_POLARITY_TOGGLE,
    	.init_state = 1,
    	.task_pin = true,
    };
    
    
    err = nrfx_gpiote_out_init(OUTPUT_PIN, &out_config);
    if (err != NRFX_SUCCESS) {
    	LOG_ERR("nrfx_gpiote_out_init error: %08x", err);
    	return;
    }
    
    nrfx_gpiote_out_task_enable(OUTPUT_PIN);

    Best regards,

    Marte

Children
  • Thank you, Marte. This is what I do today to get it to work.

    Is there a way or a plan to get it to work using zephyr GPIO API and not nrfx API? Right now, I can use zephyr GPIO API for all use cases except this case. Thanks!

  • Hi,

    You must use the nrfx GPIOTE driver for this. I am not aware of any plans to add this to the Zephyr GPIO driver as of now, but if you have roadmap questions you can contact your regional sales manager.

    Best regards,

    Marte

Related