From 18d0131032fe0e10dea9e106e1322096d93f5c15 Mon Sep 17 00:00:00 2001 From: Marcin Gasiorek Date: Thu, 19 Sep 2024 10:44:12 +0200 Subject: [PATCH] pal: spi: Move SPI bus speed setting to init function. Set SPI bus frequency in init function. Signed-off-by: Marcin Gasiorek --- subsys/sal/sid_pal/src/sid_pal_serial_bus_nrfx_spi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/subsys/sal/sid_pal/src/sid_pal_serial_bus_nrfx_spi.c b/subsys/sal/sid_pal/src/sid_pal_serial_bus_nrfx_spi.c index 875000ad4e..400481f0dd 100644 --- a/subsys/sal/sid_pal/src/sid_pal_serial_bus_nrfx_spi.c +++ b/subsys/sal/sid_pal/src/sid_pal_serial_bus_nrfx_spi.c @@ -18,6 +18,7 @@ LOG_MODULE_REGISTER(sid_nrfx_spi_bus, CONFIG_SPI_BUS_LOG_LEVEL); #define SPI_CS_PIN NRF_DT_GPIOS_TO_PSEL(DT_NODELABEL(nrfx_spi_cs), gpios) static const nrfx_spi_t spi = NRFX_SPI_INSTANCE(SPI_INSTANCE_ID); +static nrf_spi_frequency_t speed_hz; static sid_error_t bus_serial_spi_xfer(const struct sid_pal_serial_bus_iface *iface, const struct sid_pal_serial_bus_client *client, uint8_t *tx, @@ -43,7 +44,7 @@ static sid_error_t bus_serial_spi_xfer(const struct sid_pal_serial_bus_iface *if nrfx_spi_config_t config = NRFX_SPI_DEFAULT_CONFIG(SPI_SCK_PIN, SPI_MOSI_PIN, SPI_MISO_PIN, SPI_CS_PIN); - config.frequency = get_radio_cfg()->bus_selector.speed_hz; + config.frequency = speed_hz; LOG_DBG("%s(%p, %p, %d)", __func__, (void *)tx, (void *)rx, xfer_size); @@ -84,6 +85,7 @@ sid_error_t sid_pal_serial_bus_nordic_spi_create(const struct sid_pal_serial_bus } *iface = &bus_ops; + speed_hz = get_radio_cfg()->bus_selector.speed_hz; return SID_ERROR_NONE; }