Quellcode durchsuchen

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 vor 7 Jahren
Ursprung
Commit
4c5356f77a
Es ist kein Account mit der E-Mail-Adresse des Committers verbunden
1 geänderte Dateien mit 17 neuen und 5 gelöschten Zeilen
  1. 17
    5
      Marlin/src/HAL/HAL_LPC1768/fastio.h

+ 17
- 5
Marlin/src/HAL/HAL_LPC1768/fastio.h Datei anzeigen

@@ -85,13 +85,25 @@ bool useable_hardware_PWM(pin_t pin);
85 85
 /// set pin as input with pullup mode
86 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 92
 /// check if pin is an input
89
-#define _GET_INPUT(IO)
93
+#define _GET_INPUT(IO)        (LPC1768_PIN_PIN(IO)>=0)
94
+
90 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 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 108
 /// Read a pin wrapper
97 109
 #define READ(IO)  _READ(IO)
@@ -111,9 +123,9 @@ bool useable_hardware_PWM(pin_t pin);
111 123
 #define SET_OUTPUT(IO)  do{ _SET_OUTPUT(IO); _WRITE(IO, LOW); }while(0)
112 124
 
113 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 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 130
 /// check if pin is an timer wrapper
119 131
 #define GET_TIMER(IO)  _GET_TIMER(IO)

Laden…
Abbrechen
Speichern