fix: data width must be set before enabling SPI (#5279)
Co-authored-by: raphaelcoeffic <1050031+raphaelcoeffic@users.noreply.github.com>
This commit is contained in:
co-authored by
raphaelcoeffic
parent
d0791fa0c2
commit
170bdebcc4
@@ -41,9 +41,8 @@ void ads79xx_init(const stm32_spi_adc_t* adc)
|
|||||||
{
|
{
|
||||||
const auto* spi = &adc->spi;
|
const auto* spi = &adc->spi;
|
||||||
|
|
||||||
stm32_spi_init(spi);
|
stm32_spi_init(spi, LL_SPI_DATAWIDTH_16BIT);
|
||||||
stm32_spi_set_max_baudrate(spi, ADS79XX_MAX_FREQ);
|
stm32_spi_set_max_baudrate(spi, ADS79XX_MAX_FREQ);
|
||||||
LL_SPI_SetDataWidth(spi->SPIx, LL_SPI_DATAWIDTH_16BIT);
|
|
||||||
|
|
||||||
stm32_spi_unselect(spi);
|
stm32_spi_unselect(spi);
|
||||||
delay_01us(1);
|
delay_01us(1);
|
||||||
|
|||||||
@@ -247,7 +247,7 @@ static sd_init_fsm_state_t _init_sd_fsm_step(const stm32_spi_t* spi,
|
|||||||
switch (state) {
|
switch (state) {
|
||||||
case SD_INIT_START:
|
case SD_INIT_START:
|
||||||
TRACE("SD_INIT_START");
|
TRACE("SD_INIT_START");
|
||||||
stm32_spi_init(spi);
|
stm32_spi_init(spi, LL_SPI_DATAWIDTH_8BIT);
|
||||||
stm32_spi_set_max_baudrate(spi, SD_SPI_CLK_400K);
|
stm32_spi_set_max_baudrate(spi, SD_SPI_CLK_400K);
|
||||||
return SD_INIT_SPI_POWER_SEQ;
|
return SD_INIT_SPI_POWER_SEQ;
|
||||||
|
|
||||||
|
|||||||
@@ -247,7 +247,7 @@ void flashSpiSync()
|
|||||||
|
|
||||||
bool flashSpiInit(void)
|
bool flashSpiInit(void)
|
||||||
{
|
{
|
||||||
stm32_spi_init(&_flash_spi);
|
stm32_spi_init(&_flash_spi, LL_SPI_DATAWIDTH_8BIT);
|
||||||
delay_ms(1);
|
delay_ms(1);
|
||||||
flashSpiSync();
|
flashSpiSync();
|
||||||
|
|
||||||
|
|||||||
@@ -164,7 +164,7 @@ static void _config_dma_streams(const stm32_spi_t* spi)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void stm32_spi_init(const stm32_spi_t* spi)
|
void stm32_spi_init(const stm32_spi_t* spi, uint32_t data_width)
|
||||||
{
|
{
|
||||||
_init_gpios(spi);
|
_init_gpios(spi);
|
||||||
|
|
||||||
@@ -178,6 +178,7 @@ void stm32_spi_init(const stm32_spi_t* spi)
|
|||||||
spiInit.TransferDirection = LL_SPI_FULL_DUPLEX;
|
spiInit.TransferDirection = LL_SPI_FULL_DUPLEX;
|
||||||
spiInit.Mode = LL_SPI_MODE_MASTER;
|
spiInit.Mode = LL_SPI_MODE_MASTER;
|
||||||
spiInit.NSS = LL_SPI_NSS_SOFT;
|
spiInit.NSS = LL_SPI_NSS_SOFT;
|
||||||
|
spiInit.DataWidth = data_width;
|
||||||
|
|
||||||
LL_SPI_Init(SPIx, &spiInit);
|
LL_SPI_Init(SPIx, &spiInit);
|
||||||
LL_SPI_Enable(SPIx);
|
LL_SPI_Enable(SPIx);
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ struct stm32_spi_t {
|
|||||||
|
|
||||||
void stm32_spi_enable_clock(SPI_TypeDef *SPIx);
|
void stm32_spi_enable_clock(SPI_TypeDef *SPIx);
|
||||||
|
|
||||||
void stm32_spi_init(const stm32_spi_t* spi);
|
void stm32_spi_init(const stm32_spi_t* spi, uint32_t data_width);
|
||||||
void stm32_spi_deinit(const stm32_spi_t* spi);
|
void stm32_spi_deinit(const stm32_spi_t* spi);
|
||||||
|
|
||||||
void stm32_spi_select(const stm32_spi_t* spi);
|
void stm32_spi_select(const stm32_spi_t* spi);
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ void audioSpiInit(void)
|
|||||||
pinInit.Mode = LL_GPIO_MODE_INPUT;
|
pinInit.Mode = LL_GPIO_MODE_INPUT;
|
||||||
LL_GPIO_Init(AUDIO_DREQ_GPIO, &pinInit);
|
LL_GPIO_Init(AUDIO_DREQ_GPIO, &pinInit);
|
||||||
|
|
||||||
stm32_spi_init(&_audio_spi);
|
stm32_spi_init(&_audio_spi, LL_SPI_DATAWIDTH_8BIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void audioWaitReady()
|
void audioWaitReady()
|
||||||
|
|||||||
Reference in New Issue
Block a user