From 8c021bfac50e854ceede9a4ccdfc83e52ffba2be Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Sun, 17 Oct 2021 14:42:23 +0000 Subject: [PATCH] Simplified handling of circular mode. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@14918 27425a3e-05d8-49a3-a47f-9c15f0e5edd8 --- os/hal/include/hal_spi_v2.h | 13 ---------- os/hal/src/hal_spi_v2.inc | 49 +++++++++++++++---------------------- 2 files changed, 20 insertions(+), 42 deletions(-) diff --git a/os/hal/include/hal_spi_v2.h b/os/hal/include/hal_spi_v2.h index 29addaaf4..8ee3b818c 100644 --- a/os/hal/include/hal_spi_v2.h +++ b/os/hal/include/hal_spi_v2.h @@ -44,17 +44,6 @@ #define SPI_SELECT_MODE_LLD 4 /** @brief LLD-defined mode.*/ /** @} */ -/** - * @name SPI-specific messages - * @{ - */ -#define MSG_SPI_BUFFER_HALF (msg_t)-3 -#define MSG_SPI_BUFFER_FULL (msg_t)-4 -#define MSG_SPI_COMPLETE MSG_OK -#define MSG_SPI_TIMEOUT MSG_TIMEOUT -#define MSG_SPI_STOPPED MSG_RESET -/** @} */ - /*===========================================================================*/ /* Driver pre-compile time settings. */ /*===========================================================================*/ @@ -428,7 +417,6 @@ do { \ if ((spip)->config->end_cb) { \ (spip)->config->end_cb(spip); \ } \ - __spi_wakeup_isr(spip, MSG_SPI_BUFFER_HALF); \ } /** @@ -452,7 +440,6 @@ do { \ (spip)->state = SPI_ACTIVE; \ } \ } \ - __spi_wakeup_isr(spip, MSG_SPI_BUFFER_FULL); \ } /** diff --git a/os/hal/src/hal_spi_v2.inc b/os/hal/src/hal_spi_v2.inc index 1d9bf1eb8..19aac51e4 100644 --- a/os/hal/src/hal_spi_v2.inc +++ b/os/hal/src/hal_spi_v2.inc @@ -461,7 +461,7 @@ msg_t spiStopTranferI(SPIDriver *spip, size_t *sizep) { spip->state = SPI_READY; #if SPI_USE_SYNCHRONIZATION == TRUE - osalThreadResumeI(&spip->sync_transfer, MSG_SPI_STOPPED); + osalThreadResumeI(&spip->sync_transfer, MSG_RESET); #endif } else { @@ -502,13 +502,9 @@ msg_t spiStopTranfer(SPIDriver *spip, size_t *sizep) { * @param[in] spip pointer to the @p SPIDriver object * @param[in] timeout synchronization timeout * @return The synchronization result. - * @retval MSG_SPI_COMPLETE if operation completed without errors. - * @retval MSG_SPI_TIMEOUT if synchronization timed out. - * @retval MSG_SPI_STOPPED if the transfer has been stopped. - * @retval MSG_SPI_BUFFER_FULL if operation finished on buffer full (circular - * mode only). - * @retval MSG_SPI_BUFFER_HALF if operation finished on buffer half (circular - * mode only). + * @retval MSG_OK if operation completed without errors. + * @retval MSG_TIMEOUT if synchronization timed out. + * @retval MSG_RESET if the transfer has been stopped. * * @sclass */ @@ -523,7 +519,7 @@ msg_t spiSynchronizeS(SPIDriver *spip, sysinterval_t timeout) { msg = osalThreadSuspendTimeoutS(&spip->sync_transfer, timeout); } else { - msg = MSG_SPI_COMPLETE; + msg = MSG_OK; } return msg; @@ -536,13 +532,9 @@ msg_t spiSynchronizeS(SPIDriver *spip, sysinterval_t timeout) { * @param[in] spip pointer to the @p SPIDriver object * @param[in] timeout synchronization timeout * @return The synchronization result. - * @retval MSG_SPI_COMPLETE if operation completed without errors. - * @retval MSG_SPI_TIMEOUT if synchronization timed out. - * @retval MSG_SPI_STOPPED if the transfer has been stopped. - * @retval MSG_SPI_BUFFER_FULL if operation finished on buffer full (circular - * mode only). - * @retval MSG_SPI_BUFFER_HALF if operation finished on buffer half (circular - * mode only). + * @retval MSG_OK if operation completed without errors. + * @retval MSG_TIMEOUT if synchronization timed out. + * @retval MSG_RESET if the transfer has been stopped. * * @api */ @@ -566,9 +558,9 @@ msg_t spiSynchronize(SPIDriver *spip, sysinterval_t timeout) { * @param[in] spip pointer to the @p SPIDriver object * @param[in] n number of words to be ignored * @return The operation status. - * @retval MSG_SPI_COMPLETE if operation completed without errors. - * @retval MSG_SPI_TIMEOUT if synchronization timed out. - * @retval MSG_SPI_STOPPED if the transfer has been stopped. + * @retval MSG_OK if operation completed without errors. + * @retval MSG_TIMEOUT if synchronization timed out. + * @retval MSG_RESET if the transfer has been stopped. * * @api */ @@ -601,10 +593,9 @@ msg_t spiIgnore(SPIDriver *spip, size_t n) { * @param[in] txbuf the pointer to the transmit buffer * @param[out] rxbuf the pointer to the receive buffer * @return The operation status. - * @retval MSG_SPI_COMPLETE if operation completed without errors. - * mode only). - * @retval MSG_SPI_TIMEOUT if synchronization timed out. - * @retval MSG_SPI_STOPPED if the transfer has been stopped. + * @retval MSG_OK if operation completed without errors. + * @retval MSG_TIMEOUT if synchronization timed out. + * @retval MSG_RESET if the transfer has been stopped. * * @api */ @@ -636,9 +627,9 @@ msg_t spiExchange(SPIDriver *spip, size_t n, * @param[in] n number of words to send * @param[in] txbuf the pointer to the transmit buffer * @return The operation status. - * @retval MSG_SPI_COMPLETE if operation completed without errors. - * @retval MSG_SPI_TIMEOUT if synchronization timed out. - * @retval MSG_SPI_STOPPED if the transfer has been stopped. + * @retval MSG_OK if operation completed without errors. + * @retval MSG_TIMEOUT if synchronization timed out. + * @retval MSG_RESET if the transfer has been stopped. * * @api */ @@ -669,9 +660,9 @@ msg_t spiSend(SPIDriver *spip, size_t n, const void *txbuf) { * @param[in] n number of words to receive * @param[out] rxbuf the pointer to the receive buffer * @return The operation status. - * @retval MSG_SPI_COMPLETE if operation completed without errors. - * @retval MSG_SPI_TIMEOUT if synchronization timed out. - * @retval MSG_SPI_STOPPED if the transfer has been stopped. + * @retval MSG_OK if operation completed without errors. + * @retval MSG_TIMEOUT if synchronization timed out. + * @retval MSG_RESET if the transfer has been stopped. * * @api */