From 18a64e261ff7dba522c592514f9baead1839a357 Mon Sep 17 00:00:00 2001 From: James Cotton Date: Thu, 2 Feb 2012 12:32:57 -0600 Subject: [PATCH] Going a bit overkill with this - deinit who SPI block between transactions. --- flight/PiOS/STM32F4xx/pios_spi.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/flight/PiOS/STM32F4xx/pios_spi.c b/flight/PiOS/STM32F4xx/pios_spi.c index 725485a6d..51906e268 100644 --- a/flight/PiOS/STM32F4xx/pios_spi.c +++ b/flight/PiOS/STM32F4xx/pios_spi.c @@ -395,7 +395,19 @@ static int32_t SPI_DMA_TransferBlock(uint32_t spi_id, const uint8_t *send_buffer while(DMA_GetCmdStatus(spi_dev->cfg->dma.tx.channel) == ENABLE); /* Disable the SPI peripheral */ + /* Initialize the SPI block */ + SPI_DeInit(spi_dev->cfg->regs); + SPI_Init(spi_dev->cfg->regs, (SPI_InitTypeDef*)&(spi_dev->cfg->init)); SPI_Cmd(spi_dev->cfg->regs, DISABLE); + /* Configure CRC calculation */ + if (spi_dev->cfg->use_crc) { + SPI_CalculateCRC(spi_dev->cfg->regs, ENABLE); + } else { + SPI_CalculateCRC(spi_dev->cfg->regs, DISABLE); + } + + /* Enable SPI interrupts to DMA */ + SPI_I2S_DMACmd(spi_dev->cfg->regs, SPI_I2S_DMAReq_Tx | SPI_I2S_DMAReq_Rx, ENABLE); /* Set callback function */ spi_dev->callback = callback;