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_FOCC(T,V) SET_FOC(T,C,V)
|
||||
|
||||
|
||||
/**
|
||||
* PWM availability macros
|
||||
*/
|
||||
|
||||
// Determine which harware PWMs are already in use
|
||||
#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
|
||||
#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
|
||||
|
||||
#if PIN_EXISTS(FAN) || PIN_EXISTS(FAN1) || PIN_EXISTS(FAN2)
|
||||
|
@ -335,24 +334,22 @@ enum ClockSource2 : char {
|
|||
#define PWM_CHK_HEATER(p) false
|
||||
#endif
|
||||
|
||||
#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))
|
||||
#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))
|
||||
|
||||
// define which hardware PWMs are available for the current CPU
|
||||
// all timer 1 PWMS deleted from this list because they are never available
|
||||
#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
|
||||
#define PWM_PINS(p) ((p >= 2 && p <= 6) || p == 9)
|
||||
#define PWM_PIN(p) ((p >= 2 && p <= 6) || p == 9)
|
||||
#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
|
||||
#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
|
||||
#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
|
||||
#error "unknown CPU"
|
||||
#endif
|
||||
|
||||
// finally - the macro that tells us if a pin is an available hardware PWM
|
||||
#define USEABLE_HARDWARE_PWM(p) (PWM_PINS(p) && !PWM_CHK(p))
|
||||
#define USEABLE_HARDWARE_PWM(P) (PWM_PIN(P) && !PWM_CHK(p))
|
||||
|
|
|
@ -174,9 +174,9 @@
|
|||
#define SET_OUTPUT(IO) _SET_OUTPUT(IO)
|
||||
|
||||
// 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
|
||||
#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
|
||||
#define GET_TIMER(IO) ((IO) >= 2 && (IO) <= 13)
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@
|
|||
// hg42: instead use PWM bit from the #define
|
||||
|
||||
/// 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:
|
||||
// #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)
|
||||
|
|
|
@ -35,7 +35,8 @@
|
|||
|
||||
#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_GPIO(port) gpio_port(port)
|
||||
|
@ -90,7 +91,7 @@
|
|||
|
||||
/// check if pin is a timer
|
||||
/// 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
|
||||
#define READ(IO) _READ(IO)
|
||||
|
|
|
@ -207,7 +207,6 @@ static void NVIC_SetPriorityGrouping(uint32_t PriorityGroup) {
|
|||
} }
|
||||
#endif
|
||||
|
||||
|
||||
void HAL_init(void) {
|
||||
NVIC_SetPriorityGrouping(0x3);
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
|
||||
#define SET_INPUT(IO) _SET_MODE(IO, GPIO_INPUT_FLOATING)
|
||||
#define SET_INPUT_PULLUP(IO) _SET_MODE(IO, GPIO_INPUT_PU)
|
||||
#define SET_OUTPUT(IO) OUT_WRITE(IO,LOW)
|
||||
#define SET_OUTPUT(IO) OUT_WRITE(IO, LOW)
|
||||
|
||||
#define GET_INPUT(IO) (_GET_MODE(IO) == GPIO_INPUT_FLOATING || _GET_MODE(IO) == GPIO_INPUT_ANALOG || _GET_MODE(IO) == GPIO_INPUT_PU || _GET_MODE(IO) == GPIO_INPUT_PD)
|
||||
#define GET_OUTPUT(IO) (_GET_MODE(IO) == GPIO_OUTPUT_PP)
|
||||
|
|
|
@ -2014,7 +2014,7 @@ static_assert( _ARR_TEST(3,0) && _ARR_TEST(3,1) && _ARR_TEST(3,2)
|
|||
#endif
|
||||
|
||||
#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
|
||||
|
||||
#if ENABLED(Z_STEPPER_AUTO_ALIGN)
|
||||
|
|
Loading…
Reference in a new issue