aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/include/dac.h
diff options
context:
space:
mode:
Diffstat (limited to 'os/hal/include/dac.h')
-rw-r--r--os/hal/include/dac.h55
1 files changed, 11 insertions, 44 deletions
diff --git a/os/hal/include/dac.h b/os/hal/include/dac.h
index fc0a09d4c..3d1157ae0 100644
--- a/os/hal/include/dac.h
+++ b/os/hal/include/dac.h
@@ -1,6 +1,6 @@
/*
ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010,
- 2011,2012 Giovanni Di Sirio.
+ 2011,2012,2013 Giovanni Di Sirio.
This file is part of ChibiOS/RT.
@@ -64,10 +64,6 @@
/* Derived constants and error checks. */
/*===========================================================================*/
-#if DAC_USE_MUTUAL_EXCLUSION && !CH_USE_MUTEXES && !CH_USE_SEMAPHORES
-#error "DAC_USE_MUTUAL_EXCLUSION requires CH_USE_MUTEXES and/or CH_USE_SEMAPHORES"
-#endif
-
/*===========================================================================*/
/* Driver data structures and types. */
/*===========================================================================*/
@@ -107,12 +103,8 @@ typedef enum {
*
* @notapi
*/
-#define _dac_wait_s(dacp) { \
- chDbgAssert((dacp)->thread == NULL, \
- "_dac_wait_s(), #1", "already waiting"); \
- (dacp)->thread = chThdSelf(); \
- chSchGoSleepS(THD_STATE_SUSPENDED); \
-}
+#define _dac_wait_s(dacp) osalThreadSuspendS(&(dacp)->thread)
+
/**
* @brief Resumes a thread waiting for a conversion completion.
*
@@ -120,14 +112,7 @@ typedef enum {
*
* @notapi
*/
-#define _dac_reset_i(dacp) { \
- if ((dacp)->thread != NULL) { \
- Thread *tp = (dacp)->thread; \
- (dacp)->thread = NULL; \
- tp->p_u.rdymsg = RDY_RESET; \
- chSchReadyI(tp); \
- } \
-}
+#define _dac_reset_i(dacp) osalThreadResumeI(&(dacp)->thread, MSG_RESET)
/**
* @brief Resumes a thread waiting for a conversion completion.
@@ -136,13 +121,7 @@ typedef enum {
*
* @notapi
*/
-#define _dac_reset_s(dacp) { \
- if ((dacp)->thread != NULL) { \
- Thread *tp = (dacp)->thread; \
- (dacp)->thread = NULL; \
- chSchWakeupS(tp, RDY_RESET); \
- } \
-}
+#define _dac_reset_s(dacp) osalThreadResumeS(&(dacp)->thread, MSG_RESET)
/**
* @brief Wakes up the waiting thread.
@@ -152,15 +131,9 @@ typedef enum {
* @notapi
*/
#define _dac_wakeup_isr(dacp) { \
- chSysLockFromIsr(); \
- if ((dacp)->thread != NULL) { \
- Thread *tp; \
- tp = (dacp)->thread; \
- (dacp)->thread = NULL; \
- tp->p_u.rdymsg = RDY_OK; \
- chSchReadyI(tp); \
- } \
- chSysUnlockFromIsr(); \
+ osalSysLockFromISR(); \
+ osalThreadResumeI(&(dacp)->thread, MSG_OK); \
+ osalSysUnlockFromISR(); \
}
/**
@@ -171,15 +144,9 @@ typedef enum {
* @notapi
*/
#define _dac_timeout_isr(dacp) { \
- chSysLockFromIsr(); \
- if ((dacp)->thread != NULL) { \
- Thread *tp; \
- tp = (dacp)->thread; \
- (dacp)->thread = NULL; \
- tp->p_u.rdymsg = RDY_TIMEOUT; \
- chSchReadyI(tp); \
- } \
- chSysUnlockFromIsr(); \
+ osalSysLockFromISR(); \
+ osalThreadResumeI(&(dacp)->thread, MSG_TIMEOUT); \
+ osalSysUnlockFromISR(); \
}
#else /* !DAC_USE_WAIT */