From d1f11e9c10c7d2800485f853158a2c3e51e4bce9 Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 1 Dec 2017 22:18:28 +0100 Subject: [PATCH 1/2] fix missing GET_TIMER (used by PWM for Ex_AUTO_FAN) --- Marlin/src/HAL/HAL_LPC1768/fastio.h | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Marlin/src/HAL/HAL_LPC1768/fastio.h b/Marlin/src/HAL/HAL_LPC1768/fastio.h index 2da989a9c8..a390810fca 100644 --- a/Marlin/src/HAL/HAL_LPC1768/fastio.h +++ b/Marlin/src/HAL/HAL_LPC1768/fastio.h @@ -85,13 +85,22 @@ bool useable_hardware_PWM(pin_t pin); /// set pin as input with pullup mode #define _PULLUP(IO, v) (pinMode(IO, (v!=LOW ? INPUT_PULLUP : INPUT))) +// hg42: all pins can be input or output (I hope) +// hg42: undefined pins create compile error (IO, is no pin) +// hg42: currently not used, but was used by pinsDebug + /// check if pin is an input -#define _GET_INPUT(IO) +#define _GET_INPUT(IO) (LPC1768_PIN_PIN(IO)>=0) + /// check if pin is an output -#define _GET_OUTPUT(IO) +#define _GET_OUTPUT(IO) (LPC1768_PIN_PIN(IO)>=0) + +// hg42: GET_TIMER is used only to check if it's a PWM pin +// hg42: we cannot use USEABLE_HARDWARE_PWM because it uses a function that cannot be used statically +// hg42: instead use PWM bit from the #define /// check if pin is an timer -#define _GET_TIMER(IO) +#define _GET_TIMER(IO) LPC1768_PIN_PWM(IO) /// Read a pin wrapper #define READ(IO) _READ(IO) @@ -111,9 +120,9 @@ bool useable_hardware_PWM(pin_t pin); #define SET_OUTPUT(IO) do{ _SET_OUTPUT(IO); _WRITE(IO, LOW); }while(0) /// check if pin is an input wrapper -#define GET_INPUT(IO) _GET_INPUT(IO) // todo: Never used? +#define GET_INPUT(IO) _GET_INPUT(IO) /// check if pin is an output wrapper -#define GET_OUTPUT(IO) _GET_OUTPUT(IO) //todo: Never Used? +#define GET_OUTPUT(IO) _GET_OUTPUT(IO) /// check if pin is an timer wrapper #define GET_TIMER(IO) _GET_TIMER(IO) From f5b4e1ef4f121b26eab42dcd66bb79d0b0948650 Mon Sep 17 00:00:00 2001 From: Harald Gutsche Date: Sun, 3 Dec 2017 20:37:02 +0100 Subject: [PATCH 2/2] as a workaround enable PWM for any pin, see PR #8622 --- Marlin/src/HAL/HAL_LPC1768/fastio.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Marlin/src/HAL/HAL_LPC1768/fastio.h b/Marlin/src/HAL/HAL_LPC1768/fastio.h index a390810fca..cc215f5256 100644 --- a/Marlin/src/HAL/HAL_LPC1768/fastio.h +++ b/Marlin/src/HAL/HAL_LPC1768/fastio.h @@ -100,7 +100,10 @@ bool useable_hardware_PWM(pin_t pin); // hg42: instead use PWM bit from the #define /// check if pin is an timer -#define _GET_TIMER(IO) LPC1768_PIN_PWM(IO) +#define _GET_TIMER(IO) TRUE // could be LPC1768_PIN_PWM(IO), but there +// hg42: could be this: +// #define _GET_TIMER(IO) LPC1768_PIN_PWM(IO) +// but this is an incomplete check (12 pins are PWMable, but only 6 can be used at the same time) /// Read a pin wrapper #define READ(IO) _READ(IO)