From ee0f2a921d97b47286158cdc2b0cc4c5671f44d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Ple=C3=9F?= Date: Wed, 12 Jun 2013 15:30:15 +0200 Subject: [PATCH] optimisations in adc code --- display/software/powerboard/src/adc.c | 9 +++++---- display/software/powerboard/src/adc.h | 6 +++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/display/software/powerboard/src/adc.c b/display/software/powerboard/src/adc.c index 42e7b4c..8ad8969 100644 --- a/display/software/powerboard/src/adc.c +++ b/display/software/powerboard/src/adc.c @@ -30,12 +30,13 @@ uint16_t adc_read_single(uint8_t channel) { return ADCW; } -uint16_t adc_read_avg(uint8_t channel, uint8_t nsamples) { - uint32_t sum = 0; +uint16_t adc_read_avg(const uint8_t channel, const uint8_t nsamples) { + uint16_t sum = 0; + uint8_t count = nsamples % 60; - for (uint8_t i=0; i