mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-27 01:56:14 +01:00
Fix to SAMD21 ADCee pin init
This commit is contained in:
parent
4d205be007
commit
eb766aa27f
|
@ -164,12 +164,16 @@ int ADCee::init(uint8_t pin) {
|
||||||
|
|
||||||
if (id > NUM_ADC_INPUTS)
|
if (id > NUM_ADC_INPUTS)
|
||||||
return -1023;
|
return -1023;
|
||||||
pinMode(pin, INPUT);
|
// pinMode(pin, INPUT);
|
||||||
int value = analogRead(pin);
|
int value = analogRead(pin);
|
||||||
if (analogvals == NULL)
|
if (analogvals == NULL)
|
||||||
analogvals = (int *)calloc(NUM_ADC_INPUTS+1, sizeof(int));
|
analogvals = (int *)calloc(NUM_ADC_INPUTS+1, sizeof(int));
|
||||||
analogvals[id] = value;
|
analogvals[id] = value;
|
||||||
usedpins |= (1<<id);
|
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;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user