瀏覽代碼

Merge pull request #8622 from hg42/implement-LPC1768-GET_TIMER

[2.0.x][LPC1768][fix] Implement GET_TIMER and other GET_xxx, fixes PWM
Bob-the-Kuhn 7 年之前
父節點
當前提交
4c5356f77a
沒有連結到貢獻者的電子郵件帳戶。
共有 1 個檔案被更改,包括 17 行新增5 行删除
  1. 17
    5
      Marlin/src/HAL/HAL_LPC1768/fastio.h

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

85
 /// set pin as input with pullup mode
85
 /// set pin as input with pullup mode
86
 #define _PULLUP(IO, v) (pinMode(IO, (v!=LOW ? INPUT_PULLUP : INPUT)))
86
 #define _PULLUP(IO, v) (pinMode(IO, (v!=LOW ? INPUT_PULLUP : INPUT)))
87
 
87
 
88
+// hg42: all pins can be input or output (I hope)
89
+// hg42: undefined pins create compile error (IO, is no pin)
90
+// hg42: currently not used, but was used by pinsDebug
91
+
88
 /// check if pin is an input
92
 /// check if pin is an input
89
-#define _GET_INPUT(IO)
93
+#define _GET_INPUT(IO)        (LPC1768_PIN_PIN(IO)>=0)
94
+
90
 /// check if pin is an output
95
 /// check if pin is an output
91
-#define _GET_OUTPUT(IO)
96
+#define _GET_OUTPUT(IO)       (LPC1768_PIN_PIN(IO)>=0)
97
+
98
+// hg42: GET_TIMER is used only to check if it's a PWM pin
99
+// hg42: we cannot use USEABLE_HARDWARE_PWM because it uses a function that cannot be used statically
100
+// hg42: instead use PWM bit from the #define
92
 
101
 
93
 /// check if pin is an timer
102
 /// check if pin is an timer
94
-#define _GET_TIMER(IO)
103
+#define _GET_TIMER(IO)        TRUE  // could be LPC1768_PIN_PWM(IO), but there
104
+// hg42: could be this:
105
+// #define _GET_TIMER(IO)        LPC1768_PIN_PWM(IO)
106
+// but this is an incomplete check (12 pins are PWMable, but only 6 can be used at the same time)
95
 
107
 
96
 /// Read a pin wrapper
108
 /// Read a pin wrapper
97
 #define READ(IO)  _READ(IO)
109
 #define READ(IO)  _READ(IO)
111
 #define SET_OUTPUT(IO)  do{ _SET_OUTPUT(IO); _WRITE(IO, LOW); }while(0)
123
 #define SET_OUTPUT(IO)  do{ _SET_OUTPUT(IO); _WRITE(IO, LOW); }while(0)
112
 
124
 
113
 /// check if pin is an input wrapper
125
 /// check if pin is an input wrapper
114
-#define GET_INPUT(IO)  _GET_INPUT(IO) // todo: Never used?
126
+#define GET_INPUT(IO)  _GET_INPUT(IO)
115
 /// check if pin is an output wrapper
127
 /// check if pin is an output wrapper
116
-#define GET_OUTPUT(IO)  _GET_OUTPUT(IO) //todo: Never Used?
128
+#define GET_OUTPUT(IO)  _GET_OUTPUT(IO)
117
 
129
 
118
 /// check if pin is an timer wrapper
130
 /// check if pin is an timer wrapper
119
 #define GET_TIMER(IO)  _GET_TIMER(IO)
131
 #define GET_TIMER(IO)  _GET_TIMER(IO)

Loading…
取消
儲存