1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2025-02-21 08:16:04 +01:00

protect analogvals read from interrupt

This commit is contained in:
Harald Barth 2022-11-25 10:48:18 +01:00
parent 9b04cd791b
commit 96f47bf44f

View File

@ -169,9 +169,13 @@ int16_t ADCee::ADCmax() {
int ADCee::read(uint8_t pin, bool fromISR) {
(void)fromISR; // AVR does ignore this arg
uint8_t id = pin - A0;
int a;
// we do not need to check (analogvals == NULL)
// because usedpins would still be 0 in that case
return analogvals[id];
noInterrupts();
a = analogvals[id];
interrupts();
return a;
}
/*
* Scan function that is called from interrupt