Continuous mode tested.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5003 35acf78f-673a-0410-8e92-d51de3d6d3f4
master
gdisirio 2012-12-31 09:48:39 +00:00
parent 6a0fb115c3
commit a4edf0bf6c
1 changed files with 23 additions and 22 deletions

View File

@ -28,9 +28,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];
static adcsample_t samples2[ADC_GRP2_NUM_CHANNELS * ADC_GRP2_BUF_DEPTH];
#if 0
/*
* ADC streaming callback.
*/
@ -45,7 +44,6 @@ static void adccallback(ADCDriver *adcp, adcsample_t *buffer, size_t n) {
ny += n;
}
}
#endif
static void adcerrorcallback(ADCDriver *adcp, adcerror_t err) {
@ -55,8 +53,8 @@ static void adcerrorcallback(ADCDriver *adcp, adcerror_t err) {
/*
* ADC conversion group.
* Mode: Linear buffer, 8 samples of 1 channel, SW triggered.
* Channels: IN11.
* Mode: Linear buffer, 8 samples of 2 channels, SW triggered.
* Channels: IN7, IN8.
*/
static const ADCConversionGroup adcgrpcfg1 = {
FALSE,
@ -78,29 +76,34 @@ static const ADCConversionGroup adcgrpcfg1 = {
}
};
#if 0
/*
* ADC conversion group.
* Mode: Continuous, 16 samples of 8 channels, SW triggered.
* Channels: IN11, IN12, IN11, IN12, IN11, IN12, Sensor, VRef.
* Channels: IN7, IN8, IN7, IN8, IN7, IN8, Sensor, VBat/2.
*/
static const ADCConversionGroup adcgrpcfg2 = {
TRUE,
ADC_GRP2_NUM_CHANNELS,
adccallback,
adcerrorcallback,
0, /* CR1 */
ADC_CR2_SWSTART, /* CR2 */
ADC_SMPR1_SMP_AN12(ADC_SAMPLE_56) | ADC_SMPR1_SMP_AN11(ADC_SAMPLE_56) |
ADC_SMPR1_SMP_SENSOR(ADC_SAMPLE_144) | ADC_SMPR1_SMP_VREF(ADC_SAMPLE_144),
0, /* SMPR2 */
ADC_SQR1_NUM_CH(ADC_GRP2_NUM_CHANNELS),
ADC_SQR2_SQ8_N(ADC_CHANNEL_SENSOR) | ADC_SQR2_SQ7_N(ADC_CHANNEL_VREFINT),
ADC_SQR3_SQ6_N(ADC_CHANNEL_IN12) | ADC_SQR3_SQ5_N(ADC_CHANNEL_IN11) |
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)
0, /* CFGR */
ADC_TR(0, 4095), /* TR1 */
ADC_CCR_TSEN | ADC_CCR_VBATEN, /* CCR */
{ /* SMPR[2] */
ADC_SMPR1_SMP_AN7(ADC_SMPR_SMP_19P5)
| ADC_SMPR1_SMP_AN8(ADC_SMPR_SMP_19P5),
ADC_SMPR2_SMP_AN16(ADC_SMPR_SMP_61P5)
| ADC_SMPR2_SMP_AN17(ADC_SMPR_SMP_61P5),
},
{ /* SQR[4] */
ADC_SQR1_SQ1_N(ADC_CHANNEL_IN7) | ADC_SQR1_SQ2_N(ADC_CHANNEL_IN8) |
ADC_SQR1_SQ3_N(ADC_CHANNEL_IN7) | ADC_SQR1_SQ4_N(ADC_CHANNEL_IN8),
ADC_SQR2_SQ5_N(ADC_CHANNEL_IN7) | ADC_SQR2_SQ6_N(ADC_CHANNEL_IN8) |
ADC_SQR2_SQ7_N(ADC_CHANNEL_IN16) | ADC_SQR2_SQ8_N(ADC_CHANNEL_IN17),
0,
0
}
};
#endif
/*
* Red LEDs blinker thread, times are in milliseconds.
@ -149,7 +152,6 @@ int main(void) {
* Activates the ADC1 driver and the temperature sensor.
*/
adcStart(&ADCD1, NULL);
// adcSTM32EnableTSVREFE();
/*
* Linear conversion.
@ -160,15 +162,14 @@ 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);
}
chThdSleepMilliseconds(500);
}