git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1254 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
parent
81f043865e
commit
5d19ae768a
|
@ -103,7 +103,31 @@ void spi_lld_init(void) {
|
||||||
*/
|
*/
|
||||||
void spi_lld_setup(SPIDriver *spip) {
|
void spi_lld_setup(SPIDriver *spip) {
|
||||||
|
|
||||||
|
/* SPI setup.*/
|
||||||
spip->spd_spi->CR1 = spip->spd_config->spc_cr1;
|
spip->spd_spi->CR1 = spip->spd_config->spc_cr1;
|
||||||
|
|
||||||
|
/* DMA setup.*/
|
||||||
|
if ((spip->spd_config->spc_cr1 & SPI_CR1_DFF) != 0) {
|
||||||
|
/* Prepares for 16 bits transfer.*/
|
||||||
|
spip->spd_dmarx->CCR = spip->spd_dmaprio |
|
||||||
|
DMA_CCR1_MSIZE_0 | DMA_CCR1_PSIZE_0 |
|
||||||
|
DMA_CCR1_MINC |
|
||||||
|
DMA_CCR1_TEIE | DMA_CCR1_TCIE;
|
||||||
|
spip->spd_dmatx->CCR = spip->spd_dmaprio |
|
||||||
|
DMA_CCR1_MSIZE_0 | DMA_CCR1_PSIZE_0 |
|
||||||
|
DMA_CCR1_MINC | DMA_CCR1_DIR |
|
||||||
|
DMA_CCR1_TEIE | DMA_CCR1_TCIE;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* Prepares for 8 bits transfer.*/
|
||||||
|
spip->spd_dmarx->CCR = spip->spd_dmaprio | DMA_CCR1_MINC |
|
||||||
|
DMA_CCR1_TEIE | DMA_CCR1_TCIE;
|
||||||
|
spip->spd_dmatx->CCR = spip->spd_dmaprio |
|
||||||
|
DMA_CCR1_MINC | DMA_CCR1_DIR |
|
||||||
|
DMA_CCR1_TEIE | DMA_CCR1_TCIE;
|
||||||
|
}
|
||||||
|
spip->spd_dmarx->CPAR = (uint32_t)&spip->spd_spi->DR;
|
||||||
|
spip->spd_dmatx->CPAR = (uint32_t)&spip->spd_spi->DR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -146,15 +170,11 @@ void spi_lld_unselect(SPIDriver *spip) {
|
||||||
*/
|
*/
|
||||||
void spi_lld_exchange(SPIDriver *spip, size_t n, void *rxbuf, void *txbuf) {
|
void spi_lld_exchange(SPIDriver *spip, size_t n, void *rxbuf, void *txbuf) {
|
||||||
|
|
||||||
/*
|
/* DMA setup.*/
|
||||||
* DMA setup.
|
|
||||||
*/
|
|
||||||
spip->spd_dmarx->CNDTR = (uint32_t)n;
|
spip->spd_dmarx->CNDTR = (uint32_t)n;
|
||||||
spip->spd_dmarx->CPAR = (uint32_t)&spip->spd_spi->DR;
|
spip->spd_dmatx->CNDTR = (uint32_t)n;
|
||||||
spip->spd_dmarx->CMAR = (uint32_t)rxbuf;
|
spip->spd_dmarx->CMAR = (uint32_t)rxbuf;
|
||||||
spip->spd_dmarx->CCR = spip->spd_dmaprio |
|
spip->spd_dmatx->CMAR = (uint32_t)txbuf;
|
||||||
DMA_CCR1_MSIZE_0 | DMA_CCR1_MSIZE_0 |
|
|
||||||
DMA_CCR1_MINC | DMA_CCR1_TEIE | DMA_CCR1_TCIE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
Loading…
Reference in New Issue