aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabien Poussin <fabien.poussin@gmail.com>2019-10-21 22:15:57 +0200
committerGitHub <noreply@github.com>2019-10-21 22:15:57 +0200
commitdc72ea603311123964271f910f051fb2027351ef (patch)
treebdbef5b98c190a7db44fdc2329044de4ed12b741
parent4a70bf56c86c8716d9615bfb4a83c2df58f67b95 (diff)
parentb73ec1f1075d9f50e75fcc1dd57faf916b30b79d (diff)
downloadChibiOS-Contrib-dc72ea603311123964271f910f051fb2027351ef.tar.gz
ChibiOS-Contrib-dc72ea603311123964271f910f051fb2027351ef.tar.bz2
ChibiOS-Contrib-dc72ea603311123964271f910f051fb2027351ef.zip
Merge pull request #201 from romainreignier/fix-pid-demo
FIX PID demo after ChibiOS ADC callback rework
-rw-r--r--demos/STM32/RT-STM32F303-DISCOVERY-PID/main.c11
1 files 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);