aboutsummaryrefslogtreecommitdiffstats
path: root/testhal
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2011-09-25 05:55:37 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2011-09-25 05:55:37 +0000
commit4c37f7b08813f3c0b805c605780938d7d2ef8ae6 (patch)
tree2cc3bab1e48ebde8c80c5b286e3d6d36e839a3fe /testhal
parenta6310af1976c528e7eae1c757cff6e4d14aa37a1 (diff)
downloadChibiOS-4c37f7b08813f3c0b805c605780938d7d2ef8ae6.tar.gz
ChibiOS-4c37f7b08813f3c0b805c605780938d7d2ef8ae6.tar.bz2
ChibiOS-4c37f7b08813f3c0b805c605780938d7d2ef8ae6.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3401 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'testhal')
-rw-r--r--testhal/STM32L1xx/ADC/main.c36
1 files changed, 21 insertions, 15 deletions
diff --git a/testhal/STM32L1xx/ADC/main.c b/testhal/STM32L1xx/ADC/main.c
index 75729108e..9f740a49c 100644
--- a/testhal/STM32L1xx/ADC/main.c
+++ b/testhal/STM32L1xx/ADC/main.c
@@ -21,10 +21,14 @@
#include "ch.h"
#include "hal.h"
-#define ADC_GRP1_NUM_CHANNELS 8
-#define ADC_GRP1_BUF_DEPTH 16
+#define ADC_GRP1_NUM_CHANNELS 1
+#define ADC_GRP1_BUF_DEPTH 8
-static adcsample_t samples[ADC_GRP1_NUM_CHANNELS * ADC_GRP1_BUF_DEPTH];
+#define ADC_GRP2_NUM_CHANNELS 8
+#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];
/*
* ADC streaming callback.
@@ -33,7 +37,7 @@ size_t nx = 0, ny = 0;
static void adccallback(ADCDriver *adcp, adcsample_t *buffer, size_t n) {
(void)adcp;
- if (samples == buffer) {
+ if (samples2 == buffer) {
nx += n;
}
else {
@@ -58,13 +62,12 @@ static const ADCConversionGroup adcgrpcfg1 = {
NULL,
adcerrorcallback,
0, 0, /* CR1, CR2 */
- 0, 0, 0, /* SMPR1...SMPR3 */
+ 0, /* SMPR1 */
+ ADC_SMPR2_SMP_AN10(ADC_SAMPLE_9),
+ 0, /* 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)
+ 0, 0, 0, /* SQR2, SQR3, SQR4 */
+ ADC_SQR5_SQ1_N(ADC_CHANNEL_IN10)
};
/*
@@ -74,12 +77,15 @@ static const ADCConversionGroup adcgrpcfg1 = {
*/
static const ADCConversionGroup adcgrpcfg2 = {
TRUE,
- ADC_GRP1_NUM_CHANNELS,
+ ADC_GRP2_NUM_CHANNELS,
adccallback,
adcerrorcallback,
0, 0, /* CR1, CR2 */
- 0, 0, 0, /* SMPR1...SMPR3 */
- ADC_SQR1_NUM_CH(ADC_GRP1_NUM_CHANNELS),
+ 0, /* SMPR1 */
+ ADC_SMPR2_SMP_AN10(ADC_SAMPLE_48) | ADC_SMPR2_SMP_SENSOR(ADC_SAMPLE_192) |
+ ADC_SMPR2_SMP_VREF(ADC_SAMPLE_192),
+ 0, /* SMPR3 */
+ ADC_SQR1_NUM_CH(ADC_GRP2_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) |
@@ -138,13 +144,13 @@ int main(void) {
/*
* Linear conversion.
*/
- adcConvert(&ADCD1, &adcgrpcfg1, samples, ADC_GRP1_BUF_DEPTH);
+ adcConvert(&ADCD1, &adcgrpcfg1, samples1, ADC_GRP1_BUF_DEPTH);
chThdSleepMilliseconds(1000);
/*
* Starts an ADC continuous conversion.
*/
- adcStartConversion(&ADCD1, &adcgrpcfg2, samples, ADC_GRP1_BUF_DEPTH);
+ adcStartConversion(&ADCD1, &adcgrpcfg2, samples2, ADC_GRP2_BUF_DEPTH);
/*
* Normal main() thread activity, in this demo it does nothing.