Skip to content

Commit

Permalink
hw/mcu/nordic: FIX GPIO HAL for non secure code
Browse files Browse the repository at this point in the history
Code was using NRF_GPIOTE0 instead of NRF_GPIOTE which
maps to NRF_GPIOTE1 for non secure code

Signed-off-by: Jerzy Kasenberg <[email protected]>
  • Loading branch information
kasjer committed Nov 20, 2024
1 parent eb0ffcd commit ee8b7a0
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions hw/mcu/nordic/nrf_common/src/hal_gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ hal_gpio_irq_handler(void)
os_trace_isr_enter();

#if MYNEWT_VAL(MCU_GPIO_USE_PORT_EVENT)
nrf_gpiote_event_clear(NRF_GPIOTE0, NRF_GPIOTE_EVENT_PORT);
nrf_gpiote_event_clear(NRF_GPIOTE, NRF_GPIOTE_EVENT_PORT);
#endif

for (i = 0; i < HAL_GPIO_MAX_IRQ; i++) {
Expand Down Expand Up @@ -226,9 +226,9 @@ hal_gpio_irq_handler(void)
hal_gpio_irqs[i].func(hal_gpio_irqs[i].arg);
}
#else
if (nrf_gpiote_event_check(NRF_GPIOTE0, nrf_gpiote_in_event_get(i)) &&
nrf_gpiote_int_enable_check(NRF_GPIOTE0, 1 << i)) {
nrf_gpiote_event_clear(NRF_GPIOTE0, nrf_gpiote_in_event_get(i));
if (nrf_gpiote_event_check(NRF_GPIOTE, nrf_gpiote_in_event_get(i)) &&
nrf_gpiote_int_enable_check(NRF_GPIOTE, 1 << i)) {
nrf_gpiote_event_clear(NRF_GPIOTE, nrf_gpiote_in_event_get(i));
if (hal_gpio_irqs[i].func) {
hal_gpio_irqs[i].func(hal_gpio_irqs[i].arg);
}
Expand All @@ -254,8 +254,8 @@ hal_gpio_irq_setup(void)
irq_setup = 1;

#if MYNEWT_VAL(MCU_GPIO_USE_PORT_EVENT)
nrf_gpiote_int_disable(NRF_GPIOTE0, GPIOTE_INTENCLR_PORT_Msk);
nrf_gpiote_event_clear(NRF_GPIOTE0, NRF_GPIOTE_EVENT_PORT);
nrf_gpiote_int_disable(NRF_GPIOTE, GPIOTE_INTENCLR_PORT_Msk);
nrf_gpiote_event_clear(NRF_GPIOTE, NRF_GPIOTE_EVENT_PORT);
#endif
}
}
Expand Down Expand Up @@ -293,7 +293,7 @@ hal_gpio_get_gpiote_num(int pin)
#else
for (i = 0; i < HAL_GPIO_MAX_IRQ; i++) {
if (hal_gpio_irqs[i].func &&
(nrf_gpiote_event_pin_get(NRF_GPIOTE0, i) == pin)) {
(nrf_gpiote_event_pin_get(NRF_GPIOTE, i) == pin)) {
return i;
}
}
Expand Down Expand Up @@ -355,17 +355,17 @@ hal_gpio_irq_init(int pin, hal_gpio_irq_handler_t handler, void *arg,
nrf_gpiote_event_configure(NRF_GPIOTE0, i, pin, GPIOTE_CONFIG_POLARITY_LoToHi);
break;
case HAL_GPIO_TRIG_FALLING:
nrf_gpiote_event_configure(NRF_GPIOTE0, i, pin, GPIOTE_CONFIG_POLARITY_HiToLo);
nrf_gpiote_event_configure(NRF_GPIOTE, i, pin, GPIOTE_CONFIG_POLARITY_HiToLo);
break;
case HAL_GPIO_TRIG_BOTH:
nrf_gpiote_event_configure(NRF_GPIOTE0, i, pin, GPIOTE_CONFIG_POLARITY_Toggle);
nrf_gpiote_event_configure(NRF_GPIOTE, i, pin, GPIOTE_CONFIG_POLARITY_Toggle);
break;
default:
__HAL_ENABLE_INTERRUPTS(sr);
return -1;
}

nrf_gpiote_event_enable(NRF_GPIOTE0, i);
nrf_gpiote_event_enable(NRF_GPIOTE, i);
#endif

hal_gpio_irqs[i].func = handler;
Expand Down Expand Up @@ -402,8 +402,8 @@ hal_gpio_irq_release(int pin)
#if MYNEWT_VAL(MCU_GPIO_USE_PORT_EVENT)
hal_gpio_irqs[i].sense_trig = NRF_GPIO_PIN_NOSENSE;
#else
nrf_gpiote_te_default(NRF_GPIOTE0, i);
nrf_gpiote_event_clear(NRF_GPIOTE0, nrf_gpiote_in_event_get(i));
nrf_gpiote_te_default(NRF_GPIOTE, i);
nrf_gpiote_event_clear(NRF_GPIOTE, nrf_gpiote_in_event_get(i));
#endif

hal_gpio_irqs[i].arg = NULL;
Expand Down Expand Up @@ -443,10 +443,10 @@ hal_gpio_irq_enable(int pin)
nrf_gpio_cfg_sense_set(pin, GPIO_PIN_CNF_SENSE_High);
}

nrf_gpiote_int_enable(NRF_GPIOTE0, GPIOTE_INTENSET_PORT_Msk);
nrf_gpiote_int_enable(NRF_GPIOTE, GPIOTE_INTENSET_PORT_Msk);
#else
nrf_gpiote_event_clear(NRF_GPIOTE0, nrf_gpiote_in_event_get(i));
nrf_gpiote_int_enable(NRF_GPIOTE0, 1 << i);
nrf_gpiote_event_clear(NRF_GPIOTE, nrf_gpiote_in_event_get(i));
nrf_gpiote_int_enable(NRF_GPIOTE, 1 << i);
#endif

__HAL_ENABLE_INTERRUPTS(sr);
Expand Down Expand Up @@ -483,10 +483,10 @@ hal_gpio_irq_disable(int pin)
}

if (!sense_enabled) {
nrf_gpiote_int_disable(NRF_GPIOTE0, GPIOTE_INTENSET_PORT_Msk);
nrf_gpiote_int_disable(NRF_GPIOTE, GPIOTE_INTENSET_PORT_Msk);
}
#else
nrf_gpiote_int_disable(NRF_GPIOTE0, 1 << i);
nrf_gpiote_int_disable(NRF_GPIOTE, 1 << i);
#endif
__HAL_ENABLE_INTERRUPTS(sr);
}

0 comments on commit ee8b7a0

Please sign in to comment.