diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2011-09-25 05:41:29 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2011-09-25 05:41:29 +0000 |
commit | a6310af1976c528e7eae1c757cff6e4d14aa37a1 (patch) | |
tree | 567c36dc4d729a3b12fc92172e185224be54f435 /testhal/STM32L1xx | |
parent | 7d30f4c821023de001cd4459c83a1fdae2f8cb07 (diff) | |
download | ChibiOS-a6310af1976c528e7eae1c757cff6e4d14aa37a1.tar.gz ChibiOS-a6310af1976c528e7eae1c757cff6e4d14aa37a1.tar.bz2 ChibiOS-a6310af1976c528e7eae1c757cff6e4d14aa37a1.zip |
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3400 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'testhal/STM32L1xx')
-rw-r--r-- | testhal/STM32L1xx/ADC/main.c | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/testhal/STM32L1xx/ADC/main.c b/testhal/STM32L1xx/ADC/main.c index 706ec690e..75729108e 100644 --- a/testhal/STM32L1xx/ADC/main.c +++ b/testhal/STM32L1xx/ADC/main.c @@ -49,10 +49,30 @@ static void adcerrorcallback(ADCDriver *adcp, adcerror_t err) { /*
* ADC conversion group.
- * Mode: Streaming, continuous, 16 samples of 8 channels, SW triggered.
+ * Mode: Linear buffer, 16 samples of 8 channels, SW triggered.
* Channels: IN10, IN11, IN10, IN11, IN10, IN11, Sensor, VRef.
*/
-static const ADCConversionGroup adcgrpcfg = {
+static const ADCConversionGroup adcgrpcfg1 = {
+ FALSE,
+ ADC_GRP1_NUM_CHANNELS,
+ NULL,
+ adcerrorcallback,
+ 0, 0, /* CR1, CR2 */
+ 0, 0, 0, /* SMPR1...SMPR3 */
+ ADC_SQR1_NUM_CH(ADC_GRP1_NUM_CHANNELS),
+ 0, 0, /* SQR2, SQR3 */
+ ADC_SQR4_SQ8_N(ADC_CHANNEL_SENSOR) | ADC_SQR4_SQ7_N(ADC_CHANNEL_VREFINT),
+ ADC_SQR5_SQ6_N(ADC_CHANNEL_IN11) | ADC_SQR5_SQ5_N(ADC_CHANNEL_IN10) |
+ ADC_SQR5_SQ4_N(ADC_CHANNEL_IN11) | ADC_SQR5_SQ3_N(ADC_CHANNEL_IN10) |
+ ADC_SQR5_SQ2_N(ADC_CHANNEL_IN11) | ADC_SQR5_SQ1_N(ADC_CHANNEL_IN10)
+};
+
+/*
+ * ADC conversion group.
+ * Mode: Continuous, 16 samples of 8 channels, SW triggered.
+ * Channels: IN10, IN11, IN10, IN11, IN10, IN11, Sensor, VRef.
+ */
+static const ADCConversionGroup adcgrpcfg2 = {
TRUE,
ADC_GRP1_NUM_CHANNELS,
adccallback,
@@ -110,11 +130,21 @@ int main(void) { chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
/*
- * Starts an ADC continuous conversion.
+ * Activates the ADC1 driver and the thermal sensor.
*/
adcStart(&ADCD1, NULL);
adcSTM32EnableTSVREFE();
- adcStartConversion(&ADCD1, &adcgrpcfg, samples, ADC_GRP1_BUF_DEPTH);
+
+ /*
+ * Linear conversion.
+ */
+ adcConvert(&ADCD1, &adcgrpcfg1, samples, ADC_GRP1_BUF_DEPTH);
+ chThdSleepMilliseconds(1000);
+
+ /*
+ * Starts an ADC continuous conversion.
+ */
+ adcStartConversion(&ADCD1, &adcgrpcfg2, samples, ADC_GRP1_BUF_DEPTH);
/*
* Normal main() thread activity, in this demo it does nothing.
|