Skip to content
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

change digitalWrite() #133

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
23 changes: 10 additions & 13 deletions cores/arduino/wiring_digital.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,22 +145,19 @@ void digitalWrite(uint8_t pin, PinStatus val)
/* Get port */
PORT_t *port = digitalPinToPortStruct(pin);

/* Output direction */
if(port->DIR & bit_mask){

/* Set output to value */
if (val == LOW) { /* If LOW */
port->OUTCLR = bit_mask;
/* Set output to value */
if (val == LOW) { /* If LOW */
port->OUTCLR = bit_mask;

} else if (val == CHANGE) { /* If TOGGLE */
port->OUTTGL = bit_mask;
/* If HIGH OR > TOGGLE */
} else {
port->OUTSET = bit_mask;
}
} else if (val == CHANGE) { /* If TOGGLE */
port->OUTTGL = bit_mask;
/* If HIGH OR > TOGGLE */
} else {
port->OUTSET = bit_mask;
}

/* Input direction */
} else {
if(port->DIR & bit_mask){
/* Old implementation has side effect when pin set as input -
pull up is enabled if this function is called.
Should we purposely implement this side effect?
Expand Down
Loading