From 216990672983c3c551f2aaf45cf27d8f9ce68036 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 24 Oct 2009 14:08:41 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1252 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/io/platforms/STM32/spi_lld.c | 7 +++++-- os/io/platforms/STM32/spi_lld.h | 23 +++++++++++++++++++++++ os/io/spi.c | 4 ++-- os/io/templates/spi_lld.c | 4 ++-- 4 files changed, 32 insertions(+), 6 deletions(-) (limited to 'os') diff --git a/os/io/platforms/STM32/spi_lld.c b/os/io/platforms/STM32/spi_lld.c index 5e8ef614e..a143bb463 100644 --- a/os/io/platforms/STM32/spi_lld.c +++ b/os/io/platforms/STM32/spi_lld.c @@ -71,25 +71,28 @@ void spi_lld_init(void) { */ void spi_lld_setup(SPIDriver *spip) { + spip->spd_spi->CR1 = spip->spd_config->spc_cr1; } /** - * @brief Asserts the chip select signal and prepares for transfers. + * @brief Asserts the slave select signal and prepares for transfers. * * @param[in] spip pointer to the @p SPIDriver object */ void spi_lld_select(SPIDriver *spip) { + palClearPad(spip->spd_config->spc_ssport, spip->spd_config->spc_sspad); } /** - * @brief De-asserts the chip select signal. + * @brief De-asserts the slave select signal. * @details The previously selected peripheral is unselected. * * @param[in] spip pointer to the @p SPIDriver object */ void spi_lld_unselect(SPIDriver *spip) { + palSetPad(spip->spd_config->spc_ssport, spip->spd_config->spc_sspad); } /** diff --git a/os/io/platforms/STM32/spi_lld.h b/os/io/platforms/STM32/spi_lld.h index 23193bc0d..b6698e1b2 100644 --- a/os/io/platforms/STM32/spi_lld.h +++ b/os/io/platforms/STM32/spi_lld.h @@ -27,6 +27,8 @@ #ifndef _SPI_LLD_H_ #define _SPI_LLD_H_ +#include + #undef FALSE #undef TRUE #include @@ -77,6 +79,18 @@ typedef struct { */ cnt_t spc_clkpulses; /* End of the mandatory fields.*/ + /** + * @brief The chip select line port. + */ + ioportid_t spc_ssport; + /** + * @brief The chip select line pad number. + */ + uint16_t spc_sspad; + /** + * @brief SPI initialization data. + */ + uint16_t spc_cr1; } SPIConfig; /** @@ -102,8 +116,17 @@ typedef struct { */ const SPIConfig *spd_config; /* End of the mandatory fields.*/ + /** + * @brief Pointer to the SPIx registers block. + */ SPI_TypeDef *spd_spi; + /** + * @brief Pointer to the receive DMA channel registers block. + */ DMA_Channel_TypeDef *spd_dmarx; + /** + * @brief Pointer to the transmit DMA channel registers block. + */ DMA_Channel_TypeDef *spd_dmatx; } SPIDriver; diff --git a/os/io/spi.c b/os/io/spi.c index 2ea8f8909..7c08fe413 100644 --- a/os/io/spi.c +++ b/os/io/spi.c @@ -68,7 +68,7 @@ void spiSetup(SPIDriver *spip, const SPIConfig *config) { } /** - * @brief Asserts the chip select signal and prepares for transfers. + * @brief Asserts the slave select signal and prepares for transfers. * * @param[in] spip pointer to the @p SPIDriver object */ @@ -86,7 +86,7 @@ void spiSelect(SPIDriver *spip) { } /** - * @brief De-asserts the chip select signal. + * @brief De-asserts the slave select signal. * @details The previously selected peripheral is unselected. * * @param[in] spip pointer to the @p SPIDriver object diff --git a/os/io/templates/spi_lld.c b/os/io/templates/spi_lld.c index 4ef99e1ed..e98ecea14 100644 --- a/os/io/templates/spi_lld.c +++ b/os/io/templates/spi_lld.c @@ -44,7 +44,7 @@ void spi_lld_setup(SPIDriver *spip) { } /** - * @brief Asserts the chip select signal and prepares for transfers. + * @brief Asserts the slave select signal and prepares for transfers. * * @param[in] spip pointer to the @p SPIDriver object */ @@ -53,7 +53,7 @@ void spi_lld_select(SPIDriver *spip) { } /** - * @brief De-asserts the chip select signal. + * @brief De-asserts the slave select signal. * @details The previously selected peripheral is unselected. * * @param[in] spip pointer to the @p SPIDriver object -- cgit v1.2.3