Skip to content

Commit eb1a845

Browse files
Roy, ElizabethRoy, Elizabeth
authored andcommitted
Bug fix: check for activity on double bonded pins
1 parent e8ac9c0 commit eb1a845

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

cores/arduino/wiring_analog.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ void analogReference(uint8_t mode)
6969
int analogRead(uint8_t pin)
7070
{
7171
if(pin > NUM_ANALOG_INPUTS) return NOT_A_PIN;
72+
73+
/* Check if TWI is operating on double bonded pin */
74+
if(((pin == PIN_A4) || (pin == PIN_A5)) && (TWI0.MCTRLA & TWI_ENABLE_bm)) return 0;
7275

7376
uint8_t low, high;
7477

@@ -117,6 +120,9 @@ void analogWrite(uint8_t pin, int val)
117120
uint8_t bit_pos = digitalPinToBitPosition(pin);
118121
if(bit_pos == NOT_A_PIN) return;
119122

123+
/* Special check for SPI_SS double bonded pin -- no action if SPI is active */
124+
if((pin == 10) && (SPI0.CTRLB & SPI_SSD_bm)) return;
125+
120126
// We need to make sure the PWM output is enabled for those pins
121127
// that support it, as we turn it off when digitally reading or
122128
// writing with them. Also, make sure the pin is in output mode

0 commit comments

Comments
 (0)