aboutsummaryrefslogtreecommitdiffstats
path: root/os
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2009-11-28 20:09:14 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2009-11-28 20:09:14 +0000
commit2f43c85736e70a59c0b3675d01d4ddc521223263 (patch)
tree312060e283988e77427e6ca7a2527f8d99df1701 /os
parenteb2bcc41f222ebb876e25eec3642dce3cdf0236e (diff)
downloadChibiOS-2f43c85736e70a59c0b3675d01d4ddc521223263.tar.gz
ChibiOS-2f43c85736e70a59c0b3675d01d4ddc521223263.tar.bz2
ChibiOS-2f43c85736e70a59c0b3675d01d4ddc521223263.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1339 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os')
-rw-r--r--os/hal/include/adc.h3
-rw-r--r--os/hal/platforms/STM32/adc_lld.c2
-rw-r--r--os/hal/src/adc.c17
3 files changed, 15 insertions, 7 deletions
diff --git a/os/hal/include/adc.h b/os/hal/include/adc.h
index af08502a8..67ebf5ca2 100644
--- a/os/hal/include/adc.h
+++ b/os/hal/include/adc.h
@@ -40,7 +40,8 @@ typedef enum {
ADC_UNINIT = 0, /**< @brief Not initialized. */
ADC_STOP = 1, /**< @brief Stopped. */
ADC_READY = 2, /**< @brief Ready. */
- ADC_RUNNING = 3 /**< @brief Conversion running. */
+ ADC_RUNNING = 3, /**< @brief Conversion running. */
+ ADC_COMPLETE = 4 /**< @brief Conversion complete.*/
} adcstate_t;
#include "adc_lld.h"
diff --git a/os/hal/platforms/STM32/adc_lld.c b/os/hal/platforms/STM32/adc_lld.c
index 2562988f5..abfdb0a43 100644
--- a/os/hal/platforms/STM32/adc_lld.c
+++ b/os/hal/platforms/STM32/adc_lld.c
@@ -75,7 +75,7 @@ CH_IRQ_HANDLER(Vector6C) {
/* End conversion.*/
adc_lld_stop_conversion(&ADCD1);
ADCD1.ad_grpp = NULL;
- ADCD1.ad_state = ADC_READY;
+ ADCD1.ad_state = ADC_COMPLETE;
chSysLockFromIsr();
chSemResetI(&ADCD1.ad_sem, 0);
chSysUnlockFromIsr();
diff --git a/os/hal/src/adc.c b/os/hal/src/adc.c
index 5a041f056..c074c0224 100644
--- a/os/hal/src/adc.c
+++ b/os/hal/src/adc.c
@@ -134,7 +134,8 @@ bool_t adcStartConversion(ADCDriver *adcp,
chSysLock();
chDbgAssert((adcp->ad_state == ADC_READY) ||
- (adcp->ad_state == ADC_RUNNING),
+ (adcp->ad_state == ADC_RUNNING) ||
+ (adcp->ad_state == ADC_COMPLETE),
"adcStartConversion(), #1",
"invalid state");
if (adcp->ad_state == ADC_RUNNING) {
@@ -162,7 +163,8 @@ void adcStopConversion(ADCDriver *adcp) {
chSysLock();
chDbgAssert((adcp->ad_state == ADC_READY) ||
- (adcp->ad_state == ADC_RUNNING),
+ (adcp->ad_state == ADC_RUNNING) ||
+ (adcp->ad_state == ADC_COMPLETE),
"adcStopConversion(), #1",
"invalid state");
if (adcp->ad_state == ADC_RUNNING) {
@@ -172,11 +174,15 @@ void adcStopConversion(ADCDriver *adcp) {
chSemResetI(&adcp->ad_sem, 0);
chSchRescheduleS();
}
+ else
+ adcp->ad_state = ADC_READY;
chSysUnlock();
}
/**
* @brief Waits for completion.
+ * @details If the conversion is not completed or not yet started then the
+ * invoking thread waits for a conversion completion event.
*
* @param[in] adcp pointer to the @p ADCDriver object
* @param[in] timeout the number of ticks before the operation timeouts,
@@ -185,17 +191,18 @@ void adcStopConversion(ADCDriver *adcp) {
* - @a TIME_INFINITE no timeout.
* .
* @return The operation result.
- * @retval RDY_OK conversion finished (or not started).
+ * @retval RDY_OK conversion finished.
* @retval RDY_TIMEOUT conversion not finished within the specified time.
*/
msg_t adcWaitConversion(ADCDriver *adcp, systime_t timeout) {
chSysLock();
chDbgAssert((adcp->ad_state == ADC_READY) ||
- (adcp->ad_state == ADC_RUNNING),
+ (adcp->ad_state == ADC_RUNNING) ||
+ (adcp->ad_state == ADC_COMPLETE),
"adcWaitConversion(), #1",
"invalid state");
- if (adcp->ad_state == ADC_RUNNING) {
+ if (adcp->ad_state != ADC_COMPLETE) {
if (chSemWaitTimeoutS(&adcp->ad_sem, timeout) == RDY_TIMEOUT) {
chSysUnlock();
return RDY_TIMEOUT;