Let laser/spindle use free AVR servo timers (#19011)

This commit is contained in:
Giuliano Zaro 2020-08-14 15:41:44 +02:00 committed by Scott Lahteine
parent 8258a76c9b
commit 16f2f2bce7
2 changed files with 7 additions and 4 deletions

View file

@ -60,10 +60,12 @@
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
//#define _useTimer1 //#define _useTimer1
#define _useTimer3 #define _useTimer3
#if NUM_SERVOS > SERVOS_PER_TIMER
#define _useTimer4 #define _useTimer4
#if !HAS_MOTOR_CURRENT_PWM #if !HAS_MOTOR_CURRENT_PWM && SERVOS > 2 * SERVOS_PER_TIMER
#define _useTimer5 // Timer 5 is used for motor current PWM and can't be used for servos. #define _useTimer5 // Timer 5 is used for motor current PWM and can't be used for servos.
#endif #endif
#endif
#elif defined(__AVR_ATmega32U4__) #elif defined(__AVR_ATmega32U4__)
#define _useTimer3 #define _useTimer3
#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) #elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)

View file

@ -36,9 +36,10 @@
* Sanity checks for Spindle / Laser PWM * Sanity checks for Spindle / Laser PWM
*/ */
#if ENABLED(SPINDLE_LASER_PWM) #if ENABLED(SPINDLE_LASER_PWM)
#include "../ServoTimers.h" // Needed to check timer availability (_useTimer3)
#if SPINDLE_LASER_PWM_PIN == 4 || WITHIN(SPINDLE_LASER_PWM_PIN, 11, 13) #if SPINDLE_LASER_PWM_PIN == 4 || WITHIN(SPINDLE_LASER_PWM_PIN, 11, 13)
#error "Counter/Timer for SPINDLE_LASER_PWM_PIN is used by a system interrupt." #error "Counter/Timer for SPINDLE_LASER_PWM_PIN is used by a system interrupt."
#elif NUM_SERVOS > 0 && (WITHIN(SPINDLE_LASER_PWM_PIN, 2, 3) || SPINDLE_LASER_PWM_PIN == 5) #elif NUM_SERVOS > 0 && defined(_useTimer3) && (WITHIN(SPINDLE_LASER_PWM_PIN, 2, 3) || SPINDLE_LASER_PWM_PIN == 5)
#error "Counter/Timer for SPINDLE_LASER_PWM_PIN is used by the servo system." #error "Counter/Timer for SPINDLE_LASER_PWM_PIN is used by the servo system."
#endif #endif
#elif defined(SPINDLE_LASER_FREQUENCY) #elif defined(SPINDLE_LASER_FREQUENCY)