aboutsummaryrefslogtreecommitdiffstats
path: root/os
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2010-10-30 13:20:29 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2010-10-30 13:20:29 +0000
commit76603ff54010cf7c5351994c2333e8b157f0b1f0 (patch)
treef626724769fb16ddd94beaef8c6ee05a79df1d61 /os
parenta884e58e2cea877f804cb643d4d1e0909bd1fa49 (diff)
downloadChibiOS-76603ff54010cf7c5351994c2333e8b157f0b1f0.tar.gz
ChibiOS-76603ff54010cf7c5351994c2333e8b157f0b1f0.tar.bz2
ChibiOS-76603ff54010cf7c5351994c2333e8b157f0b1f0.zip
Added polled API to the STM32 SPI driver.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2303 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os')
-rw-r--r--os/hal/platforms/STM32/spi_lld.c20
-rw-r--r--os/hal/platforms/STM32/spi_lld.h1
2 files changed, 21 insertions, 0 deletions
diff --git a/os/hal/platforms/STM32/spi_lld.c b/os/hal/platforms/STM32/spi_lld.c
index be0a117e3..7d4d182bb 100644
--- a/os/hal/platforms/STM32/spi_lld.c
+++ b/os/hal/platforms/STM32/spi_lld.c
@@ -466,6 +466,26 @@ void spi_lld_receive(SPIDriver *spip, size_t n, void *rxbuf) {
dma_start(spip);
}
+/**
+ * @brief Exchanges one frame using a polled wait.
+ * @details This synchronous function exchanges one frame using a polled
+ * synchronization method. This function is useful when exchanging
+ * small amount of data on high speed channels, usually in this
+ * situation is much more efficient just wait for completion using
+ * polling than suspending the thread waiting for an interrupt.
+ *
+ * @param[in] spip pointer to the @p SPIDriver object
+ * @param[in] frame the data frame to send over the SPI bus
+ * @return The received data frame from the SPI bus.
+ */
+uint16_t spi_lld_polled_exchange(SPIDriver *spip, uint16_t frame) {
+
+ spip->spd_spi->DR = frame;
+ while ((spip->spd_spi->SR & SPI_SR_RXNE) == 0)
+ ;
+ return spip->spd_spi->DR;
+}
+
#endif /* CH_HAL_USE_SPI */
/** @} */
diff --git a/os/hal/platforms/STM32/spi_lld.h b/os/hal/platforms/STM32/spi_lld.h
index effe0337c..54b995a02 100644
--- a/os/hal/platforms/STM32/spi_lld.h
+++ b/os/hal/platforms/STM32/spi_lld.h
@@ -282,6 +282,7 @@ extern "C" {
const void *txbuf, void *rxbuf);
void spi_lld_send(SPIDriver *spip, size_t n, const void *txbuf);
void spi_lld_receive(SPIDriver *spip, size_t n, void *rxbuf);
+ uint16_t spi_lld_polled_exchange(SPIDriver *spip, uint16_t frame);
#ifdef __cplusplus
}
#endif