Skip to content

Commit 8e10cd4

Browse files
committed
[nrf fromlist] drivers: display: nrf_led_matrix: align to nrfx_gpiote with extracted cb
GPIOTE driver instances are no longer defined within nrfx. Upstream PR #: 98527 Signed-off-by: Nikodem Kastelik <[email protected]>
1 parent c8771cc commit 8e10cd4

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

drivers/display/display_nrf_led_matrix.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
#include <hal/nrf_pwm.h>
1414
#endif
1515
#include <nrfx_gpiote.h>
16+
#include <gpiote_nrfx.h>
1617
#ifdef PPI_PRESENT
1718
#include <nrfx_ppi.h>
1819
#endif
19-
#include <nrf_peripherals.h>
2020
#include <zephyr/logging/log.h>
2121
#include <zephyr/irq.h>
2222
LOG_MODULE_REGISTER(nrf_led_matrix, CONFIG_DISPLAY_LOG_LEVEL);
@@ -91,7 +91,7 @@ struct display_drv_config {
9191
#if USE_PWM
9292
NRF_PWM_Type *pwm;
9393
#else
94-
nrfx_gpiote_t gpiote;
94+
nrfx_gpiote_t *gpiote;
9595
#endif
9696
uint8_t rows[ROW_COUNT];
9797
uint8_t cols[COL_COUNT];
@@ -327,7 +327,7 @@ static void prepare_pixel_pulse(const struct device *dev,
327327

328328
/* First timer channel is used for timing the period of pulses. */
329329
nrf_timer_cc_set(dev_config->timer, 1 + channel_idx, pulse);
330-
dev_config->gpiote.p_reg->CONFIG[dev_data->gpiote_ch[channel_idx]] = gpiote_cfg;
330+
dev_config->gpiote->p_reg->CONFIG[dev_data->gpiote_ch[channel_idx]] = gpiote_cfg;
331331
#endif /* USE_PWM */
332332
}
333333

@@ -357,7 +357,7 @@ static void timer_irq_handler(void *arg)
357357
}
358358
#else
359359
for (int i = 0; i < GROUP_SIZE; ++i) {
360-
dev_config->gpiote.p_reg->CONFIG[dev_data->gpiote_ch[i]] = 0;
360+
dev_config->gpiote->p_reg->CONFIG[dev_data->gpiote_ch[i]] = 0;
361361
}
362362
#endif
363363

@@ -437,7 +437,7 @@ static int instance_init(const struct device *dev)
437437
nrf_pwm_loop_set(dev_config->pwm, 0);
438438
nrf_pwm_shorts_set(dev_config->pwm, NRF_PWM_SHORT_SEQEND0_STOP_MASK);
439439
#else
440-
nrfx_err_t err;
440+
int err;
441441
nrf_ppi_channel_t ppi_ch;
442442

443443
for (int i = 0; i < GROUP_SIZE; ++i) {
@@ -453,20 +453,20 @@ static int instance_init(const struct device *dev)
453453
return -ENOMEM;
454454
}
455455

456-
err = nrfx_gpiote_channel_alloc(&dev_config->gpiote, gpiote_ch);
457-
if (err != NRFX_SUCCESS) {
456+
err = nrfx_gpiote_channel_alloc(dev_config->gpiote, gpiote_ch);
457+
if (err < 0) {
458458
LOG_ERR("Failed to allocate GPIOTE channel.");
459459
/* Do not bother with freeing resources allocated
460460
* so far. The application needs to be reconfigured
461461
* anyway.
462462
*/
463-
return -ENOMEM;
463+
return err;
464464
}
465465

466466
nrf_ppi_channel_endpoint_setup(NRF_PPI, ppi_ch,
467467
nrf_timer_event_address_get(dev_config->timer,
468468
nrf_timer_compare_event_get(1 + i)),
469-
nrf_gpiote_event_address_get(dev_config->gpiote.p_reg,
469+
nrf_gpiote_event_address_get(dev_config->gpiote->p_reg,
470470
nrf_gpiote_out_task_get(*gpiote_ch)));
471471
nrf_ppi_channel_enable(NRF_PPI, ppi_ch);
472472
}
@@ -537,13 +537,14 @@ DT_FOREACH_PROP_ELEM(MATRIX_NODE, col_gpios, CHECK_GPIOTE_INST)
537537
[GET_DT_ROW_IDX(idx) * COL_COUNT + \
538538
GET_DT_COL_IDX(idx)] = idx,
539539

540+
//NRFX_GPIOTE_INSTANCE(NRF_DT_GPIOTE_INST_BY_IDX(MATRIX_NODE, col_gpios, 0)),
541+
540542
static const struct display_drv_config instance_config = {
541543
.timer = (NRF_TIMER_Type *)DT_REG_ADDR(TIMER_NODE),
542544
#if USE_PWM
543545
.pwm = (NRF_PWM_Type *)DT_REG_ADDR(PWM_NODE),
544546
#else
545-
.gpiote = NRFX_GPIOTE_INSTANCE(
546-
NRF_DT_GPIOTE_INST_BY_IDX(MATRIX_NODE, col_gpios, 0)),
547+
.gpiote = &GPIOTE_NRFX_INST_BY_NODE(NRF_DT_GPIOTE_NODE(MATRIX_NODE, col_gpios)),
547548
#endif
548549
.rows = { DT_FOREACH_PROP_ELEM(MATRIX_NODE, row_gpios, GET_PIN_INFO) },
549550
.cols = { DT_FOREACH_PROP_ELEM(MATRIX_NODE, col_gpios, GET_PIN_INFO) },

0 commit comments

Comments
 (0)