From f49c8de5b2d1a4e35bef8daa2a923f751d6e17b3 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 12 Oct 2010 19:25:00 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2252 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/include/spi.h | 73 ++++++++++++++++++++++++++-------------------------- 1 file changed, 37 insertions(+), 36 deletions(-) (limited to 'os/hal/include') diff --git a/os/hal/include/spi.h b/os/hal/include/spi.h index fbd26c207..ed8ba8de0 100644 --- a/os/hal/include/spi.h +++ b/os/hal/include/spi.h @@ -187,39 +187,6 @@ typedef enum { } #if SPI_USE_WAIT || defined(__DOXYGEN__) -/** - * @brief Common ISR code. - * @details This code handles the portable part of the ISR code: - * - Callback invocation. - * - Waiting thread wakeup, if any. - * - 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(spip) { \ - if (spip->spd_config->spc_endcb) { \ - spip->spd_state = SPI_COMPLETE; \ - spip->spd_config->spc_endcb(spip); \ - if (spip->spd_state == SPI_COMPLETE) \ - spip->spd_state = SPI_READY; \ - } \ - else { \ - spip->spd_state = SPI_READY; \ - chSysLockFromIsr(); \ - if ((spip)->spd_thread != NULL) { \ - Thread *tp = (spip)->spd_thread; \ - (spip)->spd_thread = NULL; \ - chSchReadyI(tp); \ - } \ - chSysUnlockFromIsr(); \ - } \ -} - /** * @brief Waits for operation completion. * @details This function waits for the driver to complete the current @@ -238,8 +205,42 @@ typedef enum { (spip)->spd_thread = chThdSelf(); \ chSchGoSleepS(THD_STATE_SUSPENDED); \ } + +/** + * @brief Wakes up the waiting thread. + * + * @param[in] spip pointer to the @p SPIDriver object + * + * @notapi + */ +#define _spi_wakeup(spip) { \ + chSysLockFromIsr(); \ + if ((spip)->spd_thread != NULL) { \ + Thread *tp = (spip)->spd_thread; \ + (spip)->spd_thread = NULL; \ + chSchReadyI(tp); \ + } \ + chSysUnlockFromIsr(); \ +} #else /* !SPI_USE_WAIT */ +#define _spi_wakeup(spip) +#define _spi_wait(spip) +#endif /* !SPI_USE_WAIT */ +/** + * @brief Common ISR code. + * @details This code handles the portable part of the ISR code: + * - Callback invocation. + * - Waiting thread wakeup, if any. + * - 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(spip) { \ if (spip->spd_config->spc_endcb) { \ spip->spd_state = SPI_COMPLETE; \ @@ -247,12 +248,12 @@ typedef enum { if (spip->spd_state == SPI_COMPLETE) \ spip->spd_state = SPI_READY; \ } \ - else \ + else { \ spip->spd_state = SPI_READY; \ + _spi_wakeup(spip); \ + } \ } -#endif /* !SPI_USE_WAIT */ - /*===========================================================================*/ /* External declarations. */ /*===========================================================================*/ -- cgit v1.2.3