Code: Select all
uint16 analogRead(uint8 pin) {
const uint8_t channel = PIN_MAP[pin].adc_channel;
if (channel == ADCx) {
return 0;
}
return adc_read(&adc1, channel);
}
Code: Select all
uint16 analogRead(uint8 pin) {
const uint8_t channel = PIN_MAP[pin].adc_channel;
if (channel == ADCx) {
return 0;
}
return adc_read(&adc1, channel);
}
Is there a measurable improvement on this?arpruss wrote: ↑Thu Nov 30, 2017 2:41 pmOn all the f1 boards, it seems that every analog pin works with both ADC1 and ADC2, so one could ever so slightly optimize analogRead() not to look up the ADC device in PIN_MAP[], and just use ADC1 (which is what is listed in the PIN_MAP for every f1 board):Code: Select all
uint16 analogRead(uint8 pin) { const uint8_t channel = PIN_MAP[pin].adc_channel; if (channel == ADCx) { return 0; } return adc_read(&adc1, channel); }