From 781b0b129cccbecba160effce8c4ddd68295b8b9 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 11 Sep 2010 10:57:11 +0000 Subject: [PATCH] Fixed bug 3064204. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2175 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/ARM7-AT91SAM7S-FATFS-GCC/halconf.h | 10 ++++++++++ demos/ARM7-AT91SAM7S-GCC/halconf.h | 10 ++++++++++ demos/ARM7-AT91SAM7X-FATFS-GCC/halconf.h | 10 ++++++++++ demos/ARM7-AT91SAM7X-GCC/halconf.h | 10 ++++++++++ demos/ARM7-AT91SAM7X-LWIP-GCC/halconf.h | 10 ++++++++++ demos/ARM7-AT91SAM7X-UIP-GCC/halconf.h | 10 ++++++++++ demos/ARM7-LPC214x-FATFS-GCC/halconf.h | 10 ++++++++++ demos/ARM7-LPC214x-G++/halconf.h | 10 ++++++++++ demos/ARM7-LPC214x-GCC/halconf.h | 10 ++++++++++ demos/ARMCM0-LPC1114-GCC/halconf.h | 10 ++++++++++ demos/ARMCM3-LPC1343-GCC/halconf.h | 10 ++++++++++ demos/ARMCM3-STM32F103-FATFS-GCC/halconf.h | 10 ++++++++++ demos/ARMCM3-STM32F107-GCC/halconf.h | 10 ++++++++++ demos/AVR-AT90CANx-GCC/halconf.h | 10 ++++++++++ demos/AVR-ATmega128-GCC/halconf.h | 10 ++++++++++ demos/MSP430-MSP430x1611-GCC/halconf.h | 10 ++++++++++ demos/PPC-SPC563-GCC/halconf.h | 10 ++++++++++ demos/Posix-GCC/halconf.h | 10 ++++++++++ demos/STM8S-STM8S105-DISCOVERY-STVD/demo/halconf.h | 10 ++++++++++ demos/STM8S-STM8S208-RC/halconf.h | 10 ++++++++++ demos/Win32-MinGW/halconf.h | 10 ++++++++++ os/hal/include/adc.h | 13 +++++++++++-- os/hal/include/can.h | 2 ++ os/hal/platforms/STM32/adc_lld.c | 2 ++ os/hal/platforms/STM32/adc_lld.h | 10 ++++++---- os/hal/src/adc.c | 8 ++++++++ os/hal/templates/adc_lld.h | 10 ++++++---- readme.txt | 4 +++- test/coverage/halconf.h | 10 ++++++++++ testhal/STM32/ADC/halconf.h | 10 ++++++++++ testhal/STM32/CAN/halconf.h | 10 ++++++++++ testhal/STM32/PWM/halconf.h | 10 ++++++++++ testhal/STM32/SPI/halconf.h | 10 ++++++++++ testhal/STM32/UART/halconf.h | 10 ++++++++++ testhal/STM32/_stess_test/halconf.h | 10 ++++++++++ 35 files changed, 318 insertions(+), 11 deletions(-) diff --git a/demos/ARM7-AT91SAM7S-FATFS-GCC/halconf.h b/demos/ARM7-AT91SAM7S-FATFS-GCC/halconf.h index c941995ee..c65522e3a 100644 --- a/demos/ARM7-AT91SAM7S-FATFS-GCC/halconf.h +++ b/demos/ARM7-AT91SAM7S-FATFS-GCC/halconf.h @@ -62,6 +62,11 @@ #define CH_HAL_USE_ADC FALSE #endif +/* + * Default ADC settings overrides (uncomment to override). + */ +/*#define ADC_USE_WAIT TRUE*/ + /*===========================================================================*/ /* CAN driver related settings. */ /*===========================================================================*/ @@ -73,6 +78,11 @@ #define CH_HAL_USE_CAN FALSE #endif +/* + * Default CAN settings overrides (uncomment to override). + */ +/*#define CAN_USE_SLEEP_MODE TRUE*/ + /*===========================================================================*/ /* MAC driver related settings. */ /*===========================================================================*/ diff --git a/demos/ARM7-AT91SAM7S-GCC/halconf.h b/demos/ARM7-AT91SAM7S-GCC/halconf.h index a9d7369b9..87d0f835d 100644 --- a/demos/ARM7-AT91SAM7S-GCC/halconf.h +++ b/demos/ARM7-AT91SAM7S-GCC/halconf.h @@ -62,6 +62,11 @@ #define CH_HAL_USE_ADC FALSE #endif +/* + * Default ADC settings overrides (uncomment to override). + */ +/*#define ADC_USE_WAIT TRUE*/ + /*===========================================================================*/ /* CAN driver related settings. */ /*===========================================================================*/ @@ -73,6 +78,11 @@ #define CH_HAL_USE_CAN FALSE #endif +/* + * Default CAN settings overrides (uncomment to override). + */ +/*#define CAN_USE_SLEEP_MODE TRUE*/ + /*===========================================================================*/ /* MAC driver related settings. */ /*===========================================================================*/ diff --git a/demos/ARM7-AT91SAM7X-FATFS-GCC/halconf.h b/demos/ARM7-AT91SAM7X-FATFS-GCC/halconf.h index c941995ee..c65522e3a 100644 --- a/demos/ARM7-AT91SAM7X-FATFS-GCC/halconf.h +++ b/demos/ARM7-AT91SAM7X-FATFS-GCC/halconf.h @@ -62,6 +62,11 @@ #define CH_HAL_USE_ADC FALSE #endif +/* + * Default ADC settings overrides (uncomment to override). + */ +/*#define ADC_USE_WAIT TRUE*/ + /*===========================================================================*/ /* CAN driver related settings. */ /*===========================================================================*/ @@ -73,6 +78,11 @@ #define CH_HAL_USE_CAN FALSE #endif +/* + * Default CAN settings overrides (uncomment to override). + */ +/*#define CAN_USE_SLEEP_MODE TRUE*/ + /*===========================================================================*/ /* MAC driver related settings. */ /*===========================================================================*/ diff --git a/demos/ARM7-AT91SAM7X-GCC/halconf.h b/demos/ARM7-AT91SAM7X-GCC/halconf.h index a9d7369b9..87d0f835d 100644 --- a/demos/ARM7-AT91SAM7X-GCC/halconf.h +++ b/demos/ARM7-AT91SAM7X-GCC/halconf.h @@ -62,6 +62,11 @@ #define CH_HAL_USE_ADC FALSE #endif +/* + * Default ADC settings overrides (uncomment to override). + */ +/*#define ADC_USE_WAIT TRUE*/ + /*===========================================================================*/ /* CAN driver related settings. */ /*===========================================================================*/ @@ -73,6 +78,11 @@ #define CH_HAL_USE_CAN FALSE #endif +/* + * Default CAN settings overrides (uncomment to override). + */ +/*#define CAN_USE_SLEEP_MODE TRUE*/ + /*===========================================================================*/ /* MAC driver related settings. */ /*===========================================================================*/ diff --git a/demos/ARM7-AT91SAM7X-LWIP-GCC/halconf.h b/demos/ARM7-AT91SAM7X-LWIP-GCC/halconf.h index ab1b7677c..0fdc6cf1c 100644 --- a/demos/ARM7-AT91SAM7X-LWIP-GCC/halconf.h +++ b/demos/ARM7-AT91SAM7X-LWIP-GCC/halconf.h @@ -62,6 +62,11 @@ #define CH_HAL_USE_ADC FALSE #endif +/* + * Default ADC settings overrides (uncomment to override). + */ +/*#define ADC_USE_WAIT TRUE*/ + /*===========================================================================*/ /* CAN driver related settings. */ /*===========================================================================*/ @@ -73,6 +78,11 @@ #define CH_HAL_USE_CAN FALSE #endif +/* + * Default CAN settings overrides (uncomment to override). + */ +/*#define CAN_USE_SLEEP_MODE TRUE*/ + /*===========================================================================*/ /* MAC driver related settings. */ /*===========================================================================*/ diff --git a/demos/ARM7-AT91SAM7X-UIP-GCC/halconf.h b/demos/ARM7-AT91SAM7X-UIP-GCC/halconf.h index ab1b7677c..0fdc6cf1c 100644 --- a/demos/ARM7-AT91SAM7X-UIP-GCC/halconf.h +++ b/demos/ARM7-AT91SAM7X-UIP-GCC/halconf.h @@ -62,6 +62,11 @@ #define CH_HAL_USE_ADC FALSE #endif +/* + * Default ADC settings overrides (uncomment to override). + */ +/*#define ADC_USE_WAIT TRUE*/ + /*===========================================================================*/ /* CAN driver related settings. */ /*===========================================================================*/ @@ -73,6 +78,11 @@ #define CH_HAL_USE_CAN FALSE #endif +/* + * Default CAN settings overrides (uncomment to override). + */ +/*#define CAN_USE_SLEEP_MODE TRUE*/ + /*===========================================================================*/ /* MAC driver related settings. */ /*===========================================================================*/ diff --git a/demos/ARM7-LPC214x-FATFS-GCC/halconf.h b/demos/ARM7-LPC214x-FATFS-GCC/halconf.h index c941995ee..c65522e3a 100644 --- a/demos/ARM7-LPC214x-FATFS-GCC/halconf.h +++ b/demos/ARM7-LPC214x-FATFS-GCC/halconf.h @@ -62,6 +62,11 @@ #define CH_HAL_USE_ADC FALSE #endif +/* + * Default ADC settings overrides (uncomment to override). + */ +/*#define ADC_USE_WAIT TRUE*/ + /*===========================================================================*/ /* CAN driver related settings. */ /*===========================================================================*/ @@ -73,6 +78,11 @@ #define CH_HAL_USE_CAN FALSE #endif +/* + * Default CAN settings overrides (uncomment to override). + */ +/*#define CAN_USE_SLEEP_MODE TRUE*/ + /*===========================================================================*/ /* MAC driver related settings. */ /*===========================================================================*/ diff --git a/demos/ARM7-LPC214x-G++/halconf.h b/demos/ARM7-LPC214x-G++/halconf.h index a9d7369b9..87d0f835d 100644 --- a/demos/ARM7-LPC214x-G++/halconf.h +++ b/demos/ARM7-LPC214x-G++/halconf.h @@ -62,6 +62,11 @@ #define CH_HAL_USE_ADC FALSE #endif +/* + * Default ADC settings overrides (uncomment to override). + */ +/*#define ADC_USE_WAIT TRUE*/ + /*===========================================================================*/ /* CAN driver related settings. */ /*===========================================================================*/ @@ -73,6 +78,11 @@ #define CH_HAL_USE_CAN FALSE #endif +/* + * Default CAN settings overrides (uncomment to override). + */ +/*#define CAN_USE_SLEEP_MODE TRUE*/ + /*===========================================================================*/ /* MAC driver related settings. */ /*===========================================================================*/ diff --git a/demos/ARM7-LPC214x-GCC/halconf.h b/demos/ARM7-LPC214x-GCC/halconf.h index a9d7369b9..87d0f835d 100644 --- a/demos/ARM7-LPC214x-GCC/halconf.h +++ b/demos/ARM7-LPC214x-GCC/halconf.h @@ -62,6 +62,11 @@ #define CH_HAL_USE_ADC FALSE #endif +/* + * Default ADC settings overrides (uncomment to override). + */ +/*#define ADC_USE_WAIT TRUE*/ + /*===========================================================================*/ /* CAN driver related settings. */ /*===========================================================================*/ @@ -73,6 +78,11 @@ #define CH_HAL_USE_CAN FALSE #endif +/* + * Default CAN settings overrides (uncomment to override). + */ +/*#define CAN_USE_SLEEP_MODE TRUE*/ + /*===========================================================================*/ /* MAC driver related settings. */ /*===========================================================================*/ diff --git a/demos/ARMCM0-LPC1114-GCC/halconf.h b/demos/ARMCM0-LPC1114-GCC/halconf.h index a9d7369b9..87d0f835d 100644 --- a/demos/ARMCM0-LPC1114-GCC/halconf.h +++ b/demos/ARMCM0-LPC1114-GCC/halconf.h @@ -62,6 +62,11 @@ #define CH_HAL_USE_ADC FALSE #endif +/* + * Default ADC settings overrides (uncomment to override). + */ +/*#define ADC_USE_WAIT TRUE*/ + /*===========================================================================*/ /* CAN driver related settings. */ /*===========================================================================*/ @@ -73,6 +78,11 @@ #define CH_HAL_USE_CAN FALSE #endif +/* + * Default CAN settings overrides (uncomment to override). + */ +/*#define CAN_USE_SLEEP_MODE TRUE*/ + /*===========================================================================*/ /* MAC driver related settings. */ /*===========================================================================*/ diff --git a/demos/ARMCM3-LPC1343-GCC/halconf.h b/demos/ARMCM3-LPC1343-GCC/halconf.h index a9d7369b9..87d0f835d 100644 --- a/demos/ARMCM3-LPC1343-GCC/halconf.h +++ b/demos/ARMCM3-LPC1343-GCC/halconf.h @@ -62,6 +62,11 @@ #define CH_HAL_USE_ADC FALSE #endif +/* + * Default ADC settings overrides (uncomment to override). + */ +/*#define ADC_USE_WAIT TRUE*/ + /*===========================================================================*/ /* CAN driver related settings. */ /*===========================================================================*/ @@ -73,6 +78,11 @@ #define CH_HAL_USE_CAN FALSE #endif +/* + * Default CAN settings overrides (uncomment to override). + */ +/*#define CAN_USE_SLEEP_MODE TRUE*/ + /*===========================================================================*/ /* MAC driver related settings. */ /*===========================================================================*/ diff --git a/demos/ARMCM3-STM32F103-FATFS-GCC/halconf.h b/demos/ARMCM3-STM32F103-FATFS-GCC/halconf.h index c941995ee..c65522e3a 100644 --- a/demos/ARMCM3-STM32F103-FATFS-GCC/halconf.h +++ b/demos/ARMCM3-STM32F103-FATFS-GCC/halconf.h @@ -62,6 +62,11 @@ #define CH_HAL_USE_ADC FALSE #endif +/* + * Default ADC settings overrides (uncomment to override). + */ +/*#define ADC_USE_WAIT TRUE*/ + /*===========================================================================*/ /* CAN driver related settings. */ /*===========================================================================*/ @@ -73,6 +78,11 @@ #define CH_HAL_USE_CAN FALSE #endif +/* + * Default CAN settings overrides (uncomment to override). + */ +/*#define CAN_USE_SLEEP_MODE TRUE*/ + /*===========================================================================*/ /* MAC driver related settings. */ /*===========================================================================*/ diff --git a/demos/ARMCM3-STM32F107-GCC/halconf.h b/demos/ARMCM3-STM32F107-GCC/halconf.h index a9d7369b9..87d0f835d 100644 --- a/demos/ARMCM3-STM32F107-GCC/halconf.h +++ b/demos/ARMCM3-STM32F107-GCC/halconf.h @@ -62,6 +62,11 @@ #define CH_HAL_USE_ADC FALSE #endif +/* + * Default ADC settings overrides (uncomment to override). + */ +/*#define ADC_USE_WAIT TRUE*/ + /*===========================================================================*/ /* CAN driver related settings. */ /*===========================================================================*/ @@ -73,6 +78,11 @@ #define CH_HAL_USE_CAN FALSE #endif +/* + * Default CAN settings overrides (uncomment to override). + */ +/*#define CAN_USE_SLEEP_MODE TRUE*/ + /*===========================================================================*/ /* MAC driver related settings. */ /*===========================================================================*/ diff --git a/demos/AVR-AT90CANx-GCC/halconf.h b/demos/AVR-AT90CANx-GCC/halconf.h index de9c05fdf..f81870b13 100644 --- a/demos/AVR-AT90CANx-GCC/halconf.h +++ b/demos/AVR-AT90CANx-GCC/halconf.h @@ -62,6 +62,11 @@ #define CH_HAL_USE_ADC FALSE #endif +/* + * Default ADC settings overrides (uncomment to override). + */ +/*#define ADC_USE_WAIT TRUE*/ + /*===========================================================================*/ /* CAN driver related settings. */ /*===========================================================================*/ @@ -73,6 +78,11 @@ #define CH_HAL_USE_CAN FALSE #endif +/* + * Default CAN settings overrides (uncomment to override). + */ +/*#define CAN_USE_SLEEP_MODE TRUE*/ + /*===========================================================================*/ /* MAC driver related settings. */ /*===========================================================================*/ diff --git a/demos/AVR-ATmega128-GCC/halconf.h b/demos/AVR-ATmega128-GCC/halconf.h index de9c05fdf..f81870b13 100644 --- a/demos/AVR-ATmega128-GCC/halconf.h +++ b/demos/AVR-ATmega128-GCC/halconf.h @@ -62,6 +62,11 @@ #define CH_HAL_USE_ADC FALSE #endif +/* + * Default ADC settings overrides (uncomment to override). + */ +/*#define ADC_USE_WAIT TRUE*/ + /*===========================================================================*/ /* CAN driver related settings. */ /*===========================================================================*/ @@ -73,6 +78,11 @@ #define CH_HAL_USE_CAN FALSE #endif +/* + * Default CAN settings overrides (uncomment to override). + */ +/*#define CAN_USE_SLEEP_MODE TRUE*/ + /*===========================================================================*/ /* MAC driver related settings. */ /*===========================================================================*/ diff --git a/demos/MSP430-MSP430x1611-GCC/halconf.h b/demos/MSP430-MSP430x1611-GCC/halconf.h index a9d7369b9..87d0f835d 100644 --- a/demos/MSP430-MSP430x1611-GCC/halconf.h +++ b/demos/MSP430-MSP430x1611-GCC/halconf.h @@ -62,6 +62,11 @@ #define CH_HAL_USE_ADC FALSE #endif +/* + * Default ADC settings overrides (uncomment to override). + */ +/*#define ADC_USE_WAIT TRUE*/ + /*===========================================================================*/ /* CAN driver related settings. */ /*===========================================================================*/ @@ -73,6 +78,11 @@ #define CH_HAL_USE_CAN FALSE #endif +/* + * Default CAN settings overrides (uncomment to override). + */ +/*#define CAN_USE_SLEEP_MODE TRUE*/ + /*===========================================================================*/ /* MAC driver related settings. */ /*===========================================================================*/ diff --git a/demos/PPC-SPC563-GCC/halconf.h b/demos/PPC-SPC563-GCC/halconf.h index 74aaff977..6e16e85a6 100644 --- a/demos/PPC-SPC563-GCC/halconf.h +++ b/demos/PPC-SPC563-GCC/halconf.h @@ -62,6 +62,11 @@ #define CH_HAL_USE_ADC FALSE #endif +/* + * Default ADC settings overrides (uncomment to override). + */ +/*#define ADC_USE_WAIT TRUE*/ + /*===========================================================================*/ /* CAN driver related settings. */ /*===========================================================================*/ @@ -73,6 +78,11 @@ #define CH_HAL_USE_CAN FALSE #endif +/* + * Default CAN settings overrides (uncomment to override). + */ +/*#define CAN_USE_SLEEP_MODE TRUE*/ + /*===========================================================================*/ /* MAC driver related settings. */ /*===========================================================================*/ diff --git a/demos/Posix-GCC/halconf.h b/demos/Posix-GCC/halconf.h index b870f61b8..6976d598e 100644 --- a/demos/Posix-GCC/halconf.h +++ b/demos/Posix-GCC/halconf.h @@ -62,6 +62,11 @@ #define CH_HAL_USE_ADC FALSE #endif +/* + * Default ADC settings overrides (uncomment to override). + */ +/*#define ADC_USE_WAIT TRUE*/ + /*===========================================================================*/ /* CAN driver related settings. */ /*===========================================================================*/ @@ -73,6 +78,11 @@ #define CH_HAL_USE_CAN FALSE #endif +/* + * Default CAN settings overrides (uncomment to override). + */ +/*#define CAN_USE_SLEEP_MODE TRUE*/ + /*===========================================================================*/ /* MAC driver related settings. */ /*===========================================================================*/ diff --git a/demos/STM8S-STM8S105-DISCOVERY-STVD/demo/halconf.h b/demos/STM8S-STM8S105-DISCOVERY-STVD/demo/halconf.h index 67d6c6d08..b0b87601a 100644 --- a/demos/STM8S-STM8S105-DISCOVERY-STVD/demo/halconf.h +++ b/demos/STM8S-STM8S105-DISCOVERY-STVD/demo/halconf.h @@ -62,6 +62,11 @@ #define CH_HAL_USE_ADC FALSE #endif +/* + * Default ADC settings overrides (uncomment to override). + */ +/*#define ADC_USE_WAIT TRUE*/ + /*===========================================================================*/ /* CAN driver related settings. */ /*===========================================================================*/ @@ -73,6 +78,11 @@ #define CH_HAL_USE_CAN FALSE #endif +/* + * Default CAN settings overrides (uncomment to override). + */ +/*#define CAN_USE_SLEEP_MODE TRUE*/ + /*===========================================================================*/ /* MAC driver related settings. */ /*===========================================================================*/ diff --git a/demos/STM8S-STM8S208-RC/halconf.h b/demos/STM8S-STM8S208-RC/halconf.h index a9d7369b9..87d0f835d 100644 --- a/demos/STM8S-STM8S208-RC/halconf.h +++ b/demos/STM8S-STM8S208-RC/halconf.h @@ -62,6 +62,11 @@ #define CH_HAL_USE_ADC FALSE #endif +/* + * Default ADC settings overrides (uncomment to override). + */ +/*#define ADC_USE_WAIT TRUE*/ + /*===========================================================================*/ /* CAN driver related settings. */ /*===========================================================================*/ @@ -73,6 +78,11 @@ #define CH_HAL_USE_CAN FALSE #endif +/* + * Default CAN settings overrides (uncomment to override). + */ +/*#define CAN_USE_SLEEP_MODE TRUE*/ + /*===========================================================================*/ /* MAC driver related settings. */ /*===========================================================================*/ diff --git a/demos/Win32-MinGW/halconf.h b/demos/Win32-MinGW/halconf.h index b870f61b8..6976d598e 100644 --- a/demos/Win32-MinGW/halconf.h +++ b/demos/Win32-MinGW/halconf.h @@ -62,6 +62,11 @@ #define CH_HAL_USE_ADC FALSE #endif +/* + * Default ADC settings overrides (uncomment to override). + */ +/*#define ADC_USE_WAIT TRUE*/ + /*===========================================================================*/ /* CAN driver related settings. */ /*===========================================================================*/ @@ -73,6 +78,11 @@ #define CH_HAL_USE_CAN FALSE #endif +/* + * Default CAN settings overrides (uncomment to override). + */ +/*#define CAN_USE_SLEEP_MODE TRUE*/ + /*===========================================================================*/ /* MAC driver related settings. */ /*===========================================================================*/ 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 @@ -194,10 +194,6 @@ typedef struct { * @brief Current configuration data. */ const ADCConfig *ad_config; - /** - * @brief Synchronization semaphore. - */ - Semaphore ad_sem; /** * @brief Current callback function or @p NULL. */ @@ -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 @@ -111,10 +111,6 @@ typedef struct { * @brief Current configuration data. */ const ADCConfig *ad_config; - /** - * @brief Synchronization semaphore. - */ - Semaphore ad_sem; /** * @brief Current callback function or @p NULL. */ @@ -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; diff --git a/readme.txt b/readme.txt index ddcbf53b3..dd43d05e4 100644 --- a/readme.txt +++ b/readme.txt @@ -62,6 +62,7 @@ ***************************************************************************** *** 2.1.2 *** +- FIX: Fixed CAN_USE_SLEEP_MODE setting (bug 3064204)(backported to 2.0.5). - FIX: Fixed potential issue with GCC reorganizing instructions around "asm volatile" statements (bug 3058731)(backported in 2.0.4). - FIX: Fixed reduced ARM7 performance with GCC 4.5.x (bug 3056866)(backported @@ -96,7 +97,8 @@ is no footprint overhead. - NEW: Added adcStartConversionI() and adcStopConversionI() APIs to the ADC driver in order to allow the driver control from within callbacks or other - interrupt handlers. + interrupt handlers. Made the adcWaitConversion() API optional, this allows + to save some space in Flash/RAM if it is not required. - NEW: Added a generic BaseFileStream interface for future File System implementations or integrations (untested and not sure if it will stay or change). diff --git a/test/coverage/halconf.h b/test/coverage/halconf.h index c93f68779..3e4b15d2d 100644 --- a/test/coverage/halconf.h +++ b/test/coverage/halconf.h @@ -62,6 +62,11 @@ #define CH_HAL_USE_ADC FALSE #endif +/* + * Default ADC settings overrides (uncomment to override). + */ +/*#define ADC_USE_WAIT TRUE*/ + /*===========================================================================*/ /* CAN driver related settings. */ /*===========================================================================*/ @@ -73,6 +78,11 @@ #define CH_HAL_USE_CAN FALSE #endif +/* + * Default CAN settings overrides (uncomment to override). + */ +/*#define CAN_USE_SLEEP_MODE TRUE*/ + /*===========================================================================*/ /* MAC driver related settings. */ /*===========================================================================*/ diff --git a/testhal/STM32/ADC/halconf.h b/testhal/STM32/ADC/halconf.h index af334fb5b..f294f3337 100644 --- a/testhal/STM32/ADC/halconf.h +++ b/testhal/STM32/ADC/halconf.h @@ -62,6 +62,11 @@ #define CH_HAL_USE_ADC TRUE #endif +/* + * Default ADC settings overrides (uncomment to override). + */ +/*#define ADC_USE_WAIT TRUE*/ + /*===========================================================================*/ /* CAN driver related settings. */ /*===========================================================================*/ @@ -73,6 +78,11 @@ #define CH_HAL_USE_CAN FALSE #endif +/* + * Default CAN settings overrides (uncomment to override). + */ +/*#define CAN_USE_SLEEP_MODE TRUE*/ + /*===========================================================================*/ /* MAC driver related settings. */ /*===========================================================================*/ diff --git a/testhal/STM32/CAN/halconf.h b/testhal/STM32/CAN/halconf.h index 2c4df98dd..3f39e210a 100644 --- a/testhal/STM32/CAN/halconf.h +++ b/testhal/STM32/CAN/halconf.h @@ -62,6 +62,11 @@ #define CH_HAL_USE_ADC FALSE #endif +/* + * Default ADC settings overrides (uncomment to override). + */ +/*#define ADC_USE_WAIT TRUE*/ + /*===========================================================================*/ /* CAN driver related settings. */ /*===========================================================================*/ @@ -73,6 +78,11 @@ #define CH_HAL_USE_CAN TRUE #endif +/* + * Default CAN settings overrides (uncomment to override). + */ +/*#define CAN_USE_SLEEP_MODE TRUE*/ + /*===========================================================================*/ /* MAC driver related settings. */ /*===========================================================================*/ diff --git a/testhal/STM32/PWM/halconf.h b/testhal/STM32/PWM/halconf.h index 86a282617..f986170cf 100644 --- a/testhal/STM32/PWM/halconf.h +++ b/testhal/STM32/PWM/halconf.h @@ -62,6 +62,11 @@ #define CH_HAL_USE_ADC FALSE #endif +/* + * Default ADC settings overrides (uncomment to override). + */ +/*#define ADC_USE_WAIT TRUE*/ + /*===========================================================================*/ /* CAN driver related settings. */ /*===========================================================================*/ @@ -73,6 +78,11 @@ #define CH_HAL_USE_CAN FALSE #endif +/* + * Default CAN settings overrides (uncomment to override). + */ +/*#define CAN_USE_SLEEP_MODE TRUE*/ + /*===========================================================================*/ /* MAC driver related settings. */ /*===========================================================================*/ diff --git a/testhal/STM32/SPI/halconf.h b/testhal/STM32/SPI/halconf.h index 64252c967..598a2d7ac 100644 --- a/testhal/STM32/SPI/halconf.h +++ b/testhal/STM32/SPI/halconf.h @@ -62,6 +62,11 @@ #define CH_HAL_USE_ADC FALSE #endif +/* + * Default ADC settings overrides (uncomment to override). + */ +/*#define ADC_USE_WAIT TRUE*/ + /*===========================================================================*/ /* CAN driver related settings. */ /*===========================================================================*/ @@ -73,6 +78,11 @@ #define CH_HAL_USE_CAN FALSE #endif +/* + * Default CAN settings overrides (uncomment to override). + */ +/*#define CAN_USE_SLEEP_MODE TRUE*/ + /*===========================================================================*/ /* MAC driver related settings. */ /*===========================================================================*/ diff --git a/testhal/STM32/UART/halconf.h b/testhal/STM32/UART/halconf.h index f317ce69a..00efb23b2 100644 --- a/testhal/STM32/UART/halconf.h +++ b/testhal/STM32/UART/halconf.h @@ -62,6 +62,11 @@ #define CH_HAL_USE_ADC FALSE #endif +/* + * Default ADC settings overrides (uncomment to override). + */ +/*#define ADC_USE_WAIT TRUE*/ + /*===========================================================================*/ /* CAN driver related settings. */ /*===========================================================================*/ @@ -73,6 +78,11 @@ #define CH_HAL_USE_CAN FALSE #endif +/* + * Default CAN settings overrides (uncomment to override). + */ +/*#define CAN_USE_SLEEP_MODE TRUE*/ + /*===========================================================================*/ /* MAC driver related settings. */ /*===========================================================================*/ diff --git a/testhal/STM32/_stess_test/halconf.h b/testhal/STM32/_stess_test/halconf.h index 9d1c16bca..c2d7102f1 100644 --- a/testhal/STM32/_stess_test/halconf.h +++ b/testhal/STM32/_stess_test/halconf.h @@ -62,6 +62,11 @@ #define CH_HAL_USE_ADC TRUE #endif +/* + * Default ADC settings overrides (uncomment to override). + */ +/*#define ADC_USE_WAIT TRUE*/ + /*===========================================================================*/ /* CAN driver related settings. */ /*===========================================================================*/ @@ -73,6 +78,11 @@ #define CH_HAL_USE_CAN TRUE #endif +/* + * Default CAN settings overrides (uncomment to override). + */ +/*#define CAN_USE_SLEEP_MODE TRUE*/ + /*===========================================================================*/ /* MAC driver related settings. */ /*===========================================================================*/