aboutsummaryrefslogtreecommitdiffstats
path: root/os
diff options
context:
space:
mode:
Diffstat (limited to 'os')
-rw-r--r--os/hal/include/i2s.h2
-rw-r--r--os/hal/ports/STM32/LLD/SPIv1/i2s_lld.c18
2 files changed, 14 insertions, 6 deletions
diff --git a/os/hal/include/i2s.h b/os/hal/include/i2s.h
index c7143daec..711ec3b5c 100644
--- a/os/hal/include/i2s.h
+++ b/os/hal/include/i2s.h
@@ -163,7 +163,7 @@ extern "C" {
void i2sStart(I2SDriver *i2sp, const I2SConfig *config);
void i2sStop(I2SDriver *i2sp);
void i2sStartExchange(I2SDriver *i2sp);
- void i2sStopTransfer(I2SDriver *i2sp);
+ void i2sStopExchange(I2SDriver *i2sp);
#ifdef __cplusplus
}
#endif
diff --git a/os/hal/ports/STM32/LLD/SPIv1/i2s_lld.c b/os/hal/ports/STM32/LLD/SPIv1/i2s_lld.c
index e95ac27ba..26f6bb5fc 100644
--- a/os/hal/ports/STM32/LLD/SPIv1/i2s_lld.c
+++ b/os/hal/ports/STM32/LLD/SPIv1/i2s_lld.c
@@ -419,14 +419,22 @@ void i2s_lld_start_exchange(I2SDriver *i2sp) {
*/
void i2s_lld_stop_exchange(I2SDriver *i2sp) {
- /* Stop DMAs.*/
- if (NULL != i2sp->dmatx)
+ /* Stop TX DMA, if enabled.*/
+ if (NULL != i2sp->dmatx) {
dmaStreamDisable(i2sp->dmatx);
- if (NULL != i2sp->dmarx)
- dmaStreamDisable(i2sp->dmarx);
- /* Stop transfer.*/
+ /* From the RM: To switch off the I2S, by clearing I2SE, it is mandatory
+ to wait for TXE = 1 and BSY = 0.*/
+ while ((i2sp->spi->SR & (SPI_SR_TXE | SPI_SR_BSY)) != SPI_SR_TXE)
+ ;
+ }
+
+ /* Stop SPI/I2S peripheral.*/
i2sp->spi->I2SCFGR &= ~SPI_I2SCFGR_I2SE;
+
+ /* Stop RX DMA, if enabled.*/
+ if (NULL != i2sp->dmarx)
+ dmaStreamDisable(i2sp->dmarx);
}
#endif /* HAL_USE_I2S */