This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

gpio_nrfx_port_toggle_bits() not task / interrupt save

Dear Support

I think gpio_nrfx_port_toggle_bits() is not task / interrupt save.

When between nrf_gpio_port_out_read() and nrf_gpio_port_out_write() a task switch or interrupt happend and in an the same port is modified nrf_gpio_port_out_write() restore the previous value and the modification is lost.

static int gpio_nrfx_port_toggle_bits(const struct device *port,
uint32_t mask)
{
NRF_GPIO_Type *reg = get_port_cfg(port)->port;
uint32_t value;

value = nrf_gpio_port_out_read(reg);
nrf_gpio_port_out_write(reg, value ^ mask);

return 0;
}

Can you confirm this?

RetoFelix

Related