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 ;
@@ -164,7 +165,7 @@ static int pwm_nrf_sw_set_cycles(const struct device *dev, uint32_t channel,
164165 }
165166 }
166167
167- gpiote = config -> gpiote [channel ]. p_reg ;
168+ gpiote = config -> gpiote [channel ]-> p_reg ;
168169 psel_ch = config -> psel_ch [channel ];
169170 gpiote_ch = data -> gpiote_ch [channel ];
170171 ppi_chs = data -> ppi_h [channel ];
@@ -349,7 +350,6 @@ static int pwm_nrf_sw_init(const struct device *dev)
349350 uint32_t src_d = nrfx_gppi_domain_id_get ((USE_RTC ? (uint32_t )rtc : (uint32_t )timer ));
350351
351352 for (uint32_t i = 0 ; i < config -> map_size ; i ++ ) {
352- nrfx_err_t err ;
353353 uint32_t dst_d = nrfx_gppi_domain_id_get ((uint32_t )config -> gpiote [i ].p_reg );
354354 int rv ;
355355
@@ -373,14 +373,13 @@ static int pwm_nrf_sw_init(const struct device *dev)
373373 }
374374 nrfx_gppi_channels_disable (src_d , data -> ppi_ch_mask [i ]);
375375
376- err = nrfx_gpiote_channel_alloc (& config -> gpiote [i ],
377- & data -> gpiote_ch [i ]);
378- if (err != NRFX_SUCCESS ) {
376+ rv = nrfx_gpiote_channel_alloc (config -> gpiote [i ], & data -> gpiote_ch [i ]);
377+ if (rv < 0 ) {
379378 /* Do not free allocated resource. It is a fatal condition,
380379 * system requires reconfiguration.
381380 */
382381 LOG_ERR ("Failed to allocate GPIOTE channel" );
383- return - ENOMEM ;
382+ return rv ;
384383 }
385384
386385 /* Set initial state of the output pins. */
@@ -418,7 +417,7 @@ static int pwm_nrf_sw_init(const struct device *dev)
418417 ? BIT(_idx) : 0) |
419418
420419#define GPIOTE_AND_COMMA (_node_id , _prop , _idx ) \
421- NRFX_GPIOTE_INSTANCE(NRF_DT_GPIOTE_INST_BY_IDX (_node_id, _prop, _idx)),
420+ &GPIOTE_NRFX_INST_BY_NODE(NRF_DT_GPIOTE_NODE_BY_IDX (_node_id, _prop, _idx))
422421
423422static const struct pwm_config pwm_nrf_sw_0_config = {
424423 COND_CODE_1 (USE_RTC , (.rtc ), (.timer )) = GENERATOR_ADDR ,
0 commit comments