1515#include <zephyr/drivers/gpio.h>
1616#include <soc.h>
1717#include <nrfx_gpiote.h>
18+ #include <gpiote_nrfx.h>
1819#include <helpers/nrfx_gppi.h>
1920#include "conn_time_sync.h"
2021
21- #define GPIOTE_INST NRF_DT_GPIOTE_INST(DT_ALIAS(led1), gpios)
22- #define GPIOTE_NODE DT_NODELABEL(_CONCAT(gpiote, GPIOTE_INST))
22+ #define GPIOTE_NODE NRF_DT_GPIOTE_NODE(DT_ALIAS(led1), gpios)
2323#define LED_PIN NRF_DT_GPIOS_TO_PSEL(DT_ALIAS(led1), gpios)
2424
25- BUILD_ASSERT (IS_ENABLED (_CONCAT (CONFIG_ , _CONCAT (NRFX_GPIOTE , GPIOTE_INST ))),
26- "NRFX_GPIOTE" STRINGIFY (GPIOTE_INST ) " must be enabled in Kconfig" );
27-
28- static const nrfx_gpiote_t gpiote = NRFX_GPIOTE_INSTANCE (GPIOTE_INST );
2925static struct gpio_dt_spec led = GPIO_DT_SPEC_GET_OR (DT_ALIAS (led1 ), gpios , {0 });
3026
3127static uint8_t previous_led_value ;
@@ -35,6 +31,7 @@ int timed_led_toggle_init(void)
3531 int err ;
3632 nrfx_gppi_handle_t ppi_led_toggle ;
3733 uint8_t gpiote_chan_led_toggle ;
34+ nrfx_gpiote_t * gpiote = & GPIOTE_NRFX_INST_BY_NODE (GPIOTE_NODE );
3835
3936 const nrfx_gpiote_output_config_t gpiote_output_cfg = NRFX_GPIOTE_DEFAULT_OUTPUT_CONFIG ;
4037
@@ -45,7 +42,7 @@ int timed_led_toggle_init(void)
4542 return err ;
4643 }
4744
48- if (nrfx_gpiote_channel_alloc (& gpiote , & gpiote_chan_led_toggle ) != NRFX_SUCCESS ) {
45+ if (nrfx_gpiote_channel_alloc (gpiote , & gpiote_chan_led_toggle ) != 0 ) {
4946 printk ("Failed allocating GPIOTE chan for setting led\n" );
5047 return - ENOMEM ;
5148 }
@@ -57,8 +54,8 @@ int timed_led_toggle_init(void)
5754 NRF_GPIOTE_INITIAL_VALUE_HIGH : NRF_GPIOTE_INITIAL_VALUE_LOW ,
5855 };
5956
60- if (nrfx_gpiote_output_configure (& gpiote , LED_PIN , & gpiote_output_cfg ,
61- & task_cfg_led_toggle ) != NRFX_SUCCESS ) {
57+ if (nrfx_gpiote_output_configure (gpiote , LED_PIN , & gpiote_output_cfg ,
58+ & task_cfg_led_toggle ) != 0 ) {
6259 printk ("Failed configuring GPIOTE chan for toggling led\n" );
6360 return - ENOMEM ;
6461 }
@@ -72,7 +69,7 @@ int timed_led_toggle_init(void)
7269 }
7370
7471 nrfx_gppi_conn_enable (ppi_led_toggle );
75- nrfx_gpiote_out_task_enable (& gpiote , LED_PIN );
72+ nrfx_gpiote_out_task_enable (gpiote , LED_PIN );
7673
7774 return 0 ;
7875}
0 commit comments