From da90520c9f1ca80168b54d437b0ad65cc0ddbb71 Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Sun, 30 Dec 2018 14:41:19 +0000 Subject: Starting to work, still problems. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@12497 110e8d01-0319-4d1e-a829-52ad28d1bb01 --- testhal/STM32/multi/ADC/.cproject | 10 +++++++-- .../multi/ADC/cfg/stm32h743_nucleo144/mcuconf.h | 4 ++-- .../multi/ADC/cfg/stm32h743_nucleo144/portab.h | 1 + ...Select ELF file)(OpenOCD, Flash and Run).launch | 2 +- testhal/STM32/multi/ADC/main.c | 24 ++++++++++++++++++++-- 5 files changed, 34 insertions(+), 7 deletions(-) (limited to 'testhal') diff --git a/testhal/STM32/multi/ADC/.cproject b/testhal/STM32/multi/ADC/.cproject index 1b8427810..07eba767f 100644 --- a/testhal/STM32/multi/ADC/.cproject +++ b/testhal/STM32/multi/ADC/.cproject @@ -151,10 +151,16 @@ - + - + + + + + + + diff --git a/testhal/STM32/multi/ADC/cfg/stm32h743_nucleo144/mcuconf.h b/testhal/STM32/multi/ADC/cfg/stm32h743_nucleo144/mcuconf.h index da2d83264..5b6e99c00 100644 --- a/testhal/STM32/multi/ADC/cfg/stm32h743_nucleo144/mcuconf.h +++ b/testhal/STM32/multi/ADC/cfg/stm32h743_nucleo144/mcuconf.h @@ -223,9 +223,9 @@ #define STM32_GPT_USE_TIM1 FALSE #define STM32_GPT_USE_TIM2 FALSE #define STM32_GPT_USE_TIM3 FALSE -#define STM32_GPT_USE_TIM4 FALSE +#define STM32_GPT_USE_TIM4 TRUE #define STM32_GPT_USE_TIM5 FALSE -#define STM32_GPT_USE_TIM6 TRUE +#define STM32_GPT_USE_TIM6 FALSE #define STM32_GPT_USE_TIM7 FALSE #define STM32_GPT_USE_TIM8 FALSE #define STM32_GPT_USE_TIM9 FALSE diff --git a/testhal/STM32/multi/ADC/cfg/stm32h743_nucleo144/portab.h b/testhal/STM32/multi/ADC/cfg/stm32h743_nucleo144/portab.h index 56ae995fa..500e4f2ab 100644 --- a/testhal/STM32/multi/ADC/cfg/stm32h743_nucleo144/portab.h +++ b/testhal/STM32/multi/ADC/cfg/stm32h743_nucleo144/portab.h @@ -67,6 +67,7 @@ extern const GPTConfig portab_gptcfg1; extern const ADCConfig portab_adccfg1; extern const ADCConversionGroup portab_adcgrpcfg1; +extern const ADCConversionGroup portab_adcgrpcfg2; #ifdef __cplusplus extern "C" { diff --git a/testhal/STM32/multi/ADC/debug/STM32-ADC (Select ELF file)(OpenOCD, Flash and Run).launch b/testhal/STM32/multi/ADC/debug/STM32-ADC (Select ELF file)(OpenOCD, Flash and Run).launch index be98c7537..98cf3d524 100644 --- a/testhal/STM32/multi/ADC/debug/STM32-ADC (Select ELF file)(OpenOCD, Flash and Run).launch +++ b/testhal/STM32/multi/ADC/debug/STM32-ADC (Select ELF file)(OpenOCD, Flash and Run).launch @@ -33,7 +33,7 @@ - + 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); @@ -122,12 +127,27 @@ int main(void) { adcConvert(&PORTAB_ADC1, &portab_adcgrpcfg1, samples1, ADC_GRP1_BUF_DEPTH); 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); } -- cgit v1.2.3