aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/include
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2018-01-09 15:39:54 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2018-01-09 15:39:54 +0000
commit7e46dc94aa5d6bad9ff7e449878f64938b2437f1 (patch)
tree70cdbe952a24ebdae5f6ab406d7faa3ba72608c3 /os/hal/include
parentcafec08d95c1428645e3b2efa59d11a3a5c1d432 (diff)
downloadChibiOS-7e46dc94aa5d6bad9ff7e449878f64938b2437f1.tar.gz
ChibiOS-7e46dc94aa5d6bad9ff7e449878f64938b2437f1.tar.bz2
ChibiOS-7e46dc94aa5d6bad9ff7e449878f64938b2437f1.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@11242 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/include')
-rw-r--r--os/hal/include/hal_spi.h58
1 files changed, 58 insertions, 0 deletions
diff --git a/os/hal/include/hal_spi.h b/os/hal/include/hal_spi.h
index 3795bf828..fafc3ce2a 100644
--- a/os/hal/include/hal_spi.h
+++ b/os/hal/include/hal_spi.h
@@ -61,6 +61,14 @@
#endif
/**
+ * @brief Enables circular transfers APIs.
+ * @note Disabling this option saves both code and data space.
+ */
+#if !defined(SPI_USE_CIRCULAR) || defined(__DOXYGEN__)
+#define SPI_USE_CIRCULAR FALSE
+#endif
+
+/**
* @brief Enables the @p spiAcquireBus() and @p spiReleaseBus() APIs.
* @note Disabling this option saves both code and data space.
*/
@@ -106,6 +114,12 @@ typedef enum {
#include "hal_spi_lld.h"
+/* Some more checks, must happen after inclusion of the LLD header, this is
+ why are placed here.*/
+#if !defined(SPI_SUPPORTS_CIRCULAR)
+#define SPI_SUPPORTS_CIRCULAR FALSE
+#endif
+
/*===========================================================================*/
/* Driver macros. */
/*===========================================================================*/
@@ -321,6 +335,46 @@ do { \
(spip)->state = SPI_READY; \
_spi_wakeup_isr(spip); \
}
+
+/**
+ * @brief Common ISR code in circular mode.
+ * @details This code handles the portable part of the ISR code:
+ * - Callback invocation.
+ * .
+ * @note This macro is meant to be used in the low level drivers
+ * implementation only.
+ *
+ * @param[in] spip pointer to the @p SPIDriver object
+ *
+ * @notapi
+ */
+#define _spi_isr_code_half1(spip) { \
+ if ((spip)->config->end_cb) { \
+ (spip)->config->end_cb(spip); \
+ } \
+}
+
+/**
+ * @brief Common ISR code in circular mode.
+ * @details This code handles the portable part of the ISR code:
+ * - Callback invocation.
+ * - Driver state transitions.
+ * .
+ * @note This macro is meant to be used in the low level drivers
+ * implementation only.
+ *
+ * @param[in] spip pointer to the @p SPIDriver object
+ *
+ * @notapi
+ */
+#define _spi_isr_code_half2(spip) { \
+ if ((spip)->config->end_cb) { \
+ (spip)->state = SPI_COMPLETE; \
+ (spip)->config->end_cb(spip); \
+ if ((spip)->state == SPI_COMPLETE) \
+ (spip)->state = SPI_ACTIVE; \
+ } \
+}
/** @} */
/*===========================================================================*/
@@ -341,6 +395,10 @@ extern "C" {
const void *txbuf, void *rxbuf);
void spiStartSend(SPIDriver *spip, size_t n, const void *txbuf);
void spiStartReceive(SPIDriver *spip, size_t n, void *rxbuf);
+#if SPI_SUPPORTS_CIRCULAR == TRUE
+ void spiAbortI(SPIDriver *spip);
+ void spiAbort(SPIDriver *spip);
+#endif
#if SPI_USE_WAIT == TRUE
void spiIgnore(SPIDriver *spip, size_t n);
void spiExchange(SPIDriver *spip, size_t n, const void *txbuf, void *rxbuf);