Skip to content

Commit

Permalink
Set pinMode with every digitalWrite (legacy compatibility)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bob-the-Kuhn committed Aug 8, 2017
1 parent 4ab72e9 commit c587d27
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Marlin/src/HAL/HAL_LPC1768/arduino.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,16 @@ void digitalWrite(int pin, int pin_status) {
LPC_GPIO(pin_map[pin].port)->FIOSET = LPC_PIN(pin_map[pin].pin);
else
LPC_GPIO(pin_map[pin].port)->FIOCLR = LPC_PIN(pin_map[pin].pin);

pinMode(pin, OUTPUT); // Set pin mode on every write (Arduino version does this)

/**
* Must be done AFTER the output state is set. Doing this before will cause a
* 2uS glitch if writing a "1".
*
* When the Port Direction bit is written to a "1" the output is immediately set
* to the value of the FIOPIN bit which is "0" because of power up defaults.
*/
}

bool digitalRead(int pin) {
Expand Down

0 comments on commit c587d27

Please sign in to comment.