1414#include <hal/nrf_gpio.h>
1515#include <hal/nrf_rtc.h>
1616#include <hal/nrf_timer.h>
17+ #include <gpiote_nrfx.h>
1718
1819#include <zephyr/logging/log.h>
1920
@@ -62,7 +63,7 @@ struct pwm_config {
6263 NRF_RTC_Type * rtc ;
6364 NRF_TIMER_Type * timer ;
6465 };
65- nrfx_gpiote_t gpiote [PWM_0_MAP_SIZE ];
66+ nrfx_gpiote_t * gpiote [PWM_0_MAP_SIZE ];
6667 uint8_t psel_ch [PWM_0_MAP_SIZE ];
6768 uint8_t initially_inverted ;
6869 uint8_t map_size ;
@@ -163,7 +164,7 @@ static int pwm_nrf_sw_set_cycles(const struct device *dev, uint32_t channel,
163164 }
164165 }
165166
166- gpiote = config -> gpiote [channel ]. p_reg ;
167+ gpiote = config -> gpiote [channel ]-> p_reg ;
167168 psel_ch = config -> psel_ch [channel ];
168169 gpiote_ch = data -> gpiote_ch [channel ];
169170 ppi_chs = data -> ppi_ch [channel ];
@@ -351,7 +352,7 @@ static int pwm_nrf_sw_init(const struct device *dev)
351352 NRF_RTC_Type * rtc = pwm_config_rtc (config );
352353
353354 for (uint32_t i = 0 ; i < config -> map_size ; i ++ ) {
354- nrfx_err_t err ;
355+ int err ;
355356
356357 /* Allocate resources. */
357358 for (uint32_t j = 0 ; j < PPI_PER_CH ; j ++ ) {
@@ -365,14 +366,14 @@ static int pwm_nrf_sw_init(const struct device *dev)
365366 }
366367 }
367368
368- err = nrfx_gpiote_channel_alloc (& config -> gpiote [i ],
369+ err = nrfx_gpiote_channel_alloc (config -> gpiote [i ],
369370 & data -> gpiote_ch [i ]);
370- if (err != NRFX_SUCCESS ) {
371+ if (err < 0 ) {
371372 /* Do not free allocated resource. It is a fatal condition,
372373 * system requires reconfiguration.
373374 */
374375 LOG_ERR ("Failed to allocate GPIOTE channel" );
375- return - ENOMEM ;
376+ return err ;
376377 }
377378
378379 /* Set initial state of the output pins. */
@@ -410,7 +411,7 @@ static int pwm_nrf_sw_init(const struct device *dev)
410411 ? BIT(_idx) : 0) |
411412
412413#define GPIOTE_AND_COMMA (_node_id , _prop , _idx ) \
413- NRFX_GPIOTE_INSTANCE(NRF_DT_GPIOTE_INST_BY_IDX (_node_id, _prop, _idx)),
414+ &GPIOTE_NRFX_INST_BY_NODE(NRF_DT_GPIOTE_NODE_BY_IDX (_node_id, _prop, _idx))
414415
415416static const struct pwm_config pwm_nrf_sw_0_config = {
416417 COND_CODE_1 (USE_RTC , (.rtc ), (.timer )) = GENERATOR_ADDR ,
0 commit comments