Skip to content

Commit

Permalink
update analogRead
Browse files Browse the repository at this point in the history
  • Loading branch information
xukangmin committed Oct 25, 2019
1 parent b9249ba commit 2d64c6e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
2 changes: 2 additions & 0 deletions avr/cores/tiny/Arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ extern const uint8_t PROGMEM digital_pin_to_bit_mask[];
extern const uint8_t PROGMEM digital_pin_to_bit_position[];
extern const uint8_t PROGMEM digital_pin_to_timer[];
extern const uint8_t PROGMEM touch_pin_to_channel[];
extern const uint8_t PROGMEM analog_pin_to_channel[];
// Get the bit location within the hardware port of the given virtual pin.
// This comes from the pins_*.c file for the active board configuration.
//
Expand Down Expand Up @@ -124,6 +125,7 @@ bool isDoubleBondedActive(uint8_t pin);
#define digitalPinToTouchPin(pin) ( (pin < NUM_TOTAL_PINS) ? pgm_read_byte(touch_pin_to_channel + pin) : NOT_A_PIN )
#define digitalPinToBitPosition(pin) ( (pin < NUM_TOTAL_PINS) ? pgm_read_byte(digital_pin_to_bit_position + pin) : NOT_A_PIN )
#define analogPinToBitPosition(pin) ( (digitalPinToAnalogInput(pin)!=NOT_A_PIN) ? pgm_read_byte(digital_pin_to_bit_position + pin + 0) : NOT_A_PIN )
#define digitalPinToAnalogInput(p) ((p < NUM_TOTAL_PINS) ? pgm_read_byte(analog_pin_to_channel + p) : NOT_A_PIN )
#define digitalPinToBitMask(pin) ( (pin < NUM_TOTAL_PINS) ? pgm_read_byte(digital_pin_to_bit_mask + pin) : NOT_A_PIN )
#define analogPinToBitMask(pin) ( (digitalPinToAnalogInput(pin)!=NOT_A_PIN) ? pgm_read_byte(digital_pin_to_bit_mask + pin + 0) : NOT_A_PIN )
#define digitalPinToTimer(pin) ( (pin < NUM_TOTAL_PINS) ? pgm_read_byte(digital_pin_to_timer + pin) : NOT_ON_TIMER )
Expand Down
2 changes: 0 additions & 2 deletions avr/variants/tiny16/pins_arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,6 @@ const uint8_t PROGMEM touch_pin_to_channel[] = {
3 // 16 PA7
};

#define digitalPinToAnalogInput(p) ((p < NUM_TOTAL_PINS) ? pgm_read_byte(analog_pin_to_channel + p) : NOT_A_PIN )

#endif


Expand Down
6 changes: 2 additions & 4 deletions avr/variants/tiny32/pins_arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
//#define NUM_INTERNALLY_USED_PINS 0 // (2 x Chip select + 2 x UART + 4 x IO + LED_BUILTIN + 1 unused pin)
#define NUM_I2C_PINS 2 // (SDA / SCL)
#define NUM_SPI_PINS 3 // (MISO / MOSI / SCK)
#define NUM_TOTAL_PINS 18
#define NUM_TOTAL_PINS 21

#define EXTERNAL_NUM_INTERRUPTS 18
#define EXTERNAL_NUM_INTERRUPTS 21

#if (defined(TCD0) && defined(USE_TIMERD0_PWM))
#define digitalPinHasPWM(p) ((p) == 1 || (p) == 2 || (p) == 3 || (p) == 6 || (p) == 7 || (p)==12 || (p)==13 || (p) == 14 )
Expand Down Expand Up @@ -300,8 +300,6 @@ const uint8_t PROGMEM touch_pin_to_channel[] = {
11 // 20 PC5
};

#define digitalPinToAnalogInput(p) ((p < NUM_TOTAL_PINS) ? pgm_read_byte(analog_pin_to_channel + p) : NOT_A_PIN )

#endif

//extern const uint8_t analog_pin_to_channel[];
Expand Down

0 comments on commit 2d64c6e

Please sign in to comment.