From 91b9f7cae8e1a1de04e8a2a9246bb36dd9e4c5dc Mon Sep 17 00:00:00 2001 From: Christopher Pepper Date: Mon, 11 Nov 2019 00:56:56 +0000 Subject: [PATCH] adc lowpass first reading initialisation --- package.json | 2 +- system/lpc176x/adc.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 9ab4389..5b2b724 100755 --- a/package.json +++ b/package.json @@ -2,5 +2,5 @@ "name": "framework-arduino-lpc176x", "description": "Arduino Wiring-based Framework (LPC176x CMSIS 5)", "url": "https://www.arduino.cc/en/Main/Software", - "version": "0.2.1" + "version": "0.2.2" } diff --git a/system/lpc176x/adc.h b/system/lpc176x/adc.h index f7cee54..4393789 100644 --- a/system/lpc176x/adc.h +++ b/system/lpc176x/adc.h @@ -298,9 +298,9 @@ struct ADC { }; struct LowpassFilter { - uint32_t data_delay = 0x7FFF << ADC_LOWPASS_K_VALUE; + uint32_t data_delay = 0xFFFFFFFF; [[gnu::always_inline]] inline uint16_t update(uint16_t value) { - data_delay = data_delay - (data_delay >> ADC_LOWPASS_K_VALUE) + value; + data_delay = data_delay == 0xFFFFFFFF ? value << ADC_LOWPASS_K_VALUE : data_delay - (data_delay >> ADC_LOWPASS_K_VALUE) + value; return (uint16_t)(data_delay >> ADC_LOWPASS_K_VALUE); } };