drivers: spi: spi-bitbang: Fix CS glitch in transceive

spi_context_cs_configure_all() is currently called from
spi_bitbang_transceive(). This causes a glitch when combined with
SPI_HOLD_ON_CS is used.

Move the initialization to spi_bitbang_init which is what the other
SPI drivers seem to do.

Signed-off-by: Andreas Sandberg <andreas@sandberg.uk>
This commit is contained in:
Andreas Sandberg 2022-07-04 17:52:48 +01:00 committed by Carles Cufí
commit a05e8dcc5e

View file

@ -77,8 +77,6 @@ static int spi_bitbang_configure(const struct spi_bitbang_config *info,
data->ctx.config = config;
spi_context_cs_configure_all(&data->ctx);
return 0;
}
@ -235,6 +233,7 @@ static struct spi_driver_api spi_bitbang_api = {
int spi_bitbang_init(const struct device *dev)
{
const struct spi_bitbang_config *config = dev->config;
struct spi_bitbang_data *data = dev->data;
int rc;
if (!device_is_ready(config->clk_gpio.port)) {
@ -274,6 +273,12 @@ int spi_bitbang_init(const struct device *dev)
}
}
rc = spi_context_cs_configure_all(&data->ctx);
if (rc < 0) {
LOG_ERR("Failed to configure CS pins: %d", rc);
return rc;
}
return 0;
}