|
13 | 13 | #include <hal/nrf_pwm.h> |
14 | 14 | #endif |
15 | 15 | #include <nrfx_gpiote.h> |
| 16 | +#include <gpiote_nrfx.h> |
16 | 17 | #include <helpers/nrfx_gppi.h> |
17 | | -#include <nrf_peripherals.h> |
18 | 18 | #include <zephyr/logging/log.h> |
19 | 19 | #include <zephyr/irq.h> |
20 | 20 | LOG_MODULE_REGISTER(nrf_led_matrix, CONFIG_DISPLAY_LOG_LEVEL); |
@@ -89,7 +89,7 @@ struct display_drv_config { |
89 | 89 | #if USE_PWM |
90 | 90 | NRF_PWM_Type *pwm; |
91 | 91 | #else |
92 | | - nrfx_gpiote_t gpiote; |
| 92 | + nrfx_gpiote_t *gpiote; |
93 | 93 | #endif |
94 | 94 | uint8_t rows[ROW_COUNT]; |
95 | 95 | uint8_t cols[COL_COUNT]; |
@@ -325,7 +325,7 @@ static void prepare_pixel_pulse(const struct device *dev, |
325 | 325 |
|
326 | 326 | /* First timer channel is used for timing the period of pulses. */ |
327 | 327 | 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; |
329 | 329 | #endif /* USE_PWM */ |
330 | 330 | } |
331 | 331 |
|
@@ -355,7 +355,7 @@ static void timer_irq_handler(void *arg) |
355 | 355 | } |
356 | 356 | #else |
357 | 357 | 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; |
359 | 359 | } |
360 | 360 | #endif |
361 | 361 |
|
@@ -435,27 +435,26 @@ static int instance_init(const struct device *dev) |
435 | 435 | nrf_pwm_loop_set(dev_config->pwm, 0); |
436 | 436 | nrf_pwm_shorts_set(dev_config->pwm, NRF_PWM_SHORT_SEQEND0_STOP_MASK); |
437 | 437 | #else |
438 | | - nrfx_err_t err; |
439 | 438 | nrfx_gppi_handle_t ppi_handle; |
440 | 439 | int rv; |
441 | 440 |
|
442 | 441 | for (int i = 0; i < GROUP_SIZE; ++i) { |
443 | 442 | uint8_t *gpiote_ch = &dev_data->gpiote_ch[i]; |
444 | 443 |
|
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) { |
447 | 446 | LOG_ERR("Failed to allocate GPIOTE channel."); |
448 | 447 | /* Do not bother with freeing resources allocated |
449 | 448 | * so far. The application needs to be reconfigured |
450 | 449 | * anyway. |
451 | 450 | */ |
452 | | - return -ENOMEM; |
| 451 | + return rv; |
453 | 452 | } |
454 | 453 |
|
455 | 454 | rv = nrfx_gppi_conn_alloc( |
456 | 455 | nrf_timer_event_address_get(dev_config->timer, |
457 | 456 | 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, |
459 | 458 | nrf_gpiote_out_task_get(*gpiote_ch)), |
460 | 459 | &ppi_handle); |
461 | 460 | if (rv < 0) { |
@@ -535,13 +534,14 @@ DT_FOREACH_PROP_ELEM(MATRIX_NODE, col_gpios, CHECK_GPIOTE_INST) |
535 | 534 | [GET_DT_ROW_IDX(idx) * COL_COUNT + \ |
536 | 535 | GET_DT_COL_IDX(idx)] = idx, |
537 | 536 |
|
| 537 | +//NRFX_GPIOTE_INSTANCE(NRF_DT_GPIOTE_INST_BY_IDX(MATRIX_NODE, col_gpios, 0)), |
| 538 | + |
538 | 539 | static const struct display_drv_config instance_config = { |
539 | 540 | .timer = (NRF_TIMER_Type *)DT_REG_ADDR(TIMER_NODE), |
540 | 541 | #if USE_PWM |
541 | 542 | .pwm = (NRF_PWM_Type *)DT_REG_ADDR(PWM_NODE), |
542 | 543 | #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)), |
545 | 545 | #endif |
546 | 546 | .rows = { DT_FOREACH_PROP_ELEM(MATRIX_NODE, row_gpios, GET_PIN_INFO) }, |
547 | 547 | .cols = { DT_FOREACH_PROP_ELEM(MATRIX_NODE, col_gpios, GET_PIN_INFO) }, |
|
0 commit comments