HotFix for sdcard driver on F7 when using DMA for TX (#5595)

* HotFix for sdcard driver on F7 when using DMA for TX

* Fix typo
This commit is contained in:
conkerkh 2018-04-02 04:36:13 +02:00 committed by Michael Keller
parent a9136e2ba0
commit db81dbe103
1 changed files with 13 additions and 3 deletions

View File

@ -366,6 +366,14 @@ static sdcardReceiveBlockStatus_e sdcard_receiveDataBlock(uint8_t *buffer, int c
static bool sdcard_sendDataBlockFinish(void)
{
#ifdef USE_HAL_DRIVER
// Drain anything left in the Rx FIFO (we didn't read it during the write)
//This is necessary here as when using msc there is timing issue
while (LL_SPI_IsActiveFlag_RXNE(sdcard.instance)) {
sdcard.instance->DR;
}
#endif
// Send a dummy CRC
spiTransferByte(sdcard.instance, 0x00);
spiTransferByte(sdcard.instance, 0x00);
@ -763,8 +771,10 @@ bool sdcard_poll(void)
sendComplete = false;
#if defined(USE_HAL_DRIVER)
// TODO : need to verify this
if (sdcard.useDMAForTx && LL_DMA_IsEnabledStream(sdcard.dma->dma, sdcard.dma->stream)) {
if (sdcard.useDMAForTx && DMA_GET_FLAG_STATUS(sdcard.dma, DMA_IT_TCIF)) {
//Clear both flags after transfer
DMA_CLEAR_FLAG(sdcard.dma, DMA_IT_TCIF);
DMA_CLEAR_FLAG(sdcard.dma, DMA_IT_HTIF);
// Drain anything left in the Rx FIFO (we didn't read it during the write)
while (LL_SPI_IsActiveFlag_RXNE(sdcard.instance)) {
sdcard.instance->DR;