Browse Source

Fix STM32 + SoftwareSerial compile (#17831)

Jason Smith 4 years ago
parent
commit
208af8cb15
No account linked to committer's email address

+ 1
- 9
Marlin/src/HAL/STM32/HAL.cpp View File

27
 #include "../../inc/MarlinConfig.h"
27
 #include "../../inc/MarlinConfig.h"
28
 #include "../shared/Delay.h"
28
 #include "../shared/Delay.h"
29
 
29
 
30
-#if HAS_TMC_SW_SERIAL
31
-  #include "SoftwareSerial.h"
32
-#endif
33
-
34
 #if ENABLED(SRAM_EEPROM_EMULATION)
30
 #if ENABLED(SRAM_EEPROM_EMULATION)
35
   #if STM32F7xx
31
   #if STM32F7xx
36
     #include <stm32f7xx_ll_pwr.h>
32
     #include <stm32f7xx_ll_pwr.h>
82
     while (!LL_PWR_IsActiveFlag_BRR());   // Wait until backup regulator is initialized
78
     while (!LL_PWR_IsActiveFlag_BRR());   // Wait until backup regulator is initialized
83
   #endif
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
 void HAL_clear_reset_source() { __HAL_RCC_CLEAR_RESET_FLAGS(); }
84
 void HAL_clear_reset_source() { __HAL_RCC_CLEAR_RESET_FLAGS(); }

+ 11
- 3
Marlin/src/HAL/STM32/timers.cpp View File

31
 
31
 
32
 #define NUM_HARDWARE_TIMERS 2
32
 #define NUM_HARDWARE_TIMERS 2
33
 
33
 
34
-#ifndef SWSERIAL_TIMER_IRQ_PRIO
35
-  #define SWSERIAL_TIMER_IRQ_PRIO 1
36
-#endif
37
 #ifndef STEP_TIMER_IRQ_PRIO
34
 #ifndef STEP_TIMER_IRQ_PRIO
38
   #define STEP_TIMER_IRQ_PRIO 2
35
   #define STEP_TIMER_IRQ_PRIO 2
39
 #endif
36
 #endif
41
   #define TEMP_TIMER_IRQ_PRIO 14   // 14 = after hardware ISRs
38
   #define TEMP_TIMER_IRQ_PRIO 14   // 14 = after hardware ISRs
42
 #endif
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
 #ifdef STM32F0xx
48
 #ifdef STM32F0xx
45
   #define HAL_TIMER_RATE (F_CPU)      // Frequency of timer peripherals
49
   #define HAL_TIMER_RATE (F_CPU)      // Frequency of timer peripherals
46
   #define MCU_STEP_TIMER 16
50
   #define MCU_STEP_TIMER 16
175
   return nullptr;
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
 #endif // ARDUINO_ARCH_STM32 && !STM32GENERIC
186
 #endif // ARDUINO_ARCH_STM32 && !STM32GENERIC

+ 3
- 0
Marlin/src/HAL/STM32/timers.h View File

75
 void HAL_timer_disable_interrupt(const uint8_t timer_num);
75
 void HAL_timer_disable_interrupt(const uint8_t timer_num);
76
 bool HAL_timer_interrupt_enabled(const uint8_t timer_num);
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
 //TIM_TypeDef* HAL_timer_device(const uint8_t timer_num); no need to be public for now. not public = not used externally
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
 // FORCE_INLINE because these are used in performance-critical situations
83
 // FORCE_INLINE because these are used in performance-critical situations

+ 3
- 1
buildroot/share/tests/BIGTREE_BTT002-tests View File

12
 restore_configs
12
 restore_configs
13
 opt_set MOTHERBOARD BOARD_BTT_BTT002_V1_0
13
 opt_set MOTHERBOARD BOARD_BTT_BTT002_V1_0
14
 opt_set SERIAL_PORT 1
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
 # clean up
19
 # clean up
18
 restore_configs
20
 restore_configs

+ 3
- 1
buildroot/share/tests/BIGTREE_SKR_PRO-tests View File

23
 opt_set E0_AUTO_FAN_PIN PC10
23
 opt_set E0_AUTO_FAN_PIN PC10
24
 opt_set E1_AUTO_FAN_PIN PC11
24
 opt_set E1_AUTO_FAN_PIN PC11
25
 opt_set E2_AUTO_FAN_PIN PC12
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
 # clean up
30
 # clean up
29
 restore_configs
31
 restore_configs

+ 2
- 1
platformio.ini View File

769
   -DHAVE_HWSERIAL3
769
   -DHAVE_HWSERIAL3
770
   -DPIN_SERIAL2_RX=PD_6
770
   -DPIN_SERIAL2_RX=PD_6
771
   -DPIN_SERIAL2_TX=PD_5
771
   -DPIN_SERIAL2_TX=PD_5
772
+  -IMarlin/src/HAL/STM32
772
 build_unflags     = -std=gnu++11
773
 build_unflags     = -std=gnu++11
773
 extra_scripts     = pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py
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
 src_filter        = ${common.default_src_filter} +<src/HAL/STM32>
776
 src_filter        = ${common.default_src_filter} +<src/HAL/STM32>
776
 
777
 
777
 #
778
 #

Loading…
Cancel
Save