aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/platforms
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2010-10-30 13:31:33 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2010-10-30 13:31:33 +0000
commitb8fd99cc2a07ac06635f2ada049dd3e7f8e741b4 (patch)
treeda60ae5c6d5a87c78f0a882122e3eabe083b6e3e /os/hal/platforms
parent76603ff54010cf7c5351994c2333e8b157f0b1f0 (diff)
downloadChibiOS-b8fd99cc2a07ac06635f2ada049dd3e7f8e741b4.tar.gz
ChibiOS-b8fd99cc2a07ac06635f2ada049dd3e7f8e741b4.tar.bz2
ChibiOS-b8fd99cc2a07ac06635f2ada049dd3e7f8e741b4.zip
Added polled API to the AT91SAM7 SPI driver.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2304 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/platforms')
-rw-r--r--os/hal/platforms/AT91SAM7/spi_lld.c21
-rw-r--r--os/hal/platforms/AT91SAM7/spi_lld.h1
2 files changed, 22 insertions, 0 deletions
diff --git a/os/hal/platforms/AT91SAM7/spi_lld.c b/os/hal/platforms/AT91SAM7/spi_lld.c
index 4bb0ea40c..2cd552ebf 100644
--- a/os/hal/platforms/AT91SAM7/spi_lld.c
+++ b/os/hal/platforms/AT91SAM7/spi_lld.c
@@ -374,6 +374,27 @@ void spi_lld_receive(SPIDriver *spip, size_t n, void *rxbuf) {
spip->spd_spi->SPI_PTCR = AT91C_PDC_RXTEN | AT91C_PDC_TXTEN;
}
+/**
+ * @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->SPI_CR = AT91C_SPI_SPIEN;
+ spip->spd_spi->SPI_TDR = frame;
+ while ((spip->spd_spi->SPI_SR & AT91C_SPI_RDRF) == 0)
+ ;
+ return spip->spd_spi->SPI_RDR;
+}
+
#endif /* CH_HAL_USE_SPI */
/** @} */
diff --git a/os/hal/platforms/AT91SAM7/spi_lld.h b/os/hal/platforms/AT91SAM7/spi_lld.h
index 173ad10c3..2b5ec2acb 100644
--- a/os/hal/platforms/AT91SAM7/spi_lld.h
+++ b/os/hal/platforms/AT91SAM7/spi_lld.h
@@ -213,6 +213,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