Skip to content

Added digitalWrite(pin, TOGGLE) #111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion build/shared/lib/keywords.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# LITERAL1 specifies constants

HIGH LITERAL1 Constants
LOW LITERAL1 Constants
HIGH LITERAL1 Constants
TOGGLE LITERAL1 Constants
INPUT LITERAL1 Constants
INPUT_PULLUP LITERAL1 Constants
OUTPUT LITERAL1 Constants
Expand Down
5 changes: 3 additions & 2 deletions hardware/arduino/cores/arduino/Arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
extern "C"{
#endif

#define HIGH 0x1
#define LOW 0x0

#define HIGH 0x1
#define TOGGLE 0x2

#define INPUT 0x0
#define OUTPUT 0x1
#define INPUT_PULLUP 0x2
Expand Down
7 changes: 4 additions & 3 deletions hardware/arduino/cores/arduino/wiring_digital.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,12 @@ void digitalWrite(uint8_t pin, uint8_t val)
uint8_t oldSREG = SREG;
cli();

if (val == LOW) {
if (val == LOW)
*out &= ~bit;
} else {
else if (val == TOGGLE)
*out ^= bit;
else
*out |= bit;
}

SREG = oldSREG;
}
Expand Down