Clean up fastIO ahead of PWM patch
This commit is contained in:
parent
388babbcea
commit
51ff5b68fa
|
@ -273,16 +273,15 @@ enum ClockSource2 : char {
|
||||||
#define SET_FOCB(T,V) SET_FOC(T,B,V)
|
#define SET_FOCB(T,V) SET_FOC(T,B,V)
|
||||||
#define SET_FOCC(T,V) SET_FOC(T,C,V)
|
#define SET_FOCC(T,V) SET_FOC(T,C,V)
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PWM availability macros
|
* PWM availability macros
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Determine which harware PWMs are already in use
|
// Determine which harware PWMs are already in use
|
||||||
#if PIN_EXISTS(CONTROLLER_FAN)
|
#if PIN_EXISTS(CONTROLLER_FAN)
|
||||||
#define PWM_CHK_FAN_B(p) (p == CONTROLLER_FAN_PIN || p == E0_AUTO_FAN_PIN || p == E1_AUTO_FAN_PIN || p == E2_AUTO_FAN_PIN || p == E3_AUTO_FAN_PIN || p == E4_AUTO_FAN_PIN || p == CHAMBER_AUTO_FAN_PIN)
|
#define PWM_CHK_FAN_B(p) (p == CONTROLLER_FAN_PIN || p == E0_AUTO_FAN_PIN || p == E1_AUTO_FAN_PIN || p == E2_AUTO_FAN_PIN || p == E3_AUTO_FAN_PIN || p == E4_AUTO_FAN_PIN || p == E5_AUTO_FAN_PIN || p == CHAMBER_AUTO_FAN_PIN)
|
||||||
#else
|
#else
|
||||||
#define PWM_CHK_FAN_B(p) (p == E0_AUTO_FAN_PIN || p == E1_AUTO_FAN_PIN || p == E2_AUTO_FAN_PIN || p == E3_AUTO_FAN_PIN || p == E4_AUTO_FAN_PIN || p == CHAMBER_AUTO_FAN_PIN)
|
#define PWM_CHK_FAN_B(p) (p == E0_AUTO_FAN_PIN || p == E1_AUTO_FAN_PIN || p == E2_AUTO_FAN_PIN || p == E3_AUTO_FAN_PIN || p == E4_AUTO_FAN_PIN || p == E5_AUTO_FAN_PIN || p == CHAMBER_AUTO_FAN_PIN)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if PIN_EXISTS(FAN) || PIN_EXISTS(FAN1) || PIN_EXISTS(FAN2)
|
#if PIN_EXISTS(FAN) || PIN_EXISTS(FAN1) || PIN_EXISTS(FAN2)
|
||||||
|
@ -335,24 +334,22 @@ enum ClockSource2 : char {
|
||||||
#define PWM_CHK_HEATER(p) false
|
#define PWM_CHK_HEATER(p) false
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define PWM_CHK(p) (PWM_CHK_HEATER(p) || PWM_CHK_SERVO(p) || PWM_CHK_MOTOR_CURRENT(p)\
|
#define PWM_CHK(p) (PWM_CHK_HEATER(p) || PWM_CHK_SERVO(p) || PWM_CHK_MOTOR_CURRENT(p) || PWM_CHK_FAN_A(p) || PWM_CHK_FAN_B(p))
|
||||||
|| PWM_CHK_FAN_A(p) || PWM_CHK_FAN_B(p))
|
|
||||||
|
|
||||||
// define which hardware PWMs are available for the current CPU
|
// define which hardware PWMs are available for the current CPU
|
||||||
// all timer 1 PWMS deleted from this list because they are never available
|
// all timer 1 PWMS deleted from this list because they are never available
|
||||||
#if AVR_ATmega2560_FAMILY
|
#if AVR_ATmega2560_FAMILY
|
||||||
#define PWM_PINS(p) ((p >= 2 && p <= 10) || p == 13 || p == 44 || p == 45 || p == 46)
|
#define PWM_PIN(p) ((p >= 2 && p <= 10) || p == 13 || p == 44 || p == 45 || p == 46)
|
||||||
#elif AVR_ATmega2561_FAMILY
|
#elif AVR_ATmega2561_FAMILY
|
||||||
#define PWM_PINS(p) ((p >= 2 && p <= 6) || p == 9)
|
#define PWM_PIN(p) ((p >= 2 && p <= 6) || p == 9)
|
||||||
#elif AVR_ATmega1284_FAMILY
|
#elif AVR_ATmega1284_FAMILY
|
||||||
#define PWM_PINS(p) (p == 3 || p == 4 || p == 14 || p == 15)
|
#define PWM_PIN(p) (p == 3 || p == 4 || p == 14 || p == 15)
|
||||||
#elif AVR_AT90USB1286_FAMILY
|
#elif AVR_AT90USB1286_FAMILY
|
||||||
#define PWM_PINS(p) (p == 0 || p == 1 || p == 14 || p == 15 || p == 16 || p == 24)
|
#define PWM_PIN(p) (p == 0 || p == 1 || p == 14 || p == 15 || p == 16 || p == 24)
|
||||||
#elif AVR_ATmega328_FAMILY
|
#elif AVR_ATmega328_FAMILY
|
||||||
#define PWM_PINS(p) (p == 3 || p == 5 || p == 6 || p == 11)
|
#define PWM_PIN(p) (p == 3 || p == 5 || p == 6 || p == 11)
|
||||||
#else
|
#else
|
||||||
#error "unknown CPU"
|
#error "unknown CPU"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// finally - the macro that tells us if a pin is an available hardware PWM
|
#define USEABLE_HARDWARE_PWM(P) (PWM_PIN(P) && !PWM_CHK(p))
|
||||||
#define USEABLE_HARDWARE_PWM(p) (PWM_PINS(p) && !PWM_CHK(p))
|
|
||||||
|
|
|
@ -174,9 +174,9 @@
|
||||||
#define SET_OUTPUT(IO) _SET_OUTPUT(IO)
|
#define SET_OUTPUT(IO) _SET_OUTPUT(IO)
|
||||||
|
|
||||||
// Check if pin is an input
|
// Check if pin is an input
|
||||||
#define GET_INPUT(IO) !(digitalPinToPort(IO)->PIO_OSR & digitalPinToBitMask(IO))
|
#define GET_INPUT(IO) ((digitalPinToPort(IO)->PIO_OSR & digitalPinToBitMask(IO)) == 0)
|
||||||
// Check if pin is an output
|
// Check if pin is an output
|
||||||
#define GET_OUTPUT(IO) !!(digitalPinToPort(IO)->PIO_OSR & digitalPinToBitMask(IO))
|
#define GET_OUTPUT(IO) ((digitalPinToPort(IO)->PIO_OSR & digitalPinToBitMask(IO)) != 0)
|
||||||
// Check if pin is a timer - Must be a constexpr
|
// Check if pin is a timer - Must be a constexpr
|
||||||
#define GET_TIMER(IO) ((IO) >= 2 && (IO) <= 13)
|
#define GET_TIMER(IO) ((IO) >= 2 && (IO) <= 13)
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,7 @@
|
||||||
// hg42: instead use PWM bit from the #define
|
// hg42: instead use PWM bit from the #define
|
||||||
|
|
||||||
/// check if pin is a timer
|
/// check if pin is a timer
|
||||||
#define _GET_TIMER(IO) TRUE // could be LPC1768_PIN_PWM(IO), but there
|
#define _GET_TIMER(IO) true // could be LPC1768_PIN_PWM(IO), but there
|
||||||
// hg42: could be this:
|
// hg42: could be this:
|
||||||
// #define _GET_TIMER(IO) LPC1768_PIN_PWM(IO)
|
// #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)
|
// but this is an incomplete check (12 pins are PWMable, but only 6 can be used at the same time)
|
||||||
|
|
|
@ -35,7 +35,8 @@
|
||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
#define USEABLE_HARDWARE_PWM(pin) TRUE // all pins are PWM capable
|
#define PWM_PIN(P) true // all pins are PWM capable
|
||||||
|
#define USEABLE_HARDWARE_PWM(P) PWM_PIN(P)
|
||||||
|
|
||||||
#define LPC_PIN(pin) gpio_pin(pin)
|
#define LPC_PIN(pin) gpio_pin(pin)
|
||||||
#define LPC_GPIO(port) gpio_port(port)
|
#define LPC_GPIO(port) gpio_port(port)
|
||||||
|
@ -90,7 +91,7 @@
|
||||||
|
|
||||||
/// check if pin is a timer
|
/// check if pin is a timer
|
||||||
/// all gpio pins are pwm capable, either interrupt or hardware pwm controlled
|
/// all gpio pins are pwm capable, either interrupt or hardware pwm controlled
|
||||||
#define _GET_TIMER(IO) TRUE
|
#define _GET_TIMER(IO) true
|
||||||
|
|
||||||
/// Read a pin wrapper
|
/// Read a pin wrapper
|
||||||
#define READ(IO) _READ(IO)
|
#define READ(IO) _READ(IO)
|
||||||
|
|
|
@ -207,7 +207,6 @@ static void NVIC_SetPriorityGrouping(uint32_t PriorityGroup) {
|
||||||
} }
|
} }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
void HAL_init(void) {
|
void HAL_init(void) {
|
||||||
NVIC_SetPriorityGrouping(0x3);
|
NVIC_SetPriorityGrouping(0x3);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2014,7 +2014,7 @@ static_assert( _ARR_TEST(3,0) && _ARR_TEST(3,1) && _ARR_TEST(3,2)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ENABLED(FAST_PWM_FAN) && !(defined(ARDUINO) && !defined(ARDUINO_ARCH_SAM))
|
#if ENABLED(FAST_PWM_FAN) && !(defined(ARDUINO) && !defined(ARDUINO_ARCH_SAM))
|
||||||
#error "FAST_PWM_FAN only supported by 8 bit CPUs."
|
#error "FAST_PWM_FAN is only supported for ARDUINO and ARDUINO_ARCH_SAM."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ENABLED(Z_STEPPER_AUTO_ALIGN)
|
#if ENABLED(Z_STEPPER_AUTO_ALIGN)
|
||||||
|
|
Loading…
Reference in a new issue