瀏覽代碼

Fix SET_OUTPUT glitch - LPC1768 & DUE

Bob-the-Kuhn 7 年之前
父節點
當前提交
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
 #define _TOGGLE(IO)  _WRITE(IO, !READ(IO))
78
 #define _TOGGLE(IO)  _WRITE(IO, !READ(IO))
79
 
79
 
80
 /// set pin as input
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
 /// set pin as output
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
 /// set pin as input with pullup mode
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
 /// check if pin is an input
93
 /// check if pin is an input
91
 #define _GET_INPUT(IO)
94
 #define _GET_INPUT(IO)
109
 #define SET_INPUT(IO)  _SET_INPUT(IO)
112
 #define SET_INPUT(IO)  _SET_INPUT(IO)
110
 /// set pin as input with pullup wrapper
113
 /// set pin as input with pullup wrapper
111
 #define SET_INPUT_PULLUP(IO) do{ _SET_INPUT(IO); _PULLUP(IO, HIGH); }while(0)
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
 /// check if pin is an input wrapper
117
 /// check if pin is an input wrapper
116
 #define GET_INPUT(IO)  _GET_INPUT(IO)
118
 #define GET_INPUT(IO)  _GET_INPUT(IO)
117
 /// check if pin is an output wrapper
119
 /// check if pin is an output wrapper

+ 2
- 2
Marlin/src/HAL/HAL_LPC1768/fastio.h 查看文件

119
 #define SET_INPUT(IO)  _SET_INPUT(IO)
119
 #define SET_INPUT(IO)  _SET_INPUT(IO)
120
 /// set pin as input with pullup wrapper
120
 /// set pin as input with pullup wrapper
121
 #define SET_INPUT_PULLUP(IO) do{ _SET_INPUT(IO); _PULLUP(IO, HIGH); }while(0)
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
 /// check if pin is an input wrapper
125
 /// check if pin is an input wrapper
126
 #define GET_INPUT(IO)  _GET_INPUT(IO)
126
 #define GET_INPUT(IO)  _GET_INPUT(IO)

Loading…
取消
儲存