From 6fbc11cb789558525e996c6015adf561e4b4a352 Mon Sep 17 00:00:00 2001 From: Bob-the-Kuhn Date: Mon, 20 Jan 2020 06:07:55 -0600 Subject: [PATCH 1/3] split out STM401 timers --- Marlin/src/HAL/HAL_STM32/timers.h | 29 ++++++++++++++++++- Marlin/src/pins/stm32/pins_STEVAL_3DP001V1.h | 2 -- .../variants/STEVAL_F401VE/variant.h | 1 + 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/Marlin/src/HAL/HAL_STM32/timers.h b/Marlin/src/HAL/HAL_STM32/timers.h index 7d028e60790f..2a7078ac0004 100644 --- a/Marlin/src/HAL/HAL_STM32/timers.h +++ b/Marlin/src/HAL/HAL_STM32/timers.h @@ -57,7 +57,7 @@ #define TEMP_TIMER 2 #endif -#elif defined(STM32F4xx) || defined(STM32F7xx) +#elif defined(STM32F401xC) || defined(STM32F401xE) #define HAL_TIMER_RATE (F_CPU/2) // frequency of timer peripherals @@ -71,8 +71,35 @@ #define TEMP_TIMER 10 #endif +#elif defined(STM32F4xx) + + #define HAL_TIMER_RATE (F_CPU/2) // frequency of timer peripherals + + + #ifndef STEP_TIMER + #define STEP_TIMER 6 + #endif + + #ifndef TEMP_TIMER + #define TEMP_TIMER 14 + #endif + +#elif defined(STM32F7xx + + #define HAL_TIMER_RATE (F_CPU/2) // frequency of timer peripherals + + #ifndef STEP_TIMER + #define STEP_TIMER 6 + #endif + + #ifndef TEMP_TIMER + #define TEMP_TIMER 14 + #endif + #endif + + #ifndef SWSERIAL_TIMER_IRQ_PRIO #define SWSERIAL_TIMER_IRQ_PRIO 1 #endif diff --git a/Marlin/src/pins/stm32/pins_STEVAL_3DP001V1.h b/Marlin/src/pins/stm32/pins_STEVAL_3DP001V1.h index 3ec5c4c0ecee..02c1c66c5a7f 100644 --- a/Marlin/src/pins/stm32/pins_STEVAL_3DP001V1.h +++ b/Marlin/src/pins/stm32/pins_STEVAL_3DP001V1.h @@ -48,8 +48,6 @@ #define MACHINE_NAME "STEVAL-3DP001V1" #endif -#define TIMER_TONE 5 - // // Limit Switches // diff --git a/buildroot/share/PlatformIO/variants/STEVAL_F401VE/variant.h b/buildroot/share/PlatformIO/variants/STEVAL_F401VE/variant.h index bac86151bb09..5cee7888b940 100644 --- a/buildroot/share/PlatformIO/variants/STEVAL_F401VE/variant.h +++ b/buildroot/share/PlatformIO/variants/STEVAL_F401VE/variant.h @@ -200,6 +200,7 @@ extern "C" { // Timer Definitions #define TIMER_SERVO TIM4 // TIMER_SERVO must be defined in this file +#define TIMER_TONE TIM5 // TIMER_TONE must be defined in this file /* SD detect signal */ /* From d54fdd679c93907e1927c82f997d1e6054cb5663 Mon Sep 17 00:00:00 2001 From: Bob-the-Kuhn Date: Mon, 20 Jan 2020 07:37:42 -0600 Subject: [PATCH 2/3] fix missing bracket --- Marlin/src/HAL/HAL_STM32/timers.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/HAL/HAL_STM32/timers.h b/Marlin/src/HAL/HAL_STM32/timers.h index 2a7078ac0004..931152cf78fe 100644 --- a/Marlin/src/HAL/HAL_STM32/timers.h +++ b/Marlin/src/HAL/HAL_STM32/timers.h @@ -84,7 +84,7 @@ #define TEMP_TIMER 14 #endif -#elif defined(STM32F7xx +#elif defined(STM32F7xx) #define HAL_TIMER_RATE (F_CPU/2) // frequency of timer peripherals From bc0f78ff494a30467e9825ecb4567b3a8ce02654 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 20 Jan 2020 18:32:14 -0600 Subject: [PATCH 3/3] Whitespace --- Marlin/src/HAL/HAL_STM32/timers.h | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/Marlin/src/HAL/HAL_STM32/timers.h b/Marlin/src/HAL/HAL_STM32/timers.h index 931152cf78fe..aa85836bd543 100644 --- a/Marlin/src/HAL/HAL_STM32/timers.h +++ b/Marlin/src/HAL/HAL_STM32/timers.h @@ -59,7 +59,7 @@ #elif defined(STM32F401xC) || defined(STM32F401xE) - #define HAL_TIMER_RATE (F_CPU/2) // frequency of timer peripherals + #define HAL_TIMER_RATE (F_CPU / 2) // frequency of timer peripherals // STM32F401 only has timers 1-5 & 9-11 with timers 4 & 5 usually assigned to TIMER_SERVO and TIMER_TONE @@ -73,8 +73,7 @@ #elif defined(STM32F4xx) - #define HAL_TIMER_RATE (F_CPU/2) // frequency of timer peripherals - + #define HAL_TIMER_RATE (F_CPU / 2) // frequency of timer peripherals #ifndef STEP_TIMER #define STEP_TIMER 6 @@ -98,8 +97,6 @@ #endif - - #ifndef SWSERIAL_TIMER_IRQ_PRIO #define SWSERIAL_TIMER_IRQ_PRIO 1 #endif @@ -109,16 +106,16 @@ #endif #ifndef TEMP_TIMER_IRQ_PRIO - #define TEMP_TIMER_IRQ_PRIO 14 //14 = after hardware ISRs + #define TEMP_TIMER_IRQ_PRIO 14 // 14 = after hardware ISRs #endif #define STEP_TIMER_NUM 0 // index of timer to use for stepper #define TEMP_TIMER_NUM 1 // index of timer to use for temperature #define PULSE_TIMER_NUM STEP_TIMER_NUM -#define TEMP_TIMER_FREQUENCY 1000 //Temperature::isr() is expected to be called at around 1kHz +#define TEMP_TIMER_FREQUENCY 1000 // Temperature::isr() is expected to be called at around 1kHz -//TODO: get rid of manual rate/prescale/ticks/cycles taken for procedures in stepper.cpp +// TODO: get rid of manual rate/prescale/ticks/cycles taken for procedures in stepper.cpp #define STEPPER_TIMER_RATE 2000000 // 2 Mhz #define STEPPER_TIMER_PRESCALE ((HAL_TIMER_RATE)/(STEPPER_TIMER_RATE)) #define STEPPER_TIMER_TICKS_PER_US ((STEPPER_TIMER_RATE) / 1000000) // stepper timer ticks per µs