Hi,
i have nrf52 and sdk13.1.
Is this possible. I get NRF_ERROR_INVALID_STATE
.
Hi,
i have nrf52 and sdk13.1.
Is this possible. I get NRF_ERROR_INVALID_STATE
.
how anyone is supposed to answer that question without you even bothering to post the line of code you allegedly get NRF_ERROR_INVALID_STATE on I don't know. Can you write a more complete question perhaps?
I have a similar case, so pardon me for hijacking the topic. I have pin 0.08 that I wanted to have as a dual-purpose pin - first a pushbutton, then a LED. Both are tied to the pin, in parallel, then grounded
My init goes smoothly:
#define GPIO_1 8
err_code = nrf_drv_gpiote_init();
APP_ERROR_CHECK(err_code);
nrf_drv_gpiote_in_config_t configInButton = GPIOTE_CONFIG_IN_SENSE_HITOLO(true);
err_code = nrf_drv_gpiote_in_init(BUTTON_0, &configInButton, my_gpio_handler);
APP_ERROR_CHECK(err_code);
and my_gpio_handler works well. Once I'm done with the button I call a second method that does the following:
nrf_drv_gpiote_out_config_t configOut = GPIOTE_CONFIG_OUT_SIMPLE(0);
err_code = nrf_drv_gpiote_out_init(GPIO_1, &configOut);
APP_ERROR_CHECK(err_code);
That last APP_ERROR_CHECK throws an NRF_ERROR_INVALID_STATE.
Did I skip a step somewhere?
This is an answer to stealth's comment above, and will hopefully help with schef's original question as well.
In the infocenter we can find that the NRF_ERROR_INVALID_STATE
is returned if the driver is not initialized or the pin is already used. In your case the error is returned because the pin is used.
When calling the function
err_code = nrf_drv_gpiote_in_init(BUTTON_0, &configInButton, my_gpio_handler);
the pin will be used, and therefore you should try to uninitialize the pin using the nrf_drv_gpiote_in_uninit() before you can initialize it again as an output pin.
Kind regards
Joakim
Much obliged!