Fixed BIDIMODE-related changes in SPI drivers.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@9030 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
parent
08a4706fb2
commit
ab30e97aea
|
@ -116,7 +116,8 @@ SPIDriver SPID6;
|
|||
/* Driver local variables and types. */
|
||||
/*===========================================================================*/
|
||||
|
||||
static uint16_t dummytx;
|
||||
static const uint16_t dummytx = 0xFFFFU;
|
||||
static uint16_t dummyrx;
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver local functions. */
|
||||
|
@ -145,11 +146,12 @@ static void spi_lld_serve_rx_interrupt(SPIDriver *spip, uint32_t flags) {
|
|||
|
||||
#if STM32_SPI_USE_BIDIMODE
|
||||
spip->spi->CR1 |= SPI_CR1_BIDIOE;
|
||||
#endif
|
||||
|
||||
/* Errors reset sequence.*/
|
||||
/* Errors reset sequence. It is required becaue BIDIOE could cause extra
|
||||
clock pulses after DMA stopped reading.*/
|
||||
(void)spip->spi->DR;
|
||||
(void)spip->spi->SR;
|
||||
#endif
|
||||
|
||||
/* Portable SPI ISR code defined in the high level driver, note, it is
|
||||
a macro.*/
|
||||
|
@ -191,8 +193,6 @@ static void spi_lld_serve_tx_interrupt(SPIDriver *spip, uint32_t flags) {
|
|||
*/
|
||||
void spi_lld_init(void) {
|
||||
|
||||
dummytx = 0xFFFF;
|
||||
|
||||
#if STM32_SPI_USE_SPI1
|
||||
spiObjectInit(&SPID1);
|
||||
SPID1.spi = SPI1;
|
||||
|
@ -531,12 +531,18 @@ void spi_lld_ignore(SPIDriver *spip, size_t n) {
|
|||
if ((spip->spi->CR1 & SPI_CR1_BIDIMODE) != 0) {
|
||||
osalDbgAssert((spip->spi->CR1 & SPI_CR1_BIDIOE) != 0,
|
||||
"BIDIOE not set");
|
||||
}
|
||||
#endif
|
||||
|
||||
dmaStreamSetMemory0(spip->dmarx, &dummyrx);
|
||||
dmaStreamSetTransactionSize(spip->dmarx, n);
|
||||
dmaStreamSetMode(spip->dmarx, spip->rxdmamode);
|
||||
|
||||
dmaStreamSetMemory0(spip->dmatx, &dummytx);
|
||||
dmaStreamSetTransactionSize(spip->dmatx, n);
|
||||
dmaStreamSetMode(spip->dmatx, spip->txdmamode);
|
||||
|
||||
dmaStreamEnable(spip->dmarx);
|
||||
dmaStreamEnable(spip->dmatx);
|
||||
}
|
||||
|
||||
|
@ -594,12 +600,18 @@ void spi_lld_send(SPIDriver *spip, size_t n, const void *txbuf) {
|
|||
if ((spip->spi->CR1 & SPI_CR1_BIDIMODE) != 0) {
|
||||
osalDbgAssert((spip->spi->CR1 & SPI_CR1_BIDIOE) != 0,
|
||||
"BIDIOE not set");
|
||||
}
|
||||
#endif
|
||||
|
||||
dmaStreamSetMemory0(spip->dmarx, &dummyrx);
|
||||
dmaStreamSetTransactionSize(spip->dmarx, n);
|
||||
dmaStreamSetMode(spip->dmarx, spip->rxdmamode);
|
||||
|
||||
dmaStreamSetMemory0(spip->dmatx, txbuf);
|
||||
dmaStreamSetTransactionSize(spip->dmatx, n);
|
||||
dmaStreamSetMode(spip->dmatx, spip->txdmamode | STM32_DMA_CR_MINC);
|
||||
|
||||
dmaStreamEnable(spip->dmarx);
|
||||
dmaStreamEnable(spip->dmatx);
|
||||
}
|
||||
|
||||
|
@ -619,10 +631,11 @@ void spi_lld_send(SPIDriver *spip, size_t n, const void *txbuf) {
|
|||
void spi_lld_receive(SPIDriver *spip, size_t n, void *rxbuf) {
|
||||
|
||||
#if STM32_SPI_USE_BIDIMODE
|
||||
if ((spip->spi->CR1 & SPI_CR1_BIDIMODE) != 0) {
|
||||
|
||||
osalDbgAssert((spip->spi->CR1 & SPI_CR1_BIDIOE) != 0,
|
||||
"BIDIOE not set");
|
||||
|
||||
if ((spip->spi->CR1 & SPI_CR1_BIDIMODE) != 0) {
|
||||
dmaStreamSetMemory0(spip->dmarx, rxbuf);
|
||||
dmaStreamSetTransactionSize(spip->dmarx, n);
|
||||
dmaStreamSetMode(spip->dmarx, spip->rxdmamode | STM32_DMA_CR_MINC);
|
||||
|
@ -666,8 +679,6 @@ uint16_t spi_lld_polled_exchange(SPIDriver *spip, uint16_t frame) {
|
|||
#if STM32_SPI_USE_BIDIMODE
|
||||
osalDbgAssert((spip->spi->CR1 & SPI_CR1_BIDIMODE) == 0,
|
||||
"spiPolledExchange() not possible with BIDIMODE");
|
||||
osalDbgAssert((spip->spi->CR1 & SPI_CR1_BIDIOE) != 0,
|
||||
"BIDIOE not set");
|
||||
#endif
|
||||
|
||||
spip->spi->DR = frame;
|
||||
|
|
|
@ -117,6 +117,7 @@ SPIDriver SPID6;
|
|||
/*===========================================================================*/
|
||||
|
||||
static const uint16_t dummytx = 0xFFFFU;
|
||||
static uint16_t dummyrx;
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver local functions. */
|
||||
|
@ -145,11 +146,12 @@ static void spi_lld_serve_rx_interrupt(SPIDriver *spip, uint32_t flags) {
|
|||
|
||||
#if STM32_SPI_USE_BIDIMODE
|
||||
spip->spi->CR1 |= SPI_CR1_BIDIOE;
|
||||
#endif
|
||||
|
||||
/* Errors reset sequence.*/
|
||||
/* Errors reset sequence. It is required becaue BIDIOE could cause extra
|
||||
clock pulses after DMA stopped reading.*/
|
||||
(void)spip->spi->DR;
|
||||
(void)spip->spi->SR;
|
||||
#endif
|
||||
|
||||
/* Portable SPI ISR code defined in the high level driver, note, it is
|
||||
a macro.*/
|
||||
|
@ -532,12 +534,18 @@ void spi_lld_ignore(SPIDriver *spip, size_t n) {
|
|||
if ((spip->spi->CR1 & SPI_CR1_BIDIMODE) != 0) {
|
||||
osalDbgAssert((spip->spi->CR1 & SPI_CR1_BIDIOE) != 0,
|
||||
"BIDIOE not set");
|
||||
}
|
||||
#endif
|
||||
|
||||
dmaStreamSetMemory0(spip->dmarx, &dummyrx);
|
||||
dmaStreamSetTransactionSize(spip->dmarx, n);
|
||||
dmaStreamSetMode(spip->dmarx, spip->rxdmamode);
|
||||
|
||||
dmaStreamSetMemory0(spip->dmatx, &dummytx);
|
||||
dmaStreamSetTransactionSize(spip->dmatx, n);
|
||||
dmaStreamSetMode(spip->dmatx, spip->txdmamode);
|
||||
|
||||
dmaStreamEnable(spip->dmarx);
|
||||
dmaStreamEnable(spip->dmatx);
|
||||
}
|
||||
|
||||
|
@ -595,12 +603,18 @@ void spi_lld_send(SPIDriver *spip, size_t n, const void *txbuf) {
|
|||
if ((spip->spi->CR1 & SPI_CR1_BIDIMODE) != 0) {
|
||||
osalDbgAssert((spip->spi->CR1 & SPI_CR1_BIDIOE) != 0,
|
||||
"BIDIOE not set");
|
||||
}
|
||||
#endif
|
||||
|
||||
dmaStreamSetMemory0(spip->dmarx, &dummyrx);
|
||||
dmaStreamSetTransactionSize(spip->dmarx, n);
|
||||
dmaStreamSetMode(spip->dmarx, spip->rxdmamode);
|
||||
|
||||
dmaStreamSetMemory0(spip->dmatx, txbuf);
|
||||
dmaStreamSetTransactionSize(spip->dmatx, n);
|
||||
dmaStreamSetMode(spip->dmatx, spip->txdmamode | STM32_DMA_CR_MINC);
|
||||
|
||||
dmaStreamEnable(spip->dmarx);
|
||||
dmaStreamEnable(spip->dmatx);
|
||||
}
|
||||
|
||||
|
@ -620,10 +634,11 @@ void spi_lld_send(SPIDriver *spip, size_t n, const void *txbuf) {
|
|||
void spi_lld_receive(SPIDriver *spip, size_t n, void *rxbuf) {
|
||||
|
||||
#if STM32_SPI_USE_BIDIMODE
|
||||
if ((spip->spi->CR1 & SPI_CR1_BIDIMODE) != 0) {
|
||||
|
||||
osalDbgAssert((spip->spi->CR1 & SPI_CR1_BIDIOE) != 0,
|
||||
"BIDIOE not set");
|
||||
|
||||
if ((spip->spi->CR1 & SPI_CR1_BIDIMODE) != 0) {
|
||||
dmaStreamSetMemory0(spip->dmarx, rxbuf);
|
||||
dmaStreamSetTransactionSize(spip->dmarx, n);
|
||||
dmaStreamSetMode(spip->dmarx, spip->rxdmamode | STM32_DMA_CR_MINC);
|
||||
|
@ -667,8 +682,6 @@ uint16_t spi_lld_polled_exchange(SPIDriver *spip, uint16_t frame) {
|
|||
#if STM32_SPI_USE_BIDIMODE
|
||||
osalDbgAssert((spip->spi->CR1 & SPI_CR1_BIDIMODE) == 0,
|
||||
"spiPolledExchange() not possible with BIDIMODE");
|
||||
osalDbgAssert((spip->spi->CR1 & SPI_CR1_BIDIOE) != 0,
|
||||
"BIDIOE not set");
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue