aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/include
diff options
context:
space:
mode:
Diffstat (limited to 'os/hal/include')
-rw-r--r--os/hal/include/adc.h16
-rw-r--r--os/hal/include/spi.h19
2 files changed, 14 insertions, 21 deletions
diff --git a/os/hal/include/adc.h b/os/hal/include/adc.h
index 48f9d9ff6..0b55d0d15 100644
--- a/os/hal/include/adc.h
+++ b/os/hal/include/adc.h
@@ -122,22 +122,21 @@ typedef enum {
*
* @notapi
*/
-#define _adc_wakeup_i(adcp) { \
- chSysLockFromIsr(); \
- (adcp)->ad_grpp = NULL; \
+#define _adc_wakeup_isr(adcp) { \
if ((adcp)->ad_thread != NULL) { \
Thread *tp = (adcp)->ad_thread; \
(adcp)->ad_thread = NULL; \
+ chSysLockFromIsr(); \
tp->p_u.rdymsg = RDY_OK; \
chSchReadyI(tp); \
+ chSysUnlockFromIsr(); \
} \
- chSysUnlockFromIsr(); \
}
#else /* !ADC_USE_WAIT */
#define _adc_reset_i(adcp)
#define _adc_reset_s(adcp)
-#define _adc_wakeup(adcp)
+#define _adc_wakeup_isr(adcp)
#endif /* !ADC_USE_WAIT */
/**
@@ -192,11 +191,7 @@ typedef enum {
else { \
/* End conversion.*/ \
adc_lld_stop_conversion(adcp); \
- if ((adcp)->ad_grpp->acg_endcb == NULL) { \
- (adcp)->ad_state = ADC_READY; \
- _adc_wakeup_i(adcp); \
- } \
- else { \
+ if ((adcp)->ad_grpp->acg_endcb != NULL) { \
(adcp)->ad_state = ADC_COMPLETE; \
if ((adcp)->ad_depth > 1) { \
/* Invokes the callback passing the 2nd half of the buffer.*/ \
@@ -212,6 +207,7 @@ typedef enum {
(adcp)->ad_state = ADC_READY; \
} \
(adcp)->ad_grpp = NULL; \
+ _adc_wakeup_isr(adcp); \
} \
}
diff --git a/os/hal/include/spi.h b/os/hal/include/spi.h
index 93aba4980..a563b262c 100644
--- a/os/hal/include/spi.h
+++ b/os/hal/include/spi.h
@@ -214,7 +214,7 @@ typedef enum {
*
* @notapi
*/
-#define _spi_wait(spip) { \
+#define _spi_wait_s(spip) { \
chDbgAssert((spip)->spd_thread == NULL, \
"_spi_wait(), #1", "already waiting"); \
(spip)->spd_thread = chThdSelf(); \
@@ -228,18 +228,18 @@ typedef enum {
*
* @notapi
*/
-#define _spi_wakeup(spip) { \
- chSysLockFromIsr(); \
+#define _spi_wakeup_isr(spip) { \
if ((spip)->spd_thread != NULL) { \
Thread *tp = (spip)->spd_thread; \
(spip)->spd_thread = NULL; \
+ chSysLockFromIsr(); \
chSchReadyI(tp); \
+ chSysUnlockFromIsr(); \
} \
- chSysUnlockFromIsr(); \
}
#else /* !SPI_USE_WAIT */
-#define _spi_wakeup(spip)
-#define _spi_wait(spip)
+#define _spi_wait_s(spip)
+#define _spi_wakeup_isr(spip)
#endif /* !SPI_USE_WAIT */
/**
@@ -261,11 +261,8 @@ typedef enum {
(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; \
- _spi_wakeup(spip); \
+ (spip)->spd_state = SPI_READY; \
+ _spi_wakeup_isr(spip); \
} \
}