Skip to content

Commit 4950f4f

Browse files
Roy, ElizabethRoy, Elizabeth
authored andcommitted
Added comments to indicate how activity is detected on the TWI and SPI
1 parent eb1a845 commit 4950f4f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

cores/arduino/wiring_analog.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ int analogRead(uint8_t pin)
7070
{
7171
if(pin > NUM_ANALOG_INPUTS) return NOT_A_PIN;
7272

73-
/* Check if TWI is operating on double bonded pin */
73+
/* Check if TWI is operating on double bonded pin (Master Enable is high
74+
in both Master and Slave mode for bus error detection, so this can
75+
indicate an active state for Wire) */
7476
if(((pin == PIN_A4) || (pin == PIN_A5)) && (TWI0.MCTRLA & TWI_ENABLE_bm)) return 0;
7577

7678
uint8_t low, high;
@@ -120,7 +122,8 @@ void analogWrite(uint8_t pin, int val)
120122
uint8_t bit_pos = digitalPinToBitPosition(pin);
121123
if(bit_pos == NOT_A_PIN) return;
122124

123-
/* Special check for SPI_SS double bonded pin -- no action if SPI is active */
125+
/* Special check for SPI_SS double bonded pin -- no action if SPI is active
126+
(Using Slave Select Disable as indicator of SPI activity) */
124127
if((pin == 10) && (SPI0.CTRLB & SPI_SSD_bm)) return;
125128

126129
// We need to make sure the PWM output is enabled for those pins

0 commit comments

Comments
 (0)