Browse Source

Fix SKR E3 board BLTOUCH + SPEAKER timer conflict (#15781)

Miroslav Šustek 4 years ago
parent
commit
9201197878

+ 1
- 1
Marlin/src/HAL/HAL_STM32F1/SPI.cpp View File

@@ -53,7 +53,7 @@ static const spi_pins* dev_to_spi_pins(spi_dev *dev);
53 53
 static void configure_gpios(spi_dev *dev, bool as_master);
54 54
 static spi_baud_rate determine_baud_rate(spi_dev *dev, uint32_t freq);
55 55
 
56
-#if (BOARD_NR_SPI >= 3) && !defined(STM32_HIGH_DENSITY)
56
+#if BOARD_NR_SPI >= 3 && !defined(STM32_HIGH_DENSITY)
57 57
   #error "The SPI library is misconfigured: 3 SPI ports only available on high density STM32 devices"
58 58
 #endif
59 59
 

+ 1
- 1
Marlin/src/HAL/HAL_STM32F1/timers.cpp View File

@@ -57,7 +57,7 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
57 57
     case 3: irq_num = NVIC_TIMER3; break;
58 58
     case 4: irq_num = NVIC_TIMER4; break;
59 59
     case 5: irq_num = NVIC_TIMER5; break;
60
-    #if ENABLED(STM32_HIGH_DENSITY)
60
+    #ifdef STM32_HIGH_DENSITY
61 61
       // 6 & 7 are basic timers, avoid them
62 62
       case 8: irq_num = NVIC_TIMER8_CC; break;
63 63
     #endif

+ 19
- 1
Marlin/src/HAL/HAL_STM32F1/timers.h View File

@@ -47,6 +47,20 @@ typedef uint16_t hal_timer_t;
47 47
 #define STEP_TIMER_CHAN 1 // Channel of the timer to use for compare and interrupts
48 48
 #define TEMP_TIMER_CHAN 1 // Channel of the timer to use for compare and interrupts
49 49
 
50
+/**
51
+ * Note: Timers may be used by platforms and libraries
52
+ *
53
+ * FAN PWMs:
54
+ *   With FAN_SOFT_PWM disabled the Temperature class uses
55
+ *   FANx_PIN timers to generate FAN PWM signals.
56
+ *
57
+ * Speaker:
58
+ *   When SPEAKER is enabled, one timer is allocated by maple/tone.cpp.
59
+ *   - If BEEPER_PIN has a timer channel (and USE_PIN_TIMER is
60
+ *     defined in tone.cpp) it uses the pin's own timer.
61
+ *   - Otherwise it uses Timer 8 on boards with STM32_HIGH_DENSITY
62
+ *     or Timer 4 on other boards.
63
+ */
50 64
 #if defined(MCU_STM32F103CB) || defined(MCU_STM32F103C8)
51 65
   #define STEP_TIMER_NUM 4 // For C8/CB boards, use timer 4
52 66
 #else
@@ -58,7 +72,11 @@ typedef uint16_t hal_timer_t;
58 72
 
59 73
 #if MB(BIGTREE_SKR_MINI_E3, BIGTREE_SKR_E3_DIP, BTT_SKR_MINI_E3_V1_2, MKS_ROBIN_LITE)
60 74
   // SKR Mini E3 boards use PA8 as FAN_PIN, so TIMER 1 is used for Fan PWM.
61
-  #define SERVO0_TIMER_NUM 8
75
+  #ifdef STM32_HIGH_DENSITY
76
+    #define SERVO0_TIMER_NUM 8  // tone.cpp uses Timer 4
77
+  #else
78
+    #define SERVO0_TIMER_NUM 3  // tone.cpp uses Timer 8
79
+  #endif
62 80
 #else
63 81
   #define SERVO0_TIMER_NUM 1  // SERVO0 or BLTOUCH
64 82
 #endif

Loading…
Cancel
Save