aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/include
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2011-09-22 14:53:42 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2011-09-22 14:53:42 +0000
commit4a3e3fc01ec6dfb4a710db771bee262d5dc9327e (patch)
treee1ff2640c6b25bf93b3d461ff867ce3353a62424 /os/hal/include
parent40c7a8982aaef28d6ac7cbbd378708f237711ccf (diff)
downloadChibiOS-4a3e3fc01ec6dfb4a710db771bee262d5dc9327e.tar.gz
ChibiOS-4a3e3fc01ec6dfb4a710db771bee262d5dc9327e.tar.bz2
ChibiOS-4a3e3fc01ec6dfb4a710db771bee262d5dc9327e.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3381 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/include')
-rw-r--r--os/hal/include/adc.h49
1 files changed, 48 insertions, 1 deletions
diff --git a/os/hal/include/adc.h b/os/hal/include/adc.h
index 53c7c199a..cb392f4e2 100644
--- a/os/hal/include/adc.h
+++ b/os/hal/include/adc.h
@@ -80,7 +80,8 @@ typedef enum {
ADC_STOP = 1, /**< Stopped. */
ADC_READY = 2, /**< Ready. */
ADC_ACTIVE = 3, /**< Converting. */
- ADC_COMPLETE = 4 /**< Conversion complete. */
+ ADC_COMPLETE = 4, /**< Conversion complete. */
+ ADC_ERROR = 5 /**< Conversion complete. */
} adcstate_t;
#include "adc_lld.h"
@@ -144,10 +145,30 @@ typedef enum {
} \
}
+/**
+ * @brief Wakes up the waiting thread with a timeout message.
+ *
+ * @param[in] adcp pointer to the @p ADCDriver object
+ *
+ * @notapi
+ */
+#define _adc_timeout_isr(adcp) { \
+ if ((adcp)->thread != NULL) { \
+ Thread *tp; \
+ chSysLockFromIsr(); \
+ tp = (adcp)->thread; \
+ (adcp)->thread = NULL; \
+ tp->p_u.rdymsg = RDY_TIMEOUT; \
+ chSchReadyI(tp); \
+ chSysUnlockFromIsr(); \
+ } \
+}
+
#else /* !ADC_USE_WAIT */
#define _adc_reset_i(adcp)
#define _adc_reset_s(adcp)
#define _adc_wakeup_isr(adcp)
+#define _adc_timeout_isr(adcp)
#endif /* !ADC_USE_WAIT */
/**
@@ -220,6 +241,32 @@ typedef enum {
_adc_wakeup_isr(adcp); \
} \
}
+
+/**
+ * @brief Common ISR code, error event.
+ * @details This code handles the portable part of the ISR code:
+ * - Callback invocation.
+ * - Waiting thread timeout signaling, if any.
+ * - Driver state transitions.
+ * .
+ * @note This macro is meant to be used in the low level drivers
+ * implementation only.
+ *
+ * @param[in] adcp pointer to the @p ADCDriver object
+ *
+ * @notapi
+ */
+#define _adc_isr_error_code(adcp, err) { \
+ adc_lld_stop_conversion(adcp); \
+ if ((adcp)->grpp->error_cb != NULL) { \
+ (adcp)->state = ADC_ERROR; \
+ (adcp)->grpp->error_cb(adcp, err); \
+ if ((adcp)->state == ADC_ERROR) \
+ (adcp)->state = ADC_READY; \
+ } \
+ (adcp)->grpp = NULL; \
+ _adc_timeout_isr(adcp); \
+}
/** @} */
/*===========================================================================*/