Hi,
I need to use the GPIOTE with interrupt function with nrfx (https://github.com/NordicSemiconductor/nrfx/) directly on the nrf54l15 DK board.
So I created a build system based on Makefile and ARM-GCC, the core Makefile (smtc-hal-mcu-nrf54l15.mk) is also attached.
I created a simple example as attached code shows. This code loosely based on NCS v2.9.1/zephyr/samples/boards/nordic/nrfx/src/main.c.
However, that sample uses PPI to trigger another Pin, which doesn't satisfy my requirements because I need to attach the handle to an IRQ Pin directly.
So in my code, when I press Button 0, the related handler function is called, which controls the LED3 on or off.
However, this code works all right under NCS v2.9.1, but doesn’t work on my build system.
I don’t know what steps are missing causing this difference, so I’d like to get some help. Thanks in advance.
The config is also attached to show that the related CONFIG for GPIOTE are enabled.
#include <stdio.h> #include <nrfx_gpiote.h> #include <nrfx_log.h> #define LED3 NRF_GPIO_PIN_MAP( 1, 14 ) #define BTN0 NRF_GPIO_PIN_MAP( 1, 13 ) #define GPIOTE_INSTANCE_IDX 20 nrfx_gpiote_t const pio_instance = NRFX_GPIOTE_INSTANCE( GPIOTE_INSTANCE_IDX ); static void button_handler(nrfx_gpiote_pin_t pin, nrfx_gpiote_trigger_t trigger, void *context) { static bool flag = true; printf("GPIO input event callback"); if(flag) { nrf_gpio_pin_set( LED3 ); flag = false; } else { nrf_gpio_pin_clear( LED3 ); flag = true; } } void test_gpiote( void ) { nrfx_err_t err; uint8_t in_channel; nrfy_gpio_cfg_output( LED3 ); nrf_gpio_pin_set( LED3 ); nrfx_gpiote_init( &pio_instance, NRFX_GPIOTE_DEFAULT_CONFIG_IRQ_PRIORITY ); err = nrfx_gpiote_channel_alloc(&pio_instance, &in_channel); if (err != NRFX_SUCCESS) { NRFX_LOG_ERROR("Failed to allocate in_channel, error: 0x%08X", err); return; } static const nrf_gpio_pin_pull_t pull_config = NRF_GPIO_PIN_PULLUP; nrfx_gpiote_trigger_config_t trigger_config = { .trigger = NRFX_GPIOTE_TRIGGER_HITOLO, .p_in_channel = &in_channel, }; static const nrfx_gpiote_handler_config_t handler_config = { .handler = button_handler, }; nrfx_gpiote_input_pin_config_t input_config = { .p_pull_config = &pull_config, .p_trigger_config = &trigger_config, .p_handler_config = &handler_config, }; err = nrfx_gpiote_input_configure(&pio_instance, BTN0, &input_config); if (err != NRFX_SUCCESS) { NRFX_LOG_ERROR("nrfx_gpiote_input_configure error: 0x%08X", err); return; } nrfx_gpiote_trigger_enable(&pio_instance, BTN0, true); } int main( void ) { test_gpiote( ); while( 1 ) { ; } }