aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/ports/STM32/LLD/ADCv2/hal_adc_lld.c
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2018-07-08 14:08:25 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2018-07-08 14:08:25 +0000
commit2cec1789e1291f2ce1c1ebe1b942784e6767ab2b (patch)
treeb80ce69b828b1723000a73b5a2d339b692a8f8b9 /os/hal/ports/STM32/LLD/ADCv2/hal_adc_lld.c
parent32d4ce8ee43227c7a630c7511b3f69a93c1a821e (diff)
downloadChibiOS-2cec1789e1291f2ce1c1ebe1b942784e6767ab2b.tar.gz
ChibiOS-2cec1789e1291f2ce1c1ebe1b942784e6767ab2b.tar.bz2
ChibiOS-2cec1789e1291f2ce1c1ebe1b942784e6767ab2b.zip
Added analog watchdog functionality to STM32 ADCv2 driver.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@12149 110e8d01-0319-4d1e-a829-52ad28d1bb01
Diffstat (limited to 'os/hal/ports/STM32/LLD/ADCv2/hal_adc_lld.c')
-rw-r--r--os/hal/ports/STM32/LLD/ADCv2/hal_adc_lld.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/os/hal/ports/STM32/LLD/ADCv2/hal_adc_lld.c b/os/hal/ports/STM32/LLD/ADCv2/hal_adc_lld.c
index b69fb3172..ab3fbf462 100644
--- a/os/hal/ports/STM32/LLD/ADCv2/hal_adc_lld.c
+++ b/os/hal/ports/STM32/LLD/ADCv2/hal_adc_lld.c
@@ -124,7 +124,11 @@ OSAL_IRQ_HANDLER(STM32_ADC_HANDLER) {
if (ADCD1.grpp != NULL)
_adc_isr_error_code(&ADCD1, ADC_ERR_OVERFLOW);
}
- /* TODO: Add here analog watchdog handling.*/
+ if (sr & ADC_SR_AWD) {
+ if (ADCD1.grpp != NULL) {
+ _adc_isr_error_code(&ADCD1, ADC_ERR_WATCHDOG);
+ }
+ }
#if defined(STM32_ADC_ADC1_IRQ_HOOK)
STM32_ADC_ADC1_IRQ_HOOK
#endif
@@ -141,7 +145,11 @@ OSAL_IRQ_HANDLER(STM32_ADC_HANDLER) {
if (ADCD2.grpp != NULL)
_adc_isr_error_code(&ADCD2, ADC_ERR_OVERFLOW);
}
- /* TODO: Add here analog watchdog handling.*/
+ if (sr & ADC_SR_AWD) {
+ if (ADCD2.grpp != NULL) {
+ _adc_isr_error_code(&ADCD2, ADC_ERR_WATCHDOG);
+ }
+ }
#if defined(STM32_ADC_ADC2_IRQ_HOOK)
STM32_ADC_ADC2_IRQ_HOOK
#endif
@@ -158,7 +166,11 @@ OSAL_IRQ_HANDLER(STM32_ADC_HANDLER) {
if (ADCD3.grpp != NULL)
_adc_isr_error_code(&ADCD3, ADC_ERR_OVERFLOW);
}
- /* TODO: Add here analog watchdog handling.*/
+ if (sr & ADC_SR_AWD) {
+ if (ADCD3.grpp != NULL) {
+ _adc_isr_error_code(&ADCD3, ADC_ERR_WATCHDOG);
+ }
+ }
#if defined(STM32_ADC_ADC3_IRQ_HOOK)
STM32_ADC_ADC3_IRQ_HOOK
#endif
@@ -350,6 +362,8 @@ void adc_lld_start_conversion(ADCDriver *adcp) {
adcp->adc->SR = 0;
adcp->adc->SMPR1 = grpp->smpr1;
adcp->adc->SMPR2 = grpp->smpr2;
+ adcp->adc->HTR = grpp->htr;
+ adcp->adc->LTR = grpp->ltr;
adcp->adc->SQR1 = grpp->sqr1 | ADC_SQR1_NUM_CH(grpp->num_channels);
adcp->adc->SQR2 = grpp->sqr2;
adcp->adc->SQR3 = grpp->sqr3;