git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@8234 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
Giovanni Di Sirio 2015-08-22 12:43:17 +00:00
parent eec9281e9f
commit 6ae7992c99
4 changed files with 19 additions and 5 deletions

View File

@ -417,6 +417,7 @@ void spi_lld_start(SPIDriver *spip) {
STM32_DMA_CR_PSIZE_BYTE | STM32_DMA_CR_MSIZE_BYTE;
spip->txdmamode = (spip->txdmamode & ~STM32_DMA_CR_SIZE_MASK) |
STM32_DMA_CR_PSIZE_BYTE | STM32_DMA_CR_MSIZE_BYTE;
spip->fsize = sizeof (uint8_t);
}
else {
/* Frame width is larger than 8 bits.*/
@ -424,6 +425,7 @@ void spi_lld_start(SPIDriver *spip) {
STM32_DMA_CR_PSIZE_HWORD | STM32_DMA_CR_MSIZE_HWORD;
spip->txdmamode = (spip->txdmamode & ~STM32_DMA_CR_SIZE_MASK) |
STM32_DMA_CR_PSIZE_HWORD | STM32_DMA_CR_MSIZE_HWORD;
spip->fsize = sizeof (uint16_t);
}
/* SPI setup and enable.*/
spip->spi->CR1 = 0;
@ -547,6 +549,9 @@ void spi_lld_ignore(SPIDriver *spip, size_t n) {
void spi_lld_exchange(SPIDriver *spip, size_t n,
const void *txbuf, void *rxbuf) {
/* DMA buffer invalidation because data cache.*/
dmaBufferInvalidate(rxbuf, (uint8_t *)rxbuf + (n * spip->fsize));
dmaStreamSetMemory0(spip->dmarx, rxbuf);
dmaStreamSetTransactionSize(spip->dmarx, n);
dmaStreamSetMode(spip->dmarx, spip->rxdmamode| STM32_DMA_CR_MINC);
@ -601,6 +606,9 @@ void spi_lld_send(SPIDriver *spip, size_t n, const void *txbuf) {
*/
void spi_lld_receive(SPIDriver *spip, size_t n, void *rxbuf) {
/* DMA buffer invalidation because data cache.*/
dmaBufferInvalidate(rxbuf, (uint8_t *)rxbuf + (n * spip->fsize));
dmaStreamSetMemory0(spip->dmarx, rxbuf);
dmaStreamSetTransactionSize(spip->dmarx, n);
dmaStreamSetMode(spip->dmarx, spip->rxdmamode | STM32_DMA_CR_MINC);

View File

@ -473,21 +473,25 @@ struct SPIDriver {
*/
SPI_TypeDef *spi;
/**
* @brief Receive DMA stream.
* @brief Receive DMA stream.
*/
const stm32_dma_stream_t *dmarx;
/**
* @brief Transmit DMA stream.
* @brief Transmit DMA stream.
*/
const stm32_dma_stream_t *dmatx;
/**
* @brief RX DMA mode bit mask.
* @brief RX DMA mode bit mask.
*/
uint32_t rxdmamode;
/**
* @brief TX DMA mode bit mask.
* @brief TX DMA mode bit mask.
*/
uint32_t txdmamode;
/**
* @brief Frame size in bytes.
*/
size_t fsize;
};
/*===========================================================================*/

View File

@ -95,6 +95,8 @@
- HAL: Introduced support for TIM21 and TIM22 in STM32 ST driver.
- HAL: Updated STM32F0xx headers to STM32CubeF0 version 1.3.0. Added support
for STM32F030xC, STM32F070x6, STM32F070xB devices.
- HAL: Fixed wrong ld file in STM32F072xB USB CDC demo (bug #634)(backported
to 3.0.2).
- NIL: Fixed Wrong assertion in NIL chSemResetI() and NIL OSAL
osalThreadDequeueAllI() (bug #633)(backported to 3.0.2).
- RT: Fixed problem with RT mutexes involving priority inheritance (bug #632)

View File

@ -96,7 +96,7 @@ include $(CHIBIOS)/os/rt/ports/ARMCMx/compilers/GCC/mk/port_v6m.mk
include $(CHIBIOS)/test/rt/test.mk
# Define linker script file here
LDSCRIPT= $(STARTUPLD)/STM32F051x8.ld
LDSCRIPT= $(STARTUPLD)/STM32F072xB.ld
# C sources that can be compiled in ARM or THUMB mode depending on the global
# setting.