diff options
Diffstat (limited to 'testhal/STM32L1xx/ADC/main.c')
-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.
|