From 33056046a3938d9f8f814f1a0a87d69c6c807b58 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 6 Oct 2018 00:14:12 -0500 Subject: [PATCH] STM32 non-generic PWM_PIN and USEABLE_HARDWARE_PWM (#12016) --- Marlin/src/HAL/HAL_DUE/fastio_Due.h | 2 +- Marlin/src/HAL/HAL_STM32/fastio_STM32.h | 5 +++-- Marlin/src/HAL/HAL_STM32F1/fastio_Stm32f1.h | 6 ++---- Marlin/src/HAL/HAL_STM32F4/fastio_STM32F4.h | 8 ++++++-- Marlin/src/HAL/HAL_STM32F7/fastio_STM32F7.h | 6 ++++++ buildroot/share/tests/STM32F1_tests | 5 ++++- 6 files changed, 22 insertions(+), 10 deletions(-) diff --git a/Marlin/src/HAL/HAL_DUE/fastio_Due.h b/Marlin/src/HAL/HAL_DUE/fastio_Due.h index bb25f4517..607e2a05a 100644 --- a/Marlin/src/HAL/HAL_DUE/fastio_Due.h +++ b/Marlin/src/HAL/HAL_DUE/fastio_Due.h @@ -47,7 +47,7 @@ // Due has 12 PWMs assigned to logical pins 2-13. // 6, 7, 8 & 9 come from the PWM controller. The others come from the timers. -#define USEABLE_HARDWARE_PWM(p) ((2 <= p) && (p <= 13)) +#define USEABLE_HARDWARE_PWM(p) WITHIN(p, 2, 13) #ifndef MASK #define MASK(PIN) (1 << PIN) diff --git a/Marlin/src/HAL/HAL_STM32/fastio_STM32.h b/Marlin/src/HAL/HAL_STM32/fastio_STM32.h index e2413e168..1287976c7 100644 --- a/Marlin/src/HAL/HAL_STM32/fastio_STM32.h +++ b/Marlin/src/HAL/HAL_STM32/fastio_STM32.h @@ -29,8 +29,6 @@ #define _BV(b) (1 << (b)) -#define USEABLE_HARDWARE_PWM(p) true - #define READ(IO) digitalRead(IO) #define WRITE(IO,V) digitalWrite(IO,V) #define WRITE_VAR(IO,V) WRITE(IO,V) @@ -51,3 +49,6 @@ #define GET_INPUT(IO) #define GET_OUTPUT(IO) #define GET_TIMER(IO) + +#define PWM_PIN(p) true +#define USEABLE_HARDWARE_PWM(p) PWM_PIN(p) diff --git a/Marlin/src/HAL/HAL_STM32F1/fastio_Stm32f1.h b/Marlin/src/HAL/HAL_STM32F1/fastio_Stm32f1.h index d6683e36e..117d4c00b 100644 --- a/Marlin/src/HAL/HAL_STM32F1/fastio_Stm32f1.h +++ b/Marlin/src/HAL/HAL_STM32F1/fastio_Stm32f1.h @@ -50,9 +50,7 @@ #define GET_OUTPUT(IO) (_GET_MODE(IO) == GPIO_OUTPUT_PP) #define GET_TIMER(IO) (PIN_MAP[IO].timer_device != NULL) -/** - * TODO: Write a macro to test if PIN is PWM or not. - */ -#define PWM_PIN(p) true +#define PWM_PIN(p) digitalPinHasPWM(p) +#define USEABLE_HARDWARE_PWM(p) PWM_PIN(p) #endif // _FASTIO_STM32F1_H diff --git a/Marlin/src/HAL/HAL_STM32F4/fastio_STM32F4.h b/Marlin/src/HAL/HAL_STM32F4/fastio_STM32F4.h index d102e64f7..14596e8fb 100644 --- a/Marlin/src/HAL/HAL_STM32F4/fastio_STM32F4.h +++ b/Marlin/src/HAL/HAL_STM32F4/fastio_STM32F4.h @@ -32,8 +32,6 @@ #undef _BV #define _BV(b) (1 << (b)) -#define USEABLE_HARDWARE_PWM(p) true - #define READ(IO) digitalRead(IO) #define WRITE(IO,V) digitalWrite(IO,V) #define WRITE_VAR(IO,V) WRITE(IO,V) @@ -55,6 +53,12 @@ #define GET_OUTPUT(IO) #define GET_TIMER(IO) +#define PWM_PIN(p) digitalPinHasPWM(p) +#define USEABLE_HARDWARE_PWM(p) PWM_PIN(p) + +// +// Pins Definitions +// #define PORTA 0 #define PORTB 1 #define PORTC 2 diff --git a/Marlin/src/HAL/HAL_STM32F7/fastio_STM32F7.h b/Marlin/src/HAL/HAL_STM32F7/fastio_STM32F7.h index 2d82530b8..0422bf47a 100644 --- a/Marlin/src/HAL/HAL_STM32F7/fastio_STM32F7.h +++ b/Marlin/src/HAL/HAL_STM32F7/fastio_STM32F7.h @@ -52,6 +52,12 @@ #define GET_OUTPUT(IO) #define GET_TIMER(IO) +#define PWM_PIN(p) digitalPinHasPWM(p) +#define USEABLE_HARDWARE_PWM(p) PWM_PIN(p) + +// +// Pins Definitions +// #define PORTA 0 #define PORTB 1 #define PORTC 2 diff --git a/buildroot/share/tests/STM32F1_tests b/buildroot/share/tests/STM32F1_tests index 0d1fd9099..283e68d9b 100755 --- a/buildroot/share/tests/STM32F1_tests +++ b/buildroot/share/tests/STM32F1_tests @@ -8,5 +8,8 @@ opt_set MOTHERBOARD BOARD_STM32F1R opt_enable EEPROM_SETTINGS EEPROM_CHITCHAT REPRAP_DISCOUNT_SMART_CONTROLLER SDSUPPORT exec_test $1 $2 "STM32F1R EEPROM_SETTINGS EEPROM_CHITCHAT REPRAP_DISCOUNT_SMART_CONTROLLER SDSUPPORT" -#cleanup +opt_enable SPINDLE_LASER_ENABLE +exec_test $1 $2 "STM32F1R SPINDLE_LASER_ENABLE" + +# cleanup restore_configs