From 567fd6ac1290c0aa80c861cee47daa3150810586 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sun, 30 Dec 2012 13:35:12 +0000 Subject: [PATCH] git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4998 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/platforms/STM32F3xx/adc_lld.c | 4 ++- testhal/STM32F3xx/ADC/main.c | 39 ++++++++++++++++++---------- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/os/hal/platforms/STM32F3xx/adc_lld.c b/os/hal/platforms/STM32F3xx/adc_lld.c index 874067140..e661b4b9c 100644 --- a/os/hal/platforms/STM32F3xx/adc_lld.c +++ b/os/hal/platforms/STM32F3xx/adc_lld.c @@ -89,6 +89,7 @@ ADCDriver ADCD3; */ static void adc_lld_vreg_on(ADCDriver *adcp) { + adcp->adcm->CR = 0; /* RM 12.4.3.*/ adcp->adcm->CR = ADC_CR_ADVREGEN_0; #if STM32_ADC_DUAL_MODE adcp->adcs->CR = ADC_CR_ADVREGEN_0; @@ -103,6 +104,7 @@ static void adc_lld_vreg_on(ADCDriver *adcp) { */ static void adc_lld_vreg_off(ADCDriver *adcp) { + adcp->adcm->CR = 0; /* RM 12.4.3.*/ adcp->adcm->CR = ADC_CR_ADVREGEN_1; #if STM32_ADC_DUAL_MODE adcp->adcs->CR = ADC_CR_ADVREGEN_1; @@ -479,7 +481,7 @@ void adc_lld_start_conversion(ADCDriver *adcp) { ccr |= ADC_CCR_DMACFG_CIRCULAR; cfgr |= ADC_CFGR_CONT; #else - cfgr |= ADC_CFGR_CONT | ADC_CFGR_DMACFG | ADC_CFGR_DMAEN; + cfgr |= ADC_CFGR_CONT | ADC_CFGR_DMACFG_CIRCULAR | ADC_CFGR_DMAEN; #endif } diff --git a/testhal/STM32F3xx/ADC/main.c b/testhal/STM32F3xx/ADC/main.c index d08bef1cc..ee5dfa922 100644 --- a/testhal/STM32F3xx/ADC/main.c +++ b/testhal/STM32F3xx/ADC/main.c @@ -28,8 +28,9 @@ #define ADC_GRP2_BUF_DEPTH 16 static adcsample_t samples1[ADC_GRP1_NUM_CHANNELS * ADC_GRP1_BUF_DEPTH]; -static adcsample_t samples2[ADC_GRP2_NUM_CHANNELS * ADC_GRP2_BUF_DEPTH]; +//static adcsample_t samples2[ADC_GRP2_NUM_CHANNELS * ADC_GRP2_BUF_DEPTH]; +#if 0 /* * ADC streaming callback. */ @@ -44,6 +45,7 @@ static void adccallback(ADCDriver *adcp, adcsample_t *buffer, size_t n) { ny += n; } } +#endif static void adcerrorcallback(ADCDriver *adcp, adcerror_t err) { @@ -61,15 +63,22 @@ static const ADCConversionGroup adcgrpcfg1 = { ADC_GRP1_NUM_CHANNELS, NULL, adcerrorcallback, - 0, /* CR1 */ - ADC_CR2_SWSTART, /* CR2 */ - ADC_SMPR1_SMP_AN11(ADC_SAMPLE_3), - 0, /* SMPR2 */ - ADC_SQR1_NUM_CH(ADC_GRP1_NUM_CHANNELS), - 0, /* SQR2 */ - ADC_SQR3_SQ1_N(ADC_CHANNEL_IN11) + 0, /* CFGR */ + 0, /* TR1 */ + 0, /* CCR */ + { /* SMPR[2] */ + 0, + 0 + }, + { /* SQR[4] */ + ADC_SQR1_SQ1_N(ADC_CHANNEL_IN7) | ADC_SQR1_SQ2_N(ADC_CHANNEL_IN8), + 0, + 0, + 0 + } }; +#if 0 /* * ADC conversion group. * Mode: Continuous, 16 samples of 8 channels, SW triggered. @@ -91,6 +100,7 @@ static const ADCConversionGroup adcgrpcfg2 = { ADC_SQR3_SQ4_N(ADC_CHANNEL_IN12) | ADC_SQR3_SQ3_N(ADC_CHANNEL_IN11) | ADC_SQR3_SQ2_N(ADC_CHANNEL_IN12) | ADC_SQR3_SQ1_N(ADC_CHANNEL_IN11) }; +#endif /* * Red LEDs blinker thread, times are in milliseconds. @@ -101,11 +111,12 @@ static msg_t Thread1(void *arg) { (void)arg; chRegSetThreadName("blinker"); while (TRUE) { - palSetPad(GPIOD, GPIOD_LED5); + palSetPad(GPIOE, GPIOE_LED10_RED); chThdSleepMilliseconds(500); - palClearPad(GPIOD, GPIOD_LED5); + palClearPad(GPIOE, GPIOE_LED10_RED); chThdSleepMilliseconds(500); } + return 0; } /* @@ -138,7 +149,7 @@ int main(void) { * Activates the ADC1 driver and the thermal sensor. */ adcStart(&ADCD1, NULL); - adcSTM32EnableTSVREFE(); +// adcSTM32EnableTSVREFE(); /* * Linear conversion. @@ -149,15 +160,15 @@ int main(void) { /* * Starts an ADC continuous conversion. */ - adcStartConversion(&ADCD1, &adcgrpcfg2, samples2, ADC_GRP2_BUF_DEPTH); +// adcStartConversion(&ADCD1, &adcgrpcfg2, samples2, ADC_GRP2_BUF_DEPTH); /* * Normal main() thread activity, in this demo it does nothing. */ while (TRUE) { if (palReadPad(GPIOA, GPIOA_BUTTON)) { - adcStopConversion(&ADCD1); - adcSTM32DisableTSVREFE(); +// adcStopConversion(&ADCD1); +// adcSTM32DisableTSVREFE(); } chThdSleepMilliseconds(500); }