aboutsummaryrefslogtreecommitdiffstats
path: root/os
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2010-09-11 10:57:11 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2010-09-11 10:57:11 +0000
commit781b0b129cccbecba160effce8c4ddd68295b8b9 (patch)
tree4e32a7b8c14e9eb808e1ae305fcbbff76074de48 /os
parentd51840a0c799be3b684c5b379f4015475096b6b1 (diff)
downloadChibiOS-781b0b129cccbecba160effce8c4ddd68295b8b9.tar.gz
ChibiOS-781b0b129cccbecba160effce8c4ddd68295b8b9.tar.bz2
ChibiOS-781b0b129cccbecba160effce8c4ddd68295b8b9.zip
Fixed bug 3064204.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2175 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os')
-rw-r--r--os/hal/include/adc.h13
-rw-r--r--os/hal/include/can.h2
-rw-r--r--os/hal/platforms/STM32/adc_lld.c2
-rw-r--r--os/hal/platforms/STM32/adc_lld.h10
-rw-r--r--os/hal/src/adc.c8
-rw-r--r--os/hal/templates/adc_lld.h10
6 files changed, 35 insertions, 10 deletions
diff --git a/os/hal/include/adc.h b/os/hal/include/adc.h
index 8b1bfd47b..8a2af908e 100644
--- a/os/hal/include/adc.h
+++ b/os/hal/include/adc.h
@@ -38,12 +38,19 @@
/* Driver pre-compile time settings. */
/*===========================================================================*/
+/**
+ * @brief Inclusion of the @p adcWaitConversion() function.
+ */
+#if !defined(ADC_USE_WAIT) || defined(__DOXYGEN__)
+#define ADC_USE_WAIT TRUE
+#endif
+
/*===========================================================================*/
/* Derived constants and error checks. */
/*===========================================================================*/
-#if !CH_USE_SEMAPHORES
-#error "ADC driver requires CH_USE_SEMAPHORES"
+#if ADC_USE_WAIT && !CH_USE_SEMAPHORES
+#error "ADC driver requires CH_USE_SEMAPHORES when ADC_USE_WAIT is enabled"
#endif
/*===========================================================================*/
@@ -90,7 +97,9 @@ extern "C" {
adccallback_t callback);
void adcStopConversion(ADCDriver *adcp);
void adcStopConversionI(ADCDriver *adcp);
+#if ADC_USE_WAIT
msg_t adcWaitConversion(ADCDriver *adcp, systime_t timeout);
+#endif
#ifdef __cplusplus
}
#endif
diff --git a/os/hal/include/can.h b/os/hal/include/can.h
index b503dd8e3..4a40fb952 100644
--- a/os/hal/include/can.h
+++ b/os/hal/include/can.h
@@ -62,7 +62,9 @@
/**
* @brief Sleep mode related APIs inclusion switch.
*/
+#if !defined(CAN_USE_SLEEP_MODE) || defined(__DOXYGEN__)
#define CAN_USE_SLEEP_MODE TRUE
+#endif
/*===========================================================================*/
/* Derived constants and error checks. */
diff --git a/os/hal/platforms/STM32/adc_lld.c b/os/hal/platforms/STM32/adc_lld.c
index 9a506d150..fa748aa84 100644
--- a/os/hal/platforms/STM32/adc_lld.c
+++ b/os/hal/platforms/STM32/adc_lld.c
@@ -76,9 +76,11 @@ CH_IRQ_HANDLER(DMA1_Ch1_IRQHandler) {
adc_lld_stop_conversion(&ADCD1);
ADCD1.ad_grpp = NULL;
ADCD1.ad_state = ADC_COMPLETE;
+#if ADC_USE_WAIT
chSysLockFromIsr();
chSemResetI(&ADCD1.ad_sem, 0);
chSysUnlockFromIsr();
+#endif
}
/* Callback handling.*/
if (ADCD1.ad_callback != NULL) {
diff --git a/os/hal/platforms/STM32/adc_lld.h b/os/hal/platforms/STM32/adc_lld.h
index 2a91c9b4d..7fe219706 100644
--- a/os/hal/platforms/STM32/adc_lld.h
+++ b/os/hal/platforms/STM32/adc_lld.h
@@ -195,10 +195,6 @@ typedef struct {
*/
const ADCConfig *ad_config;
/**
- * @brief Synchronization semaphore.
- */
- Semaphore ad_sem;
- /**
* @brief Current callback function or @p NULL.
*/
adccallback_t ad_callback;
@@ -214,6 +210,12 @@ typedef struct {
* @brief Current conversion group pointer or @p NULL.
*/
const ADCConversionGroup *ad_grpp;
+#if ADC_USE_WAIT
+ /**
+ * @brief Synchronization semaphore.
+ */
+ Semaphore ad_sem;
+#endif
/* End of the mandatory fields.*/
/**
* @brief Pointer to the ADCx registers block.
diff --git a/os/hal/src/adc.c b/os/hal/src/adc.c
index 23b096f3e..df8b05fd5 100644
--- a/os/hal/src/adc.c
+++ b/os/hal/src/adc.c
@@ -67,7 +67,9 @@ void adcObjectInit(ADCDriver *adcp) {
adcp->ad_samples = NULL;
adcp->ad_depth = 0;
adcp->ad_grpp = NULL;
+#if ADC_USE_WAIT
chSemInit(&adcp->ad_sem, 0);
+#endif
}
/**
@@ -229,8 +231,10 @@ void adcStopConversion(ADCDriver *adcp) {
adc_lld_stop_conversion(adcp);
adcp->ad_grpp = NULL;
adcp->ad_state = ADC_READY;
+#if ADC_USE_WAIT
chSemResetI(&adcp->ad_sem, 0);
chSchRescheduleS();
+#endif
}
else
adcp->ad_state = ADC_READY;
@@ -258,12 +262,15 @@ void adcStopConversionI(ADCDriver *adcp) {
adc_lld_stop_conversion(adcp);
adcp->ad_grpp = NULL;
adcp->ad_state = ADC_READY;
+#if ADC_USE_WAIT
chSemResetI(&adcp->ad_sem, 0);
+#endif
}
else
adcp->ad_state = ADC_READY;
}
+#if ADC_USE_WAIT || defined(__DOXYGEN__)
/**
* @brief Waits for completion.
* @details If the conversion is not completed or not yet started then the
@@ -296,6 +303,7 @@ msg_t adcWaitConversion(ADCDriver *adcp, systime_t timeout) {
chSysUnlock();
return RDY_OK;
}
+#endif /* ADC_USE_WAIT */
#endif /* CH_HAL_USE_ADC */
diff --git a/os/hal/templates/adc_lld.h b/os/hal/templates/adc_lld.h
index d969b24e0..6486abb37 100644
--- a/os/hal/templates/adc_lld.h
+++ b/os/hal/templates/adc_lld.h
@@ -112,10 +112,6 @@ typedef struct {
*/
const ADCConfig *ad_config;
/**
- * @brief Synchronization semaphore.
- */
- Semaphore ad_sem;
- /**
* @brief Current callback function or @p NULL.
*/
adccallback_t ad_callback;
@@ -131,6 +127,12 @@ typedef struct {
* @brief Current conversion group pointer or @p NULL.
*/
const ADCConversionGroup *ad_grpp;
+#if ADC_USE_WAIT
+ /**
+ * @brief Synchronization semaphore.
+ */
+ Semaphore ad_sem;
+#endif
/* End of the mandatory fields.*/
} ADCDriver;