Hi
i am using nrf9160 based custom board with zephyr, and trying to build GPIOTE with interrupt for a button, and led finally connect with PPI
i have been trying for Blinky using GPIOTE like this:
/* * Copyright (c) 2016 Intel Corporation * * SPDX-License-Identifier: Apache-2.0 */ #include <zephyr.h> #include <nrfx_gpiote.h> #define LED_PIN NRF_GPIO_PIN_MAP(0,1) #define BT_PIN NRF_GPIO_PIN_MAP(0,27) /* The devicetree node identifier for the "led0" alias. */ #define LED1_NODE DT_ALIAS(led1) #if DT_NODE_HAS_STATUS(LED1_NODE, okay) #define LED1 DT_GPIO_LABEL(LED1_NODE, gpios) #define PIN DT_GPIO_PIN(LED1_NODE, gpios) #define FLAGS DT_GPIO_FLAGS(LED1_NODE, gpios) #endif void gpio_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action) { nrfx_gpiote_out_toggle(LED_PIN); k_sleep(K_MSEC(100)); //nothing } void gpio_inits(void) { nrfx_err_t err; ///* Connect GPIOTE_0 IRQ to nrfx_gpiote_irq_handler */ //IRQ_CONNECT(DT_IRQN(DT_NODELABEL(gpiote)), // DT_IRQ(DT_NODELABEL(gpiote), priority), // nrfx_isr, nrfx_gpiote_irq_handler, 0); //nrfx_gpiote_irq_handler(); if (!nrfx_gpiote_is_init()) { err = nrfx_gpiote_init(0); } nrfx_gpiote_out_config_t const out_config = { .init_state = NRF_GPIOTE_INITIAL_VALUE_HIGH, .action = NRF_GPIOTE_POLARITY_TOGGLE, .task_pin = true, }; err = nrfx_gpiote_out_init(PIN, &out_config); nrfx_gpiote_out_task_enable(PIN); //------------------------------------------------------------------------------------------------ nrfx_gpiote_in_config_t in_config = NRFX_GPIOTE_CONFIG_IN_SENSE_TOGGLE(false); in_config.pull = NRF_GPIO_PIN_PULLUP; err = nrfx_gpiote_in_init(BT_PIN, &in_config, gpio_handler); if (err != NRFX_SUCCESS) printk("DRDY_init error: %08x \n", err); nrfx_gpiote_in_event_enable(BT_PIN, true); } void main(void) { gpio_inits(); while (1) { nrf_gpio_pin_toggle(PIN); // k_sleep(K_MSEC(1000)); } }
prj.conf file:
CONFIG_GPIO=y CONFIG_GPIO_NRFX=y CONFIG_GPIO_NRF_P0=y CONFIG_NRFX_GPIOTE=y
after uploading, the code is not working, but when i change the initial status of LED pin in config, its changing the initial status, but still output is not working in while loop.
Please help me to understand my mistake,
please provide me a example project which is having GPIOTE with interrupt (if possible)
Best Regards
Rajender