Skip to content

Commit 043555a

Browse files
committed
Added digitalWrite(pin, TOGGLE)
1 parent 36b5d52 commit 043555a

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

build/shared/lib/keywords.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# LITERAL1 specifies constants
22

3-
HIGH LITERAL1 Constants
43
LOW LITERAL1 Constants
4+
HIGH LITERAL1 Constants
5+
TOGGLE LITERAL1 Constants
56
INPUT LITERAL1 Constants
67
INPUT_PULLUP LITERAL1 Constants
78
OUTPUT LITERAL1 Constants

hardware/arduino/cores/arduino/Arduino.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
1515
extern "C"{
1616
#endif
1717

18-
#define HIGH 0x1
1918
#define LOW 0x0
20-
19+
#define HIGH 0x1
20+
#define TOGGLE 0x2
21+
2122
#define INPUT 0x0
2223
#define OUTPUT 0x1
2324
#define INPUT_PULLUP 0x2

hardware/arduino/cores/arduino/wiring_digital.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,12 @@ void digitalWrite(uint8_t pin, uint8_t val)
152152
uint8_t oldSREG = SREG;
153153
cli();
154154

155-
if (val == LOW) {
155+
if (val == LOW)
156156
*out &= ~bit;
157-
} else {
157+
else if (val == TOGGLE)
158+
*out ^= bit;
159+
else
158160
*out |= bit;
159-
}
160161

161162
SREG = oldSREG;
162163
}

0 commit comments

Comments
 (0)