Skip to content

Commit 48305e2

Browse files
committed
change digitalWrite()
1 parent 5e639ee commit 48305e2

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

Diff for: cores/arduino/wiring_digital.c

+10-13
Original file line numberDiff line numberDiff line change
@@ -145,22 +145,19 @@ void digitalWrite(uint8_t pin, PinStatus val)
145145
/* Get port */
146146
PORT_t *port = digitalPinToPortStruct(pin);
147147

148-
/* Output direction */
149-
if(port->DIR & bit_mask){
150-
151-
/* Set output to value */
152-
if (val == LOW) { /* If LOW */
153-
port->OUTCLR = bit_mask;
148+
/* Set output to value */
149+
if (val == LOW) { /* If LOW */
150+
port->OUTCLR = bit_mask;
154151

155-
} else if (val == CHANGE) { /* If TOGGLE */
156-
port->OUTTGL = bit_mask;
157-
/* If HIGH OR > TOGGLE */
158-
} else {
159-
port->OUTSET = bit_mask;
160-
}
152+
} else if (val == CHANGE) { /* If TOGGLE */
153+
port->OUTTGL = bit_mask;
154+
/* If HIGH OR > TOGGLE */
155+
} else {
156+
port->OUTSET = bit_mask;
157+
}
161158

162159
/* Input direction */
163-
} else {
160+
if(port->DIR & bit_mask){
164161
/* Old implementation has side effect when pin set as input -
165162
pull up is enabled if this function is called.
166163
Should we purposely implement this side effect?

0 commit comments

Comments
 (0)