Преглед на файлове

Fix SET_OUTPUT glitch - LPC1768 & DUE

Bob-the-Kuhn преди 6 години
родител
ревизия
1a948cbd93
променени са 2 файла, в които са добавени 12 реда и са изтрити 10 реда
  1. 10
    8
      Marlin/src/HAL/HAL_DUE/fastio_Due.h
  2. 2
    2
      Marlin/src/HAL/HAL_LPC1768/fastio.h

+ 10
- 8
Marlin/src/HAL/HAL_DUE/fastio_Due.h Целия файл

@@ -78,14 +78,17 @@
78 78
 #define _TOGGLE(IO)  _WRITE(IO, !READ(IO))
79 79
 
80 80
 /// set pin as input
81
-#define _SET_INPUT(IO)  pmc_enable_periph_clk(g_APinDescription[IO].ulPeripheralId); \
82
-                        PIO_Configure(g_APinDescription[IO].pPort, PIO_INPUT, g_APinDescription[IO].ulPin, 0)
81
+#define _SET_INPUT(IO)  do{ pmc_enable_periph_clk(g_APinDescription[IO].ulPeripheralId); \
82
+                            PIO_Configure(g_APinDescription[IO].pPort, PIO_INPUT, g_APinDescription[IO].ulPin, 0); \
83
+                        }while(0)
83 84
 /// set pin as output
84
-#define _SET_OUTPUT(IO)  PIO_Configure(g_APinDescription[IO].pPort, PIO_OUTPUT_1, \
85
-                         g_APinDescription[IO].ulPin, g_APinDescription[IO].ulPinConfiguration)
85
+#define _SET_OUTPUT(IO) do{ pmc_enable_periph_clk(g_APinDescription[IO].ulPeripheralId); \
86
+                            PIO_Configure(g_APinDescription[IO].pPort, _READ(IO) ? PIO_OUTPUT_1 : PIO_OUTPUT_0, \
87
+                                          g_APinDescription[IO].ulPin, g_APinDescription[IO].ulPinConfiguration); \
88
+                        }while(0)
86 89
 
87 90
 /// set pin as input with pullup mode
88
-#define _PULLUP(IO, v)  { pinMode(IO, (v!=LOW ? INPUT_PULLUP : INPUT)); }
91
+#define _PULLUP(IO, v)  { pinMode(IO, v != LOW ? INPUT_PULLUP : INPUT); }
89 92
 
90 93
 /// check if pin is an input
91 94
 #define _GET_INPUT(IO)
@@ -109,9 +112,8 @@
109 112
 #define SET_INPUT(IO)  _SET_INPUT(IO)
110 113
 /// set pin as input with pullup wrapper
111 114
 #define SET_INPUT_PULLUP(IO) do{ _SET_INPUT(IO); _PULLUP(IO, HIGH); }while(0)
112
-/// set pin as output wrapper
113
-#define SET_OUTPUT(IO)  do{ _SET_OUTPUT(IO); _WRITE(IO, LOW); }while(0)
114
-
115
+/// set pin as output wrapper -  reads the pin and sets the output to that value
116
+#define SET_OUTPUT(IO)  _SET_OUTPUT(IO)
115 117
 /// check if pin is an input wrapper
116 118
 #define GET_INPUT(IO)  _GET_INPUT(IO)
117 119
 /// check if pin is an output wrapper

+ 2
- 2
Marlin/src/HAL/HAL_LPC1768/fastio.h Целия файл

@@ -119,8 +119,8 @@ bool useable_hardware_PWM(pin_t pin);
119 119
 #define SET_INPUT(IO)  _SET_INPUT(IO)
120 120
 /// set pin as input with pullup wrapper
121 121
 #define SET_INPUT_PULLUP(IO) do{ _SET_INPUT(IO); _PULLUP(IO, HIGH); }while(0)
122
-/// set pin as output wrapper
123
-#define SET_OUTPUT(IO)  do{ _SET_OUTPUT(IO); _WRITE(IO, LOW); }while(0)
122
+/// set pin as output wrapper  -  reads the pin and sets the output to that value
123
+#define SET_OUTPUT(IO)  do{ _WRITE(IO, _READ(IO)); _SET_OUTPUT(IO); }while(0)
124 124
 
125 125
 /// check if pin is an input wrapper
126 126
 #define GET_INPUT(IO)  _GET_INPUT(IO)

Loading…
Отказ
Запис