Parcourir la source

Fix STM32 + SoftwareSerial compile (#17831)

Jason Smith il y a 4 ans
Parent
révision
208af8cb15
Aucun compte lié à l'adresse e-mail de l'auteur

+ 1
- 9
Marlin/src/HAL/STM32/HAL.cpp Voir le fichier

@@ -27,10 +27,6 @@
27 27
 #include "../../inc/MarlinConfig.h"
28 28
 #include "../shared/Delay.h"
29 29
 
30
-#if HAS_TMC_SW_SERIAL
31
-  #include "SoftwareSerial.h"
32
-#endif
33
-
34 30
 #if ENABLED(SRAM_EEPROM_EMULATION)
35 31
   #if STM32F7xx
36 32
     #include <stm32f7xx_ll_pwr.h>
@@ -82,11 +78,7 @@ void HAL_init() {
82 78
     while (!LL_PWR_IsActiveFlag_BRR());   // Wait until backup regulator is initialized
83 79
   #endif
84 80
 
85
-  #if HAS_TMC_SW_SERIAL
86
-    SoftwareSerial::setInterruptPriority(SWSERIAL_TIMER_IRQ_PRIO, 0);
87
-  #endif
88
-
89
-  TERN_(HAS_TMC_SW_SERIAL, SoftwareSerial::setInterruptPriority(SWSERIAL_TIMER_IRQ_PRIO, 0));
81
+  SetSoftwareSerialTimerInterruptPriority();
90 82
 }
91 83
 
92 84
 void HAL_clear_reset_source() { __HAL_RCC_CLEAR_RESET_FLAGS(); }

+ 11
- 3
Marlin/src/HAL/STM32/timers.cpp Voir le fichier

@@ -31,9 +31,6 @@
31 31
 
32 32
 #define NUM_HARDWARE_TIMERS 2
33 33
 
34
-#ifndef SWSERIAL_TIMER_IRQ_PRIO
35
-  #define SWSERIAL_TIMER_IRQ_PRIO 1
36
-#endif
37 34
 #ifndef STEP_TIMER_IRQ_PRIO
38 35
   #define STEP_TIMER_IRQ_PRIO 2
39 36
 #endif
@@ -41,6 +38,13 @@
41 38
   #define TEMP_TIMER_IRQ_PRIO 14   // 14 = after hardware ISRs
42 39
 #endif
43 40
 
41
+#if HAS_TMC_SW_SERIAL
42
+  #include <SoftwareSerial.h>
43
+  #ifndef SWSERIAL_TIMER_IRQ_PRIO
44
+    #define SWSERIAL_TIMER_IRQ_PRIO 1
45
+  #endif
46
+#endif
47
+
44 48
 #ifdef STM32F0xx
45 49
   #define HAL_TIMER_RATE (F_CPU)      // Frequency of timer peripherals
46 50
   #define MCU_STEP_TIMER 16
@@ -175,4 +179,8 @@ TIM_TypeDef * HAL_timer_device(const uint8_t timer_num) {
175 179
   return nullptr;
176 180
 }
177 181
 
182
+void SetSoftwareSerialTimerInterruptPriority() {
183
+  TERN_(HAS_TMC_SW_SERIAL, SoftwareSerial::setInterruptPriority(SWSERIAL_TIMER_IRQ_PRIO, 0));
184
+}
185
+
178 186
 #endif // ARDUINO_ARCH_STM32 && !STM32GENERIC

+ 3
- 0
Marlin/src/HAL/STM32/timers.h Voir le fichier

@@ -75,6 +75,9 @@ void HAL_timer_enable_interrupt(const uint8_t timer_num);
75 75
 void HAL_timer_disable_interrupt(const uint8_t timer_num);
76 76
 bool HAL_timer_interrupt_enabled(const uint8_t timer_num);
77 77
 
78
+// Exposed here to allow all timer priority information to reside in timers.cpp
79
+void SetSoftwareSerialTimerInterruptPriority();
80
+
78 81
 //TIM_TypeDef* HAL_timer_device(const uint8_t timer_num); no need to be public for now. not public = not used externally
79 82
 
80 83
 // FORCE_INLINE because these are used in performance-critical situations

+ 3
- 1
buildroot/share/tests/BIGTREE_BTT002-tests Voir le fichier

@@ -12,7 +12,9 @@ set -e
12 12
 restore_configs
13 13
 opt_set MOTHERBOARD BOARD_BTT_BTT002_V1_0
14 14
 opt_set SERIAL_PORT 1
15
-exec_test $1 $2 "BigTreeTech BTT002 Default Configuration"
15
+opt_set X_DRIVER_TYPE TMC2209
16
+opt_set Y_DRIVER_TYPE TMC2130
17
+exec_test $1 $2 "BigTreeTech BTT002 Default Configuration plus TMC steppers"
16 18
 
17 19
 # clean up
18 20
 restore_configs

+ 3
- 1
buildroot/share/tests/BIGTREE_SKR_PRO-tests Voir le fichier

@@ -23,7 +23,9 @@ opt_set TEMP_SENSOR_2 1
23 23
 opt_set E0_AUTO_FAN_PIN PC10
24 24
 opt_set E1_AUTO_FAN_PIN PC11
25 25
 opt_set E2_AUTO_FAN_PIN PC12
26
-exec_test $1 $2 "BigTreeTech SKR Pro 3 Extruders with Auto-Fan"
26
+opt_set X_DRIVER_TYPE TMC2209
27
+opt_set Y_DRIVER_TYPE TMC2130
28
+exec_test $1 $2 "BigTreeTech SKR Pro 3 Extruders with Auto-Fan and mixed TMC drivers"
27 29
 
28 30
 # clean up
29 31
 restore_configs

+ 2
- 1
platformio.ini Voir le fichier

@@ -769,9 +769,10 @@ build_flags       = ${common.build_flags}
769 769
   -DHAVE_HWSERIAL3
770 770
   -DPIN_SERIAL2_RX=PD_6
771 771
   -DPIN_SERIAL2_TX=PD_5
772
+  -IMarlin/src/HAL/STM32
772 773
 build_unflags     = -std=gnu++11
773 774
 extra_scripts     = pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py
774
-lib_ignore        = Adafruit NeoPixel, SailfishLCD, SlowSoftI2CMaster
775
+lib_ignore        = Adafruit NeoPixel, SailfishLCD, SlowSoftI2CMaster, SoftwareSerial
775 776
 src_filter        = ${common.default_src_filter} +<src/HAL/STM32>
776 777
 
777 778
 #

Chargement…
Annuler
Enregistrer