Skip to content

Commit

Permalink
modules: hal_nordic: nrfx: update API version to 3.2.0
Browse files Browse the repository at this point in the history
Updated API version enables multi-instance GPIOTE driver.
Additionally obsolete symbol that was used to specify
API version in the past was removed.
Affected drivers have been adjusted and appropriate changes
in affected files have been made.

Signed-off-by: Jakub Zymelka <[email protected]>
  • Loading branch information
jaz1-nordic authored and nika-nordic committed Jan 8, 2024
1 parent 96f4746 commit aecd53a
Show file tree
Hide file tree
Showing 15 changed files with 270 additions and 167 deletions.
4 changes: 2 additions & 2 deletions drivers/adc/adc_nrfx_saadc.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ static void adc_context_update_buffer_pointer(struct adc_context *ctx,
if (!repeat) {
nrf_saadc_buffer_pointer_set(
NRF_SAADC,
nrf_saadc_buffer_pointer_get(NRF_SAADC) +
(uint16_t *)nrf_saadc_buffer_pointer_get(NRF_SAADC) +
nrf_saadc_amount_get(NRF_SAADC));
}
}
Expand Down Expand Up @@ -256,7 +256,7 @@ static int check_buffer_size(const struct adc_sequence *sequence,
{
size_t needed_buffer_size;

needed_buffer_size = active_channels * sizeof(nrf_saadc_value_t);
needed_buffer_size = active_channels * sizeof(uint16_t);
if (sequence->options) {
needed_buffer_size *= (1 + sequence->options->extra_samplings);
}
Expand Down
22 changes: 18 additions & 4 deletions drivers/display/display_nrf_led_matrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <zephyr/drivers/display.h>
#include <zephyr/devicetree.h>
#include <zephyr/dt-bindings/gpio/gpio.h>
#include <soc.h>
#include <hal/nrf_timer.h>
#ifdef PWM_PRESENT
#include <hal/nrf_pwm.h>
Expand Down Expand Up @@ -89,6 +90,8 @@ struct display_drv_config {
NRF_TIMER_Type *timer;
#if USE_PWM
NRF_PWM_Type *pwm;
#else
nrfx_gpiote_t gpiote;
#endif
uint8_t rows[ROW_COUNT];
uint8_t cols[COL_COUNT];
Expand Down Expand Up @@ -324,7 +327,7 @@ static void prepare_pixel_pulse(const struct device *dev,

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

Expand Down Expand Up @@ -354,7 +357,7 @@ static void timer_irq_handler(void *arg)
}
#else
for (int i = 0; i < GROUP_SIZE; ++i) {
NRF_GPIOTE->CONFIG[dev_data->gpiote_ch[i]] = 0;
dev_config->gpiote.p_reg->CONFIG[dev_data->gpiote_ch[i]] = 0;
}
#endif

Expand Down Expand Up @@ -450,7 +453,7 @@ static int instance_init(const struct device *dev)
return -ENOMEM;
}

err = nrfx_gpiote_channel_alloc(gpiote_ch);
err = nrfx_gpiote_channel_alloc(&dev_config->gpiote, gpiote_ch);
if (err != NRFX_SUCCESS) {
LOG_ERR("Failed to allocate GPIOTE channel.");
/* Do not bother with freeing resources allocated
Expand All @@ -463,7 +466,7 @@ static int instance_init(const struct device *dev)
nrf_ppi_channel_endpoint_setup(NRF_PPI, ppi_ch,
nrf_timer_event_address_get(dev_config->timer,
nrf_timer_compare_event_get(1 + i)),
nrf_gpiote_event_address_get(NRF_GPIOTE,
nrf_gpiote_event_address_get(dev_config->gpiote.p_reg,
nrf_gpiote_out_task_get(*gpiote_ch)));
nrf_ppi_channel_enable(NRF_PPI, ppi_ch);
}
Expand Down Expand Up @@ -514,6 +517,14 @@ static struct display_drv_data instance_data = {
.blanking = true,
};

#if !USE_PWM
#define CHECK_GPIOTE_INST(node_id, prop, idx) \
BUILD_ASSERT(NRF_DT_GPIOTE_INST_BY_IDX(node_id, prop, idx) == \
NRF_DT_GPIOTE_INST_BY_IDX(node_id, prop, 0), \
"All column GPIOs must use the same GPIOTE instance");
DT_FOREACH_PROP_ELEM(MATRIX_NODE, col_gpios, CHECK_GPIOTE_INST)
#endif

#define GET_PIN_INFO(node_id, pha, idx) \
(DT_GPIO_PIN_BY_IDX(node_id, pha, idx) | \
(DT_PROP_BY_PHANDLE_IDX(node_id, pha, idx, port) << 5) | \
Expand All @@ -530,6 +541,9 @@ static const struct display_drv_config instance_config = {
.timer = (NRF_TIMER_Type *)DT_REG_ADDR(TIMER_NODE),
#if USE_PWM
.pwm = (NRF_PWM_Type *)DT_REG_ADDR(PWM_NODE),
#else
.gpiote = NRFX_GPIOTE_INSTANCE(
NRF_DT_GPIOTE_INST_BY_IDX(MATRIX_NODE, col_gpios, 0)),
#endif
.rows = { DT_FOREACH_PROP_ELEM(MATRIX_NODE, row_gpios, GET_PIN_INFO) },
.cols = { DT_FOREACH_PROP_ELEM(MATRIX_NODE, col_gpios, GET_PIN_INFO) },
Expand Down
7 changes: 6 additions & 1 deletion drivers/gpio/Kconfig.nrfx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ menuconfig GPIO_NRFX
bool "nRF GPIO driver"
default y
depends on DT_HAS_NORDIC_NRF_GPIO_ENABLED
select NRFX_GPIOTE
select NRFX_GPIOTE0 if HAS_HW_NRF_GPIOTE0
select NRFX_GPIOTE1 if HAS_HW_NRF_GPIOTE1
select NRFX_GPIOTE20 if HAS_HW_NRF_GPIOTE20
select NRFX_GPIOTE30 if HAS_HW_NRF_GPIOTE30
select NRFX_GPIOTE130 if HAS_HW_NRF_GPIOTE130
select NRFX_GPIOTE131 if HAS_HW_NRF_GPIOTE131
help
Enable GPIO driver for nRF line of MCUs.

Expand Down
Loading

0 comments on commit aecd53a

Please sign in to comment.