cleanup
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@15006 27425a3e-05d8-49a3-a47f-9c15f0e5edd8
This commit is contained in:
parent
998b9f8891
commit
dda3dc7efe
|
@ -120,6 +120,21 @@ SPIDriver SPID6;
|
||||||
/* Driver local functions. */
|
/* Driver local functions. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
static void spi_lld_configure(SPIDriver *spip) {
|
||||||
|
|
||||||
|
/* SPI setup.*/
|
||||||
|
if (spip->config->slave) {
|
||||||
|
spip->spi->CR1 = spip->config->cr1 & ~(SPI_CR1_MSTR | SPI_CR1_SPE);
|
||||||
|
spip->spi->CR2 = spip->config->cr2 | SPI_CR2_FRXTH |
|
||||||
|
SPI_CR2_RXDMAEN | SPI_CR2_TXDMAEN;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
spip->spi->CR1 = (spip->config->cr1 | SPI_CR1_MSTR) & ~SPI_CR1_SPE;
|
||||||
|
spip->spi->CR2 = spip->config->cr2 | SPI_CR2_FRXTH | SPI_CR2_SSOE |
|
||||||
|
SPI_CR2_RXDMAEN | SPI_CR2_TXDMAEN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Stopping the SPI transaction.
|
* @brief Stopping the SPI transaction.
|
||||||
* @note This is done nicely or by brutally resetting it depending on
|
* @note This is done nicely or by brutally resetting it depending on
|
||||||
|
@ -196,9 +211,7 @@ static msg_t spi_lld_stop_abort(SPIDriver *spip) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Reconfiguring SPI.*/
|
/* Reconfiguring SPI.*/
|
||||||
spip->spi->CR1 = spip->config->cr1 & ~(SPI_CR1_MSTR | SPI_CR1_SPE);
|
spi_lld_configure(spip);
|
||||||
spip->spi->CR2 = spip->config->cr2 | SPI_CR2_FRXTH |
|
|
||||||
SPI_CR2_RXDMAEN | SPI_CR2_TXDMAEN;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return HAL_RET_SUCCESS;
|
return HAL_RET_SUCCESS;
|
||||||
|
@ -584,17 +597,8 @@ msg_t spi_lld_start(SPIDriver *spip) {
|
||||||
spip->txdmamode &= ~(STM32_DMA_CR_CIRC | STM32_DMA_CR_HTIE);
|
spip->txdmamode &= ~(STM32_DMA_CR_CIRC | STM32_DMA_CR_HTIE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* SPI setup and enable.*/
|
/* SPI setup.*/
|
||||||
if (spip->config->slave) {
|
spi_lld_configure(spip);
|
||||||
spip->spi->CR1 = spip->config->cr1 & ~(SPI_CR1_MSTR | SPI_CR1_SPE);
|
|
||||||
spip->spi->CR2 = spip->config->cr2 | SPI_CR2_FRXTH |
|
|
||||||
SPI_CR2_RXDMAEN | SPI_CR2_TXDMAEN;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
spip->spi->CR1 = (spip->config->cr1 | SPI_CR1_MSTR) & ~SPI_CR1_SPE;
|
|
||||||
spip->spi->CR2 = spip->config->cr2 | SPI_CR2_FRXTH | SPI_CR2_SSOE |
|
|
||||||
SPI_CR2_RXDMAEN | SPI_CR2_TXDMAEN;
|
|
||||||
}
|
|
||||||
|
|
||||||
return HAL_RET_SUCCESS;
|
return HAL_RET_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue