From f2ad63de59947a47583667beac66ebdbbf501aa8 Mon Sep 17 00:00:00 2001 From: thisiskeithb <13375512+thisiskeithb@users.noreply.github.com> Date: Thu, 17 Dec 2020 22:00:16 -0800 Subject: [PATCH 1/4] Set default TMC slave addresses for SKR Mini E3 V1/2 boards --- Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V1_0.h | 13 +++++++++++++ Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V2_0.h | 13 +++++++++++++ 2 files changed, 26 insertions(+) diff --git a/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V1_0.h b/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V1_0.h index 78751a6bac87..0507782a87fe 100644 --- a/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V1_0.h +++ b/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V1_0.h @@ -34,4 +34,17 @@ #define Y_HARDWARE_SERIAL MSerial4 #define Z_HARDWARE_SERIAL MSerial4 #define E0_HARDWARE_SERIAL MSerial4 + + // Override default config TMC slave addresses + #undef X_SLAVE_ADDRESS + #define X_SLAVE_ADDRESS 0 + + #undef Y_SLAVE_ADDRESS + #define Y_SLAVE_ADDRESS 2 + + #undef Z_SLAVE_ADDRESS + #define Z_SLAVE_ADDRESS 1 + + #undef E0_SLAVE_ADDRESS + #define E0_SLAVE_ADDRESS 3 #endif diff --git a/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V2_0.h b/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V2_0.h index 8ed30bffb733..8c6785b98b10 100644 --- a/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V2_0.h +++ b/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V2_0.h @@ -58,4 +58,17 @@ #define Y_HARDWARE_SERIAL MSerial4 #define Z_HARDWARE_SERIAL MSerial4 #define E0_HARDWARE_SERIAL MSerial4 + + // Override default config TMC slave addresses + #undef X_SLAVE_ADDRESS + #define X_SLAVE_ADDRESS 0 + + #undef Y_SLAVE_ADDRESS + #define Y_SLAVE_ADDRESS 2 + + #undef Z_SLAVE_ADDRESS + #define Z_SLAVE_ADDRESS 1 + + #undef E0_SLAVE_ADDRESS + #define E0_SLAVE_ADDRESS 3 #endif From 4a5b98d57f6e8db7011f021fad66b0c622bb0334 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 19 Dec 2020 15:55:56 -0600 Subject: [PATCH 2/4] Disable slave overrides by default --- Marlin/Configuration_adv.h | 32 ++++++------- Marlin/src/inc/Conditionals_post.h | 48 +++++++++++++++++++ .../pins/stm32f1/pins_BTT_SKR_MINI_E3_V1_0.h | 25 +++++----- .../pins/stm32f1/pins_BTT_SKR_MINI_E3_V2_0.h | 25 +++++----- Marlin/src/pins/stm32f1/pins_FYSETC_AIO_II.h | 15 ++++++ Marlin/src/pins/stm32f1/pins_FYSETC_CHEETAH.h | 15 ++++++ buildroot/tests/STM32F103RC_btt-tests | 4 -- 7 files changed, 120 insertions(+), 44 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index aed29d0f2c59..51c2b8f99419 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -2473,22 +2473,22 @@ * Set *_SERIAL_TX_PIN and *_SERIAL_RX_PIN to match for all drivers * on the same serial port, either here or in your board's pins file. */ - #define X_SLAVE_ADDRESS 0 - #define Y_SLAVE_ADDRESS 0 - #define Z_SLAVE_ADDRESS 0 - #define X2_SLAVE_ADDRESS 0 - #define Y2_SLAVE_ADDRESS 0 - #define Z2_SLAVE_ADDRESS 0 - #define Z3_SLAVE_ADDRESS 0 - #define Z4_SLAVE_ADDRESS 0 - #define E0_SLAVE_ADDRESS 0 - #define E1_SLAVE_ADDRESS 0 - #define E2_SLAVE_ADDRESS 0 - #define E3_SLAVE_ADDRESS 0 - #define E4_SLAVE_ADDRESS 0 - #define E5_SLAVE_ADDRESS 0 - #define E6_SLAVE_ADDRESS 0 - #define E7_SLAVE_ADDRESS 0 + //#define X_SLAVE_ADDRESS 0 + //#define Y_SLAVE_ADDRESS 0 + //#define Z_SLAVE_ADDRESS 0 + //#define X2_SLAVE_ADDRESS 0 + //#define Y2_SLAVE_ADDRESS 0 + //#define Z2_SLAVE_ADDRESS 0 + //#define Z3_SLAVE_ADDRESS 0 + //#define Z4_SLAVE_ADDRESS 0 + //#define E0_SLAVE_ADDRESS 0 + //#define E1_SLAVE_ADDRESS 0 + //#define E2_SLAVE_ADDRESS 0 + //#define E3_SLAVE_ADDRESS 0 + //#define E4_SLAVE_ADDRESS 0 + //#define E5_SLAVE_ADDRESS 0 + //#define E6_SLAVE_ADDRESS 0 + //#define E7_SLAVE_ADDRESS 0 /** * Software enable diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 3510cb211554..ff37e92c3fb2 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -1647,6 +1647,54 @@ #ifndef E7_INTERPOLATE #define E7_INTERPOLATE INTERPOLATE #endif + #ifndef X_SLAVE_ADDRESS + #define X_SLAVE_ADDRESS 0 + #endif + #ifndef Y_SLAVE_ADDRESS + #define Y_SLAVE_ADDRESS 0 + #endif + #ifndef Z_SLAVE_ADDRESS + #define Z_SLAVE_ADDRESS 0 + #endif + #ifndef X2_SLAVE_ADDRESS + #define X2_SLAVE_ADDRESS 0 + #endif + #ifndef Y2_SLAVE_ADDRESS + #define Y2_SLAVE_ADDRESS 0 + #endif + #ifndef Z2_SLAVE_ADDRESS + #define Z2_SLAVE_ADDRESS 0 + #endif + #ifndef Z3_SLAVE_ADDRESS + #define Z3_SLAVE_ADDRESS 0 + #endif + #ifndef Z4_SLAVE_ADDRESS + #define Z4_SLAVE_ADDRESS 0 + #endif + #ifndef E0_SLAVE_ADDRESS + #define E0_SLAVE_ADDRESS 0 + #endif + #ifndef E1_SLAVE_ADDRESS + #define E1_SLAVE_ADDRESS 0 + #endif + #ifndef E2_SLAVE_ADDRESS + #define E2_SLAVE_ADDRESS 0 + #endif + #ifndef E3_SLAVE_ADDRESS + #define E3_SLAVE_ADDRESS 0 + #endif + #ifndef E4_SLAVE_ADDRESS + #define E4_SLAVE_ADDRESS 0 + #endif + #ifndef E5_SLAVE_ADDRESS + #define E5_SLAVE_ADDRESS 0 + #endif + #ifndef E6_SLAVE_ADDRESS + #define E6_SLAVE_ADDRESS 0 + #endif + #ifndef E7_SLAVE_ADDRESS + #define E7_SLAVE_ADDRESS 0 + #endif #endif #if (HAS_E_DRIVER(TMC2660) \ diff --git a/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V1_0.h b/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V1_0.h index 0507782a87fe..a09da02e1584 100644 --- a/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V1_0.h +++ b/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V1_0.h @@ -35,16 +35,17 @@ #define Z_HARDWARE_SERIAL MSerial4 #define E0_HARDWARE_SERIAL MSerial4 - // Override default config TMC slave addresses - #undef X_SLAVE_ADDRESS - #define X_SLAVE_ADDRESS 0 - - #undef Y_SLAVE_ADDRESS - #define Y_SLAVE_ADDRESS 2 - - #undef Z_SLAVE_ADDRESS - #define Z_SLAVE_ADDRESS 1 - - #undef E0_SLAVE_ADDRESS - #define E0_SLAVE_ADDRESS 3 + // Default TMC slave addresses + #ifndef X_SLAVE_ADDRESS + #define X_SLAVE_ADDRESS 0 + #endif + #ifndef Y_SLAVE_ADDRESS + #define Y_SLAVE_ADDRESS 2 + #endif + #ifndef Z_SLAVE_ADDRESS + #define Z_SLAVE_ADDRESS 1 + #endif + #ifndef E0_SLAVE_ADDRESS + #define E0_SLAVE_ADDRESS 3 + #endif #endif diff --git a/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V2_0.h b/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V2_0.h index 8c6785b98b10..93344941d529 100644 --- a/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V2_0.h +++ b/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V2_0.h @@ -59,16 +59,17 @@ #define Z_HARDWARE_SERIAL MSerial4 #define E0_HARDWARE_SERIAL MSerial4 - // Override default config TMC slave addresses - #undef X_SLAVE_ADDRESS - #define X_SLAVE_ADDRESS 0 - - #undef Y_SLAVE_ADDRESS - #define Y_SLAVE_ADDRESS 2 - - #undef Z_SLAVE_ADDRESS - #define Z_SLAVE_ADDRESS 1 - - #undef E0_SLAVE_ADDRESS - #define E0_SLAVE_ADDRESS 3 + // Default TMC slave addresses + #ifndef X_SLAVE_ADDRESS + #define X_SLAVE_ADDRESS 0 + #endif + #ifndef Y_SLAVE_ADDRESS + #define Y_SLAVE_ADDRESS 2 + #endif + #ifndef Z_SLAVE_ADDRESS + #define Z_SLAVE_ADDRESS 1 + #endif + #ifndef E0_SLAVE_ADDRESS + #define E0_SLAVE_ADDRESS 3 + #endif #endif diff --git a/Marlin/src/pins/stm32f1/pins_FYSETC_AIO_II.h b/Marlin/src/pins/stm32f1/pins_FYSETC_AIO_II.h index aebb776b2961..1c379f98bdff 100644 --- a/Marlin/src/pins/stm32f1/pins_FYSETC_AIO_II.h +++ b/Marlin/src/pins/stm32f1/pins_FYSETC_AIO_II.h @@ -113,6 +113,21 @@ #endif +#if HAS_TRINAMIC_CONFIG + #ifndef X_SLAVE_ADDRESS + #define X_SLAVE_ADDRESS 0 + #endif + #ifndef Y_SLAVE_ADDRESS + #define Y_SLAVE_ADDRESS 1 + #endif + #ifndef Z_SLAVE_ADDRESS + #define Z_SLAVE_ADDRESS 2 + #endif + #ifndef E0_SLAVE_ADDRESS + #define E0_SLAVE_ADDRESS 3 + #endif +#endif + // // Stepper current PWM // diff --git a/Marlin/src/pins/stm32f1/pins_FYSETC_CHEETAH.h b/Marlin/src/pins/stm32f1/pins_FYSETC_CHEETAH.h index b8a4ccf770c4..28634521d1b2 100644 --- a/Marlin/src/pins/stm32f1/pins_FYSETC_CHEETAH.h +++ b/Marlin/src/pins/stm32f1/pins_FYSETC_CHEETAH.h @@ -85,6 +85,21 @@ #define Z_HARDWARE_SERIAL MSerial2 #define E0_HARDWARE_SERIAL MSerial2 +#if HAS_TRINAMIC_CONFIG + #ifndef X_SLAVE_ADDRESS + #define X_SLAVE_ADDRESS 0 + #endif + #ifndef Y_SLAVE_ADDRESS + #define Y_SLAVE_ADDRESS 1 + #endif + #ifndef Z_SLAVE_ADDRESS + #define Z_SLAVE_ADDRESS 2 + #endif + #ifndef E0_SLAVE_ADDRESS + #define E0_SLAVE_ADDRESS 3 + #endif +#endif + // // Heaters / Fans // diff --git a/buildroot/tests/STM32F103RC_btt-tests b/buildroot/tests/STM32F103RC_btt-tests index 5d695c9296b1..0084f59a0ce8 100755 --- a/buildroot/tests/STM32F103RC_btt-tests +++ b/buildroot/tests/STM32F103RC_btt-tests @@ -17,10 +17,6 @@ opt_set X_DRIVER_TYPE TMC2209 opt_set Y_DRIVER_TYPE TMC2209 opt_set Z_DRIVER_TYPE TMC2209 opt_set E0_DRIVER_TYPE TMC2209 -opt_set X_SLAVE_ADDRESS 0 -opt_set Y_SLAVE_ADDRESS 1 -opt_set Z_SLAVE_ADDRESS 2 -opt_set E0_SLAVE_ADDRESS 3 opt_enable PINS_DEBUGGING exec_test $1 $2 "BigTreeTech SKR Mini E3 1.0 - Basic Config with TMC2209 HW Serial" "$3" From 5d30e8ce618bf666c955a8c788f8e762f6ba4cb9 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 19 Dec 2020 21:44:31 -0600 Subject: [PATCH 3/4] Use HAS_TMC_UART --- Marlin/src/pins/stm32f1/pins_FYSETC_AIO_II.h | 4 +--- Marlin/src/pins/stm32f1/pins_FYSETC_CHEETAH.h | 10 +++++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Marlin/src/pins/stm32f1/pins_FYSETC_AIO_II.h b/Marlin/src/pins/stm32f1/pins_FYSETC_AIO_II.h index 1c379f98bdff..1485705592cf 100644 --- a/Marlin/src/pins/stm32f1/pins_FYSETC_AIO_II.h +++ b/Marlin/src/pins/stm32f1/pins_FYSETC_AIO_II.h @@ -111,9 +111,7 @@ // Reduce baud rate to improve software serial reliability #define TMC_BAUD_RATE 19200 -#endif - -#if HAS_TRINAMIC_CONFIG + // Default TMC slave addresses #ifndef X_SLAVE_ADDRESS #define X_SLAVE_ADDRESS 0 #endif diff --git a/Marlin/src/pins/stm32f1/pins_FYSETC_CHEETAH.h b/Marlin/src/pins/stm32f1/pins_FYSETC_CHEETAH.h index 28634521d1b2..4e52af256627 100644 --- a/Marlin/src/pins/stm32f1/pins_FYSETC_CHEETAH.h +++ b/Marlin/src/pins/stm32f1/pins_FYSETC_CHEETAH.h @@ -80,12 +80,12 @@ #define E0_DIR_PIN PC14 #define E0_ENABLE_PIN PC13 -#define X_HARDWARE_SERIAL MSerial2 -#define Y_HARDWARE_SERIAL MSerial2 -#define Z_HARDWARE_SERIAL MSerial2 -#define E0_HARDWARE_SERIAL MSerial2 +#if HAS_TMC_UART + #define X_HARDWARE_SERIAL MSerial2 + #define Y_HARDWARE_SERIAL MSerial2 + #define Z_HARDWARE_SERIAL MSerial2 + #define E0_HARDWARE_SERIAL MSerial2 -#if HAS_TRINAMIC_CONFIG #ifndef X_SLAVE_ADDRESS #define X_SLAVE_ADDRESS 0 #endif From 22724d499fd249c318a628485139c368c9fca2d7 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 19 Dec 2020 21:47:07 -0600 Subject: [PATCH 4/4] Tweak format --- .../pins/stm32f1/pins_BTT_SKR_MINI_E3_V2_0.h | 8 +++--- Marlin/src/pins/stm32f1/pins_FYSETC_AIO_II.h | 25 ++++++++----------- Marlin/src/pins/stm32f1/pins_FYSETC_CHEETAH.h | 1 + 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V2_0.h b/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V2_0.h index 93344941d529..cc4bf46e15a6 100644 --- a/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V2_0.h +++ b/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V2_0.h @@ -49,11 +49,11 @@ #define CONTROLLER_FAN_PIN FAN1_PIN #endif -/** - * TMC220x stepper drivers - * Hardware serial communication ports. - */ #if HAS_TMC_UART + /** + * TMC220x stepper drivers + * Hardware serial communication ports + */ #define X_HARDWARE_SERIAL MSerial4 #define Y_HARDWARE_SERIAL MSerial4 #define Z_HARDWARE_SERIAL MSerial4 diff --git a/Marlin/src/pins/stm32f1/pins_FYSETC_AIO_II.h b/Marlin/src/pins/stm32f1/pins_FYSETC_AIO_II.h index 1485705592cf..3919723f3788 100644 --- a/Marlin/src/pins/stm32f1/pins_FYSETC_AIO_II.h +++ b/Marlin/src/pins/stm32f1/pins_FYSETC_AIO_II.h @@ -87,30 +87,16 @@ #define E0_ENABLE_PIN PC13 #if HAS_TMC_UART - /** * TMC2208/TMC2209 stepper drivers */ - // // Hardware serial with switch - // #define X_HARDWARE_SERIAL MSerial2 #define Y_HARDWARE_SERIAL MSerial2 #define Z_HARDWARE_SERIAL MSerial2 #define E0_HARDWARE_SERIAL MSerial2 - // The 4xTMC2209 module doesn't have a serial multiplexer and - // needs to set *_SLAVE_ADDRESS in Configuration_adv.h for X,Y,Z,E0 - #if HAS_DRIVER(TMC2208) - #define TMC_SERIAL_MULTIPLEXER - #define SERIAL_MUL_PIN1 PB13 - #define SERIAL_MUL_PIN2 PB12 - #endif - - // Reduce baud rate to improve software serial reliability - #define TMC_BAUD_RATE 19200 - // Default TMC slave addresses #ifndef X_SLAVE_ADDRESS #define X_SLAVE_ADDRESS 0 @@ -124,6 +110,17 @@ #ifndef E0_SLAVE_ADDRESS #define E0_SLAVE_ADDRESS 3 #endif + + // The 4xTMC2209 module doesn't have a serial multiplexer and + // needs to set *_SLAVE_ADDRESS in Configuration_adv.h for X,Y,Z,E0 + #if HAS_DRIVER(TMC2208) + #define TMC_SERIAL_MULTIPLEXER + #define SERIAL_MUL_PIN1 PB13 + #define SERIAL_MUL_PIN2 PB12 + #endif + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 #endif // diff --git a/Marlin/src/pins/stm32f1/pins_FYSETC_CHEETAH.h b/Marlin/src/pins/stm32f1/pins_FYSETC_CHEETAH.h index 4e52af256627..c978092ab22c 100644 --- a/Marlin/src/pins/stm32f1/pins_FYSETC_CHEETAH.h +++ b/Marlin/src/pins/stm32f1/pins_FYSETC_CHEETAH.h @@ -86,6 +86,7 @@ #define Z_HARDWARE_SERIAL MSerial2 #define E0_HARDWARE_SERIAL MSerial2 + // Default TMC slave addresses #ifndef X_SLAVE_ADDRESS #define X_SLAVE_ADDRESS 0 #endif