Browse Source

Set pinMode with every digitalWrite (legacy compatibility)

Bob-the-Kuhn 6 years ago
parent
commit
d80877d570
1 changed files with 10 additions and 0 deletions
  1. 10
    0
      Marlin/src/HAL/HAL_LPC1768/arduino.cpp

+ 10
- 0
Marlin/src/HAL/HAL_LPC1768/arduino.cpp View File

121
     LPC_GPIO(pin_map[pin].port)->FIOSET = LPC_PIN(pin_map[pin].pin);
121
     LPC_GPIO(pin_map[pin].port)->FIOSET = LPC_PIN(pin_map[pin].pin);
122
   else
122
   else
123
     LPC_GPIO(pin_map[pin].port)->FIOCLR = LPC_PIN(pin_map[pin].pin);
123
     LPC_GPIO(pin_map[pin].port)->FIOCLR = LPC_PIN(pin_map[pin].pin);
124
+
125
+  pinMode(pin, OUTPUT);  // Set pin mode on every write (Arduino version does this)
126
+
127
+    /**
128
+     * Must be done AFTER the output state is set. Doing this before will cause a
129
+     * 2uS glitch if writing a "1".
130
+     *
131
+     * When the Port Direction bit is written to a "1" the output is immediately set
132
+     * to the value of the FIOPIN bit which is "0" because of power up defaults.
133
+     */
124
 }
134
 }
125
 
135
 
126
 bool digitalRead(int pin) {
136
 bool digitalRead(int pin) {

Loading…
Cancel
Save