Skip to content

Commit

Permalink
Remove Arduino-style analogRead() (#14348)
Browse files Browse the repository at this point in the history
  • Loading branch information
fauxpark committed Sep 8, 2021
1 parent 9b3e973 commit d977e5d
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 24 deletions.
23 changes: 0 additions & 23 deletions platforms/avr/drivers/analog.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,6 @@ static uint8_t aref = ADC_REF_POWER;

void analogReference(uint8_t mode) { aref = mode & (_BV(REFS1) | _BV(REFS0)); }

// Arduino compatible pin input
int16_t analogRead(uint8_t pin) {
#if defined(__AVR_ATmega32U4__)
// clang-format off
static const uint8_t PROGMEM pin_to_mux[] = {
//A0 A1 A2 A3 A4 A5
//F7 F6 F5 F4 F1 F0
0x07, 0x06, 0x05, 0x04, 0x01, 0x00,
//A6 A7 A8 A9 A10 A11
//D4 D7 B4 B5 B6 D6
0x20, 0x22, 0x23, 0x24, 0x25, 0x21
};
// clang-format on
if (pin >= 12) return 0;
return adc_read(pgm_read_byte(pin_to_mux + pin));
#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328__)
if (pin >= 8) return 0;
return adc_read(pin);
#else
return 0;
#endif
}

int16_t analogReadPin(pin_t pin) { return adc_read(pinToMux(pin)); }

uint8_t pinToMux(pin_t pin) {
Expand Down
1 change: 0 additions & 1 deletion platforms/avr/drivers/analog.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
extern "C" {
#endif
void analogReference(uint8_t mode);
int16_t analogRead(uint8_t pin);

int16_t analogReadPin(pin_t pin);
uint8_t pinToMux(pin_t pin);
Expand Down

0 comments on commit d977e5d

Please sign in to comment.