From 92011978787ecade56fb34a075735dba36f39a64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20=C5=A0ustek?= Date: Thu, 7 Nov 2019 00:34:29 +0100 Subject: [PATCH] Fix SKR E3 board BLTOUCH + SPEAKER timer conflict (#15781) --- Marlin/src/HAL/HAL_STM32F1/SPI.cpp | 2 +- Marlin/src/HAL/HAL_STM32F1/timers.cpp | 2 +- Marlin/src/HAL/HAL_STM32F1/timers.h | 20 +++++++++++++++++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/Marlin/src/HAL/HAL_STM32F1/SPI.cpp b/Marlin/src/HAL/HAL_STM32F1/SPI.cpp index 101b42a53..8eb8f9aa8 100644 --- a/Marlin/src/HAL/HAL_STM32F1/SPI.cpp +++ b/Marlin/src/HAL/HAL_STM32F1/SPI.cpp @@ -53,7 +53,7 @@ static const spi_pins* dev_to_spi_pins(spi_dev *dev); static void configure_gpios(spi_dev *dev, bool as_master); static spi_baud_rate determine_baud_rate(spi_dev *dev, uint32_t freq); -#if (BOARD_NR_SPI >= 3) && !defined(STM32_HIGH_DENSITY) +#if BOARD_NR_SPI >= 3 && !defined(STM32_HIGH_DENSITY) #error "The SPI library is misconfigured: 3 SPI ports only available on high density STM32 devices" #endif diff --git a/Marlin/src/HAL/HAL_STM32F1/timers.cpp b/Marlin/src/HAL/HAL_STM32F1/timers.cpp index a1f5f1e45..68a0cad48 100644 --- a/Marlin/src/HAL/HAL_STM32F1/timers.cpp +++ b/Marlin/src/HAL/HAL_STM32F1/timers.cpp @@ -57,7 +57,7 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) { case 3: irq_num = NVIC_TIMER3; break; case 4: irq_num = NVIC_TIMER4; break; case 5: irq_num = NVIC_TIMER5; break; - #if ENABLED(STM32_HIGH_DENSITY) + #ifdef STM32_HIGH_DENSITY // 6 & 7 are basic timers, avoid them case 8: irq_num = NVIC_TIMER8_CC; break; #endif diff --git a/Marlin/src/HAL/HAL_STM32F1/timers.h b/Marlin/src/HAL/HAL_STM32F1/timers.h index aba619fd1..4fe0bcbe8 100644 --- a/Marlin/src/HAL/HAL_STM32F1/timers.h +++ b/Marlin/src/HAL/HAL_STM32F1/timers.h @@ -47,6 +47,20 @@ typedef uint16_t hal_timer_t; #define STEP_TIMER_CHAN 1 // Channel of the timer to use for compare and interrupts #define TEMP_TIMER_CHAN 1 // Channel of the timer to use for compare and interrupts +/** + * Note: Timers may be used by platforms and libraries + * + * FAN PWMs: + * With FAN_SOFT_PWM disabled the Temperature class uses + * FANx_PIN timers to generate FAN PWM signals. + * + * Speaker: + * When SPEAKER is enabled, one timer is allocated by maple/tone.cpp. + * - If BEEPER_PIN has a timer channel (and USE_PIN_TIMER is + * defined in tone.cpp) it uses the pin's own timer. + * - Otherwise it uses Timer 8 on boards with STM32_HIGH_DENSITY + * or Timer 4 on other boards. + */ #if defined(MCU_STM32F103CB) || defined(MCU_STM32F103C8) #define STEP_TIMER_NUM 4 // For C8/CB boards, use timer 4 #else @@ -58,7 +72,11 @@ typedef uint16_t hal_timer_t; #if MB(BIGTREE_SKR_MINI_E3, BIGTREE_SKR_E3_DIP, BTT_SKR_MINI_E3_V1_2, MKS_ROBIN_LITE) // SKR Mini E3 boards use PA8 as FAN_PIN, so TIMER 1 is used for Fan PWM. - #define SERVO0_TIMER_NUM 8 + #ifdef STM32_HIGH_DENSITY + #define SERVO0_TIMER_NUM 8 // tone.cpp uses Timer 4 + #else + #define SERVO0_TIMER_NUM 3 // tone.cpp uses Timer 8 + #endif #else #define SERVO0_TIMER_NUM 1 // SERVO0 or BLTOUCH #endif