Browse Source

[LPC176x] Update fastio _GET_INPUT, _GET_OUTPUT macros (#11168)

Chris Pepper 7 years ago
parent
commit
5616581eb1
1 changed files with 4 additions and 14 deletions
  1. 4
    14
      Marlin/src/HAL/HAL_LPC1768/fastio.h

+ 4
- 14
Marlin/src/HAL/HAL_LPC1768/fastio.h View File

88
 /// set pin as input with pulldown mode
88
 /// set pin as input with pulldown mode
89
 #define _PULLDOWN(IO,V)   pinMode(IO, (V) ? INPUT_PULLDOWN : INPUT)
89
 #define _PULLDOWN(IO,V)   pinMode(IO, (V) ? INPUT_PULLDOWN : INPUT)
90
 
90
 
91
-// hg42: all pins can be input or output (I hope)
92
-// hg42: undefined pins create compile error (IO, is no pin)
93
-// hg42: currently not used, but was used by pinsDebug
94
-
95
 /// check if pin is an input
91
 /// check if pin is an input
96
-#define _GET_INPUT(IO)    (LPC1768_PIN_PIN(IO) >= 0)
92
+#define _GET_INPUT(IO)    (LPC_GPIO(LPC1768_PIN_PORT(IO))->FIODIR & LPC_PIN(LPC1768_PIN_PIN(IO)) != 0)
97
 
93
 
98
 /// check if pin is an output
94
 /// check if pin is an output
99
-#define _GET_OUTPUT(IO)   (LPC1768_PIN_PIN(IO) >= 0)
100
-
101
-// hg42: GET_TIMER is used only to check if it's a PWM pin
102
-// hg42: we cannot use USEABLE_HARDWARE_PWM because it uses a function that cannot be used statically
103
-// hg42: instead use PWM bit from the #define
95
+#define _GET_OUTPUT(IO)   (LPC_GPIO(LPC1768_PIN_PORT(IO))->FIODIR & LPC_PIN(LPC1768_PIN_PIN(IO)) == 0)
104
 
96
 
105
 /// check if pin is a timer
97
 /// check if pin is a timer
106
-#define _GET_TIMER(IO)    TRUE  // could be LPC1768_PIN_PWM(IO), but there
107
-// hg42: could be this:
108
-// #define _GET_TIMER(IO)        LPC1768_PIN_PWM(IO)
109
-// but this is an incomplete check (12 pins are PWMable, but only 6 can be used at the same time)
98
+/// all gpio pins are pwm capable, either interrupt or hardware pwm controlled
99
+#define _GET_TIMER(IO)    TRUE
110
 
100
 
111
 /// Read a pin wrapper
101
 /// Read a pin wrapper
112
 #define READ(IO)          _READ(IO)
102
 #define READ(IO)          _READ(IO)

Loading…
Cancel
Save