diff options
author | Giovanni Di Sirio <gdisirio@gmail.com> | 2018-12-30 14:41:19 +0000 |
---|---|---|
committer | Giovanni Di Sirio <gdisirio@gmail.com> | 2018-12-30 14:41:19 +0000 |
commit | da90520c9f1ca80168b54d437b0ad65cc0ddbb71 (patch) | |
tree | eaf03488f003547c7f0118ffcc63a7532f49a6ce /testhal/STM32/multi/ADC/main.c | |
parent | 15fca876739fcd859f8b53b5eeb43820eb7feb37 (diff) | |
download | ChibiOS-da90520c9f1ca80168b54d437b0ad65cc0ddbb71.tar.gz ChibiOS-da90520c9f1ca80168b54d437b0ad65cc0ddbb71.tar.bz2 ChibiOS-da90520c9f1ca80168b54d437b0ad65cc0ddbb71.zip |
Starting to work, still problems.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@12497 110e8d01-0319-4d1e-a829-52ad28d1bb01
Diffstat (limited to 'testhal/STM32/multi/ADC/main.c')
-rw-r--r-- | testhal/STM32/multi/ADC/main.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/testhal/STM32/multi/ADC/main.c b/testhal/STM32/multi/ADC/main.c index 5464bd7c5..8e26c3819 100644 --- a/testhal/STM32/multi/ADC/main.c +++ b/testhal/STM32/multi/ADC/main.c @@ -42,18 +42,23 @@ adcsample_t samples2[CACHE_SIZE_ALIGN(adcsample_t, ADC_GRP2_NUM_CHANNELS * ADC_G /*
* ADC streaming callback.
*/
-size_t nx = 0, ny = 0;
+size_t n= 0, nx = 0, ny = 0;
void adccallback(ADCDriver *adcp) {
(void)adcp;
/* Updating counters.*/
+ n++;
if (adcIsBufferComplete(adcp)) {
nx += 1;
}
else {
ny += 1;
}
+
+ if ((n % 200) == 0U) {
+ palToggleLine(LINE_LED2);
+ }
}
/*
@@ -112,7 +117,7 @@ int main(void) { chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
/*
- * Activates the PORTAB_ADC1 driver and the temperature sensor.
+ * Starting PORTAB_ADC1 driver and the temperature sensor.
*/
adcStart(&PORTAB_ADC1, &portab_adccfg1);
adcSTM32EnableVREF(&PORTAB_ADC1);
@@ -123,11 +128,26 @@ int main(void) { cacheBufferInvalidate(samples1, sizeof (samples1) / sizeof (adcsample_t));
/*
+ * Starting PORTAB_GPT1 driver, it is used for triggering the ADC.
+ */
+ gptStart(&PORTAB_GPT1, &portab_gptcfg1);
+
+ /*
+ * Starting an ADC continuous conversion triggered with a period of
+ * 1/10000 second.
+ */
+ adcStartConversion(&PORTAB_ADC1, &portab_adcgrpcfg2,
+ samples2, ADC_GRP2_BUF_DEPTH);
+ gptStartContinuous(&PORTAB_GPT1, 100U);
+
+ /*
* Normal main() thread activity, if the button is pressed then the
* conversion is stopped.
*/
while (true) {
if (palReadLine(PORTAB_LINE_BUTTON) == PORTAB_BUTTON_PRESSED) {
+ gptStopTimer(&PORTAB_GPT1);
+ adcStopConversion(&PORTAB_ADC1);
}
chThdSleepMilliseconds(500);
}
|