Skip to content

Commit 315dd0f

Browse files
Adam Wojasinskifabiobaltieri
authored andcommitted
drivers: spi: spi_nrfx_spim: Add CPOL handling on SCK pin
Pin state after SPIM deinitialization is based on pinctrl configuration. On the other hand, CPOL is set during runtime. With the introduction of the power-optimized SPIM driver, it disables the peripheral instance once the transfer is completed. As a result, the GPIO takes control over the SCK pin and drives it based on pinctrl configuration which causes an invalid SCK state when the transaction is configured with CPOL (Clock Polarity). To address this issue, a patch was introduced to the SPIM driver. Now, when a SPIM instance is configured with CPOL, the driver is setting in the runtime the correct state of the SCK pin. Signed-off-by: Adam Wojasinski <adam.wojasinski@nordicsemi.no>
1 parent b40c052 commit 315dd0f

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/spi/spi_nrfx_spim.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,9 @@ static int configure(const struct device *dev,
181181
config.mode = get_nrf_spim_mode(spi_cfg->operation);
182182
config.bit_order = get_nrf_spim_bit_order(spi_cfg->operation);
183183

184+
nrfy_gpio_pin_write(nrfy_spim_sck_pin_get(dev_config->spim.p_reg),
185+
spi_cfg->operation & SPI_MODE_CPOL ? 1 : 0);
186+
184187
if (dev_data->initialized) {
185188
nrfx_spim_uninit(&dev_config->spim);
186189
dev_data->initialized = false;

0 commit comments

Comments
 (0)