diff options
author | Fabien Poussin <fabien.poussin@gmail.com> | 2019-10-21 22:15:57 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-21 22:15:57 +0200 |
commit | dc72ea603311123964271f910f051fb2027351ef (patch) | |
tree | bdbef5b98c190a7db44fdc2329044de4ed12b741 | |
parent | 4a70bf56c86c8716d9615bfb4a83c2df58f67b95 (diff) | |
parent | b73ec1f1075d9f50e75fcc1dd57faf916b30b79d (diff) | |
download | ChibiOS-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.c | 11 |
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);
|