Skip to content

Commit 4a9dc96

Browse files
nika-nordicjaz1-nordic
authored andcommitted
[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 dc84597 commit 4a9dc96

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

drivers/display/display_nrf_led_matrix.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
#include <hal/nrf_pwm.h>
1414
#endif
1515
#include <nrfx_gpiote.h>
16+
#include <gpiote_nrfx.h>
1617
#include <helpers/nrfx_gppi.h>
17-
#include <nrf_peripherals.h>
1818
#include <zephyr/logging/log.h>
1919
#include <zephyr/irq.h>
2020
LOG_MODULE_REGISTER(nrf_led_matrix, CONFIG_DISPLAY_LOG_LEVEL);
@@ -89,7 +89,7 @@ struct display_drv_config {
8989
#if USE_PWM
9090
NRF_PWM_Type *pwm;
9191
#else
92-
nrfx_gpiote_t gpiote;
92+
nrfx_gpiote_t *gpiote;
9393
#endif
9494
uint8_t rows[ROW_COUNT];
9595
uint8_t cols[COL_COUNT];
@@ -325,7 +325,7 @@ static void prepare_pixel_pulse(const struct device *dev,
325325

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

@@ -355,7 +355,7 @@ static void timer_irq_handler(void *arg)
355355
}
356356
#else
357357
for (int i = 0; i < GROUP_SIZE; ++i) {
358-
dev_config->gpiote.p_reg->CONFIG[dev_data->gpiote_ch[i]] = 0;
358+
dev_config->gpiote->p_reg->CONFIG[dev_data->gpiote_ch[i]] = 0;
359359
}
360360
#endif
361361

@@ -435,27 +435,26 @@ static int instance_init(const struct device *dev)
435435
nrf_pwm_loop_set(dev_config->pwm, 0);
436436
nrf_pwm_shorts_set(dev_config->pwm, NRF_PWM_SHORT_SEQEND0_STOP_MASK);
437437
#else
438-
nrfx_err_t err;
439438
nrfx_gppi_handle_t ppi_handle;
440439
int rv;
441440

442441
for (int i = 0; i < GROUP_SIZE; ++i) {
443442
uint8_t *gpiote_ch = &dev_data->gpiote_ch[i];
444443

445-
err = nrfx_gpiote_channel_alloc(&dev_config->gpiote, gpiote_ch);
446-
if (err != NRFX_SUCCESS) {
444+
rv = nrfx_gpiote_channel_alloc(dev_config->gpiote, gpiote_ch);
445+
if (rv != 0) {
447446
LOG_ERR("Failed to allocate GPIOTE channel.");
448447
/* Do not bother with freeing resources allocated
449448
* so far. The application needs to be reconfigured
450449
* anyway.
451450
*/
452-
return -ENOMEM;
451+
return rv;
453452
}
454453

455454
rv = nrfx_gppi_conn_alloc(
456455
nrf_timer_event_address_get(dev_config->timer,
457456
nrf_timer_compare_event_get(1 + i)),
458-
nrf_gpiote_event_address_get(dev_config->gpiote.p_reg,
457+
nrf_gpiote_event_address_get(dev_config->gpiote->p_reg,
459458
nrf_gpiote_out_task_get(*gpiote_ch)),
460459
&ppi_handle);
461460
if (rv < 0) {
@@ -535,13 +534,14 @@ DT_FOREACH_PROP_ELEM(MATRIX_NODE, col_gpios, CHECK_GPIOTE_INST)
535534
[GET_DT_ROW_IDX(idx) * COL_COUNT + \
536535
GET_DT_COL_IDX(idx)] = idx,
537536

537+
//NRFX_GPIOTE_INSTANCE(NRF_DT_GPIOTE_INST_BY_IDX(MATRIX_NODE, col_gpios, 0)),
538+
538539
static const struct display_drv_config instance_config = {
539540
.timer = (NRF_TIMER_Type *)DT_REG_ADDR(TIMER_NODE),
540541
#if USE_PWM
541542
.pwm = (NRF_PWM_Type *)DT_REG_ADDR(PWM_NODE),
542543
#else
543-
.gpiote = NRFX_GPIOTE_INSTANCE(
544-
NRF_DT_GPIOTE_INST_BY_IDX(MATRIX_NODE, col_gpios, 0)),
544+
.gpiote = &GPIOTE_NRFX_INST_BY_NODE(NRF_DT_GPIOTE_NODE(MATRIX_NODE, col_gpios)),
545545
#endif
546546
.rows = { DT_FOREACH_PROP_ELEM(MATRIX_NODE, row_gpios, GET_PIN_INFO) },
547547
.cols = { DT_FOREACH_PROP_ELEM(MATRIX_NODE, col_gpios, GET_PIN_INFO) },

0 commit comments

Comments
 (0)