From b73ec1f1075d9f50e75fcc1dd57faf916b30b79d Mon Sep 17 00:00:00 2001 From: Romain Reignier Date: Mon, 21 Oct 2019 20:14:23 +0200 Subject: FIX PID demo after ChibiOS ADC callback rework https://github.com/ChibiOS/ChibiOS/commit/f20ecc78178fc8cdfa682e100398c240224dbb4a#diff-e42edbbb9a343d9d1b70e68f524cbc22 --- demos/STM32/RT-STM32F303-DISCOVERY-PID/main.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/demos/STM32/RT-STM32F303-DISCOVERY-PID/main.c b/demos/STM32/RT-STM32F303-DISCOVERY-PID/main.c index d2e5e00..33cd39c 100644 --- a/demos/STM32/RT-STM32F303-DISCOVERY-PID/main.c +++ b/demos/STM32/RT-STM32F303-DISCOVERY-PID/main.c @@ -30,17 +30,16 @@ static adcsample_t samples[ADC_GRP1_NUM_CHANNELS * ADC_GRP1_BUF_DEPTH]; /* * ADC streaming callback. */ -static void adccallback(ADCDriver *adcp, adcsample_t *buffer, size_t n) { +static void adccallback(ADCDriver *adcp) { (void)adcp; - (void)n; uint32_t i, tmp = 0; - if (samples == buffer) { + if (adcIsBufferComplete(adcp)) { - for (i = 0; i < n; i++) { - tmp += buffer[i]; + for (i = 0; i < (adcp)->depth; i++) { + tmp += (adcp)->samples[i]; } - input = tmp / n; + input = tmp / (adcp)->depth; if (input <= target) { palClearLine(LINE_LED7_GREEN); -- cgit v1.2.3