|
@@ -29,26 +29,41 @@
|
29
|
29
|
|
30
|
30
|
#define NUM_HARDWARE_TIMERS 2
|
31
|
31
|
|
|
32
|
+// Default timer priorities. Override by specifying alternate priorities in the board pins file.
|
|
33
|
+// The TONE timer is not present here, as it currently cannot be set programmatically. It is set
|
|
34
|
+// by defining TIM_IRQ_PRIO in the variant.h or platformio.ini file, which adjusts the default
|
|
35
|
+// priority for STM32 HardwareTimer objects.
|
|
36
|
+#define SWSERIAL_TIMER_IRQ_PRIO_DEFAULT 1 // Requires tight bit timing to communicate reliably with TMC drivers
|
|
37
|
+#define SERVO_TIMER_IRQ_PRIO_DEFAULT 1 // Requires tight PWM timing to control a BLTouch reliably
|
|
38
|
+#define STEP_TIMER_IRQ_PRIO_DEFAULT 2
|
|
39
|
+#define TEMP_TIMER_IRQ_PRIO_DEFAULT 14 // Low priority avoids interference with other hardware and timers
|
|
40
|
+
|
32
|
41
|
#ifndef STEP_TIMER_IRQ_PRIO
|
33
|
|
- #define STEP_TIMER_IRQ_PRIO 2
|
|
42
|
+ #define STEP_TIMER_IRQ_PRIO STEP_TIMER_IRQ_PRIO_DEFAULT
|
34
|
43
|
#endif
|
35
|
44
|
#ifndef TEMP_TIMER_IRQ_PRIO
|
36
|
|
- #define TEMP_TIMER_IRQ_PRIO 14 // 14 = after hardware ISRs
|
37
|
|
-#endif
|
38
|
|
-
|
39
|
|
-// Ensure the default timer priority is somewhere between the STEP and TEMP priorities.
|
40
|
|
-// The STM32 framework defaults to interrupt 14 for all timers. This should be increased so that
|
41
|
|
-// timing-sensitive operations such as speaker output are note impacted by the long-running
|
42
|
|
-// temperature ISR. This must be defined in the platformio.ini file or the board's variant.h,
|
43
|
|
-// so that it will be consumed by framework code.
|
44
|
|
-#if !(TIM_IRQ_PRIO > STEP_TIMER_IRQ_PRIO && TIM_IRQ_PRIO < TEMP_TIMER_IRQ_PRIO)
|
45
|
|
- #error "Default timer interrupt priority is unspecified or set to a value which may degrade performance."
|
|
45
|
+ #define TEMP_TIMER_IRQ_PRIO TEMP_TIMER_IRQ_PRIO_DEFAULT
|
46
|
46
|
#endif
|
47
|
|
-
|
48
|
47
|
#if HAS_TMC_SW_SERIAL
|
49
|
48
|
#include <SoftwareSerial.h>
|
50
|
49
|
#ifndef SWSERIAL_TIMER_IRQ_PRIO
|
51
|
|
- #define SWSERIAL_TIMER_IRQ_PRIO 1
|
|
50
|
+ #define SWSERIAL_TIMER_IRQ_PRIO SWSERIAL_TIMER_IRQ_PRIO_DEFAULT
|
|
51
|
+ #endif
|
|
52
|
+#endif
|
|
53
|
+#if HAS_SERVOS
|
|
54
|
+ #include "Servo.h"
|
|
55
|
+ #ifndef SERVO_TIMER_IRQ_PRIO
|
|
56
|
+ #define SERVO_TIMER_IRQ_PRIO SERVO_TIMER_IRQ_PRIO_DEFAULT
|
|
57
|
+ #endif
|
|
58
|
+#endif
|
|
59
|
+#if ENABLED(SPEAKER)
|
|
60
|
+ // Ensure the default timer priority is somewhere between the STEP and TEMP priorities.
|
|
61
|
+ // The STM32 framework defaults to interrupt 14 for all timers. This should be increased so that
|
|
62
|
+ // timing-sensitive operations such as speaker output are not impacted by the long-running
|
|
63
|
+ // temperature ISR. This must be defined in the platformio.ini file or the board's variant.h,
|
|
64
|
+ // so that it will be consumed by framework code.
|
|
65
|
+ #if !(TIM_IRQ_PRIO > STEP_TIMER_IRQ_PRIO && TIM_IRQ_PRIO < TEMP_TIMER_IRQ_PRIO)
|
|
66
|
+ #error "Default timer interrupt priority is unspecified or set to a value which may degrade performance."
|
52
|
67
|
#endif
|
53
|
68
|
#endif
|
54
|
69
|
|
|
@@ -189,8 +204,9 @@ TIM_TypeDef * HAL_timer_device(const uint8_t timer_num) {
|
189
|
204
|
return nullptr;
|
190
|
205
|
}
|
191
|
206
|
|
192
|
|
-void SetSoftwareSerialTimerInterruptPriority() {
|
|
207
|
+void SetTimerInterruptPriorities() {
|
193
|
208
|
TERN_(HAS_TMC_SW_SERIAL, SoftwareSerial::setInterruptPriority(SWSERIAL_TIMER_IRQ_PRIO, 0));
|
|
209
|
+ TERN_(HAS_SERVOS, libServo::setInterruptPriority(SERVO_TIMER_IRQ_PRIO, 0));
|
194
|
210
|
}
|
195
|
211
|
|
196
|
212
|
#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC
|