1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-11-22 23:56:13 +01:00

Fix to SAMD21 ADCee pin init

This commit is contained in:
pmantoine 2022-10-12 17:12:00 +08:00
parent 4d205be007
commit eb766aa27f

View File

@ -164,12 +164,16 @@ int ADCee::init(uint8_t pin) {
if (id > NUM_ADC_INPUTS)
return -1023;
pinMode(pin, INPUT);
// pinMode(pin, INPUT);
int value = analogRead(pin);
if (analogvals == NULL)
analogvals = (int *)calloc(NUM_ADC_INPUTS+1, sizeof(int));
analogvals[id] = value;
usedpins |= (1<<id);
// Permanently configure SAMD IO MUX for that pin
pinPeripheral(pin, PIO_ANALOG);
ADC->INPUTCTRL.bit.MUXPOS = g_APinDescription[pin].ulADCChannelNumber; // Selection for the positive ADC input
return value;
}