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