-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Description
I found the issue causing #8252 (GPIO interrupt only called once on nRF52832).
The issue is accessing GPIOTE registers responsible for GPIO pin configuration (ie: gpiote->CONFIG[]) from multiple Zephyr drivers.
Nordic Zephyr drivers directly access these registers without checking if other drivers also access it. So they overwrite each other GPIO configurations.
In the case of #8252, it was the PWM driver that was overwriting the GPIO driver configurations. As @JoeHut mentioned, there are two other drivers that uses GPIO interrupts. And following which one was started first, the other one was not working (as soon as the PWM driver was doing stuff with gpiote->CONFIG[]).
At the moment, there are 3 drivers directly accessing gpiote->CONFIG[]:
- Nordic GPIO driver: https://github.com/zephyrproject-rtos/zephyr/blob/master/drivers/gpio/gpio_nrf5.c
- Nordic PWM drivers: https://github.com/zephyrproject-rtos/zephyr/blob/master/drivers/pwm/pwm_nrf5_sw.c
- Nordic Radio drivers (BLE):
NRF_GPIOTE->CONFIG[CONFIG_BT_CTLR_PA_LNA_GPIOTE_CHAN] =
Not sure if the new Nordic PWN driver https://github.com/zephyrproject-rtos/zephyr/blob/master/drivers/pwm/pwm_nrfx.c accesses GPIOTE through NRFX SDK.
I see two possibles fixes for this issue:
- either we introduce a Zephyr Nordic GPIOTE driver (that could live in
arch/arm/soc/nordic_nrf/) that manages all GPIOTE accesses (mainly GPIO pin configuration allocations). - or we only use NRFX SDK to access GPIOTE registers (I guess that will be the preferred solution as some Zephyr drivers are migrating to this API).
Note: This issue is already raised in GPIO driver: https://github.com/zephyrproject-rtos/zephyr/blob/master/drivers/gpio/gpio_nrf5.c#L68
@henrikbrixandersen Your pull-request #8628 would be affected