aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/src/hal_spi.c
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/src/hal_spi.c
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/src/hal_spi.c')
-rw-r--r--os/hal/src/hal_spi.c47
1 files changed, 43 insertions, 4 deletions
diff --git a/os/hal/src/hal_spi.c b/os/hal/src/hal_spi.c
index a16b61591..da42b5e1d 100644
--- a/os/hal/src/hal_spi.c
+++ b/os/hal/src/hal_spi.c
@@ -263,6 +263,49 @@ void spiStartReceive(SPIDriver *spip, size_t n, void *rxbuf) {
osalSysUnlock();
}
+#if (SPI_SUPPORTS_CIRCULAR == TRUE) || defined(__DOXYGEN__)
+/**
+ * @brief Aborts the ongoing SPI operation.
+ *
+ * @param[in] spip pointer to the @p SPIDriver object
+ *
+ * @iclass
+ */
+void spiAbortI(SPIDriver *spip) {
+
+ osalDbgCheckClassI();
+
+ osalDbgCheck(spip != NULL);
+ osalDbgAssert((spip->state == SPI_ACTIVE) || (spip->state == SPI_COMPLETE),
+ "invalid state");
+
+ spi_lld_abort(spip);
+ spip->state = SPI_READY;
+#if SPI_USE_WAIT == TRUE
+ osalThreadResumeI(&spip->thread, MSG_OK);
+#endif
+}
+
+/**
+ * @brief Aborts the ongoing SPI operation, if any.
+ *
+ * @param[in] spip pointer to the @p SPIDriver object
+ *
+ * @api
+ */
+void spiAbort(SPIDriver *spip) {
+
+ osalSysLock();
+ osalDbgAssert((spip->state == SPI_READY) || (spip->state == SPI_ACTIVE),
+ "invalid state");
+ if (spip->state == SPI_ACTIVE) {
+ spiAbortI(spip);
+ osalOsRescheduleS();
+ }
+ osalSysUnlock();
+}
+#endif
+
#if (SPI_USE_WAIT == TRUE) || defined(__DOXYGEN__)
/**
* @brief Ignores data on the SPI bus.
@@ -284,7 +327,6 @@ void spiIgnore(SPIDriver *spip, size_t n) {
osalSysLock();
osalDbgAssert(spip->state == SPI_READY, "not ready");
- osalDbgAssert(spip->config->end_cb == NULL, "has callback");
spiStartIgnoreI(spip, n);
(void) osalThreadSuspendS(&spip->thread);
osalSysUnlock();
@@ -316,7 +358,6 @@ void spiExchange(SPIDriver *spip, size_t n,
osalSysLock();
osalDbgAssert(spip->state == SPI_READY, "not ready");
- osalDbgAssert(spip->config->end_cb == NULL, "has callback");
spiStartExchangeI(spip, n, txbuf, rxbuf);
(void) osalThreadSuspendS(&spip->thread);
osalSysUnlock();
@@ -344,7 +385,6 @@ void spiSend(SPIDriver *spip, size_t n, const void *txbuf) {
osalSysLock();
osalDbgAssert(spip->state == SPI_READY, "not ready");
- osalDbgAssert(spip->config->end_cb == NULL, "has callback");
spiStartSendI(spip, n, txbuf);
(void) osalThreadSuspendS(&spip->thread);
osalSysUnlock();
@@ -372,7 +412,6 @@ void spiReceive(SPIDriver *spip, size_t n, void *rxbuf) {
osalSysLock();
osalDbgAssert(spip->state == SPI_READY, "not ready");
- osalDbgAssert(spip->config->end_cb == NULL, "has callback");
spiStartReceiveI(spip, n, rxbuf);
(void) osalThreadSuspendS(&spip->thread);
osalSysUnlock();