Skip to content

Commit c06142f

Browse files
thisiskeithbthinkyhead
authored andcommitted
Let boards set Default TMC Slave Addresses (MarlinFirmware#20498)
Co-authored-by: Scott Lahteine <github@thinkyhead.com>
1 parent 0738154 commit c06142f

File tree

7 files changed

+130
-32
lines changed

7 files changed

+130
-32
lines changed

Marlin/Configuration_adv.h

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2473,22 +2473,22 @@
24732473
* Set *_SERIAL_TX_PIN and *_SERIAL_RX_PIN to match for all drivers
24742474
* on the same serial port, either here or in your board's pins file.
24752475
*/
2476-
#define X_SLAVE_ADDRESS 0
2477-
#define Y_SLAVE_ADDRESS 0
2478-
#define Z_SLAVE_ADDRESS 0
2479-
#define X2_SLAVE_ADDRESS 0
2480-
#define Y2_SLAVE_ADDRESS 0
2481-
#define Z2_SLAVE_ADDRESS 0
2482-
#define Z3_SLAVE_ADDRESS 0
2483-
#define Z4_SLAVE_ADDRESS 0
2484-
#define E0_SLAVE_ADDRESS 0
2485-
#define E1_SLAVE_ADDRESS 0
2486-
#define E2_SLAVE_ADDRESS 0
2487-
#define E3_SLAVE_ADDRESS 0
2488-
#define E4_SLAVE_ADDRESS 0
2489-
#define E5_SLAVE_ADDRESS 0
2490-
#define E6_SLAVE_ADDRESS 0
2491-
#define E7_SLAVE_ADDRESS 0
2476+
//#define X_SLAVE_ADDRESS 0
2477+
//#define Y_SLAVE_ADDRESS 0
2478+
//#define Z_SLAVE_ADDRESS 0
2479+
//#define X2_SLAVE_ADDRESS 0
2480+
//#define Y2_SLAVE_ADDRESS 0
2481+
//#define Z2_SLAVE_ADDRESS 0
2482+
//#define Z3_SLAVE_ADDRESS 0
2483+
//#define Z4_SLAVE_ADDRESS 0
2484+
//#define E0_SLAVE_ADDRESS 0
2485+
//#define E1_SLAVE_ADDRESS 0
2486+
//#define E2_SLAVE_ADDRESS 0
2487+
//#define E3_SLAVE_ADDRESS 0
2488+
//#define E4_SLAVE_ADDRESS 0
2489+
//#define E5_SLAVE_ADDRESS 0
2490+
//#define E6_SLAVE_ADDRESS 0
2491+
//#define E7_SLAVE_ADDRESS 0
24922492

24932493
/**
24942494
* Software enable

Marlin/src/inc/Conditionals_post.h

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1647,6 +1647,54 @@
16471647
#ifndef E7_INTERPOLATE
16481648
#define E7_INTERPOLATE INTERPOLATE
16491649
#endif
1650+
#ifndef X_SLAVE_ADDRESS
1651+
#define X_SLAVE_ADDRESS 0
1652+
#endif
1653+
#ifndef Y_SLAVE_ADDRESS
1654+
#define Y_SLAVE_ADDRESS 0
1655+
#endif
1656+
#ifndef Z_SLAVE_ADDRESS
1657+
#define Z_SLAVE_ADDRESS 0
1658+
#endif
1659+
#ifndef X2_SLAVE_ADDRESS
1660+
#define X2_SLAVE_ADDRESS 0
1661+
#endif
1662+
#ifndef Y2_SLAVE_ADDRESS
1663+
#define Y2_SLAVE_ADDRESS 0
1664+
#endif
1665+
#ifndef Z2_SLAVE_ADDRESS
1666+
#define Z2_SLAVE_ADDRESS 0
1667+
#endif
1668+
#ifndef Z3_SLAVE_ADDRESS
1669+
#define Z3_SLAVE_ADDRESS 0
1670+
#endif
1671+
#ifndef Z4_SLAVE_ADDRESS
1672+
#define Z4_SLAVE_ADDRESS 0
1673+
#endif
1674+
#ifndef E0_SLAVE_ADDRESS
1675+
#define E0_SLAVE_ADDRESS 0
1676+
#endif
1677+
#ifndef E1_SLAVE_ADDRESS
1678+
#define E1_SLAVE_ADDRESS 0
1679+
#endif
1680+
#ifndef E2_SLAVE_ADDRESS
1681+
#define E2_SLAVE_ADDRESS 0
1682+
#endif
1683+
#ifndef E3_SLAVE_ADDRESS
1684+
#define E3_SLAVE_ADDRESS 0
1685+
#endif
1686+
#ifndef E4_SLAVE_ADDRESS
1687+
#define E4_SLAVE_ADDRESS 0
1688+
#endif
1689+
#ifndef E5_SLAVE_ADDRESS
1690+
#define E5_SLAVE_ADDRESS 0
1691+
#endif
1692+
#ifndef E6_SLAVE_ADDRESS
1693+
#define E6_SLAVE_ADDRESS 0
1694+
#endif
1695+
#ifndef E7_SLAVE_ADDRESS
1696+
#define E7_SLAVE_ADDRESS 0
1697+
#endif
16501698
#endif
16511699

16521700
#if (HAS_E_DRIVER(TMC2660) \

Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V1_0.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,18 @@
3434
#define Y_HARDWARE_SERIAL MSerial4
3535
#define Z_HARDWARE_SERIAL MSerial4
3636
#define E0_HARDWARE_SERIAL MSerial4
37+
38+
// Default TMC slave addresses
39+
#ifndef X_SLAVE_ADDRESS
40+
#define X_SLAVE_ADDRESS 0
41+
#endif
42+
#ifndef Y_SLAVE_ADDRESS
43+
#define Y_SLAVE_ADDRESS 2
44+
#endif
45+
#ifndef Z_SLAVE_ADDRESS
46+
#define Z_SLAVE_ADDRESS 1
47+
#endif
48+
#ifndef E0_SLAVE_ADDRESS
49+
#define E0_SLAVE_ADDRESS 3
50+
#endif
3751
#endif

Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V2_0.h

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,27 @@
4949
#define CONTROLLER_FAN_PIN FAN1_PIN
5050
#endif
5151

52-
/**
53-
* TMC220x stepper drivers
54-
* Hardware serial communication ports.
55-
*/
5652
#if HAS_TMC_UART
53+
/**
54+
* TMC220x stepper drivers
55+
* Hardware serial communication ports
56+
*/
5757
#define X_HARDWARE_SERIAL MSerial4
5858
#define Y_HARDWARE_SERIAL MSerial4
5959
#define Z_HARDWARE_SERIAL MSerial4
6060
#define E0_HARDWARE_SERIAL MSerial4
61+
62+
// Default TMC slave addresses
63+
#ifndef X_SLAVE_ADDRESS
64+
#define X_SLAVE_ADDRESS 0
65+
#endif
66+
#ifndef Y_SLAVE_ADDRESS
67+
#define Y_SLAVE_ADDRESS 2
68+
#endif
69+
#ifndef Z_SLAVE_ADDRESS
70+
#define Z_SLAVE_ADDRESS 1
71+
#endif
72+
#ifndef E0_SLAVE_ADDRESS
73+
#define E0_SLAVE_ADDRESS 3
74+
#endif
6175
#endif

Marlin/src/pins/stm32f1/pins_FYSETC_AIO_II.h

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,19 +87,30 @@
8787
#define E0_ENABLE_PIN PC13
8888

8989
#if HAS_TMC_UART
90-
9190
/**
9291
* TMC2208/TMC2209 stepper drivers
9392
*/
9493

95-
//
9694
// Hardware serial with switch
97-
//
9895
#define X_HARDWARE_SERIAL MSerial2
9996
#define Y_HARDWARE_SERIAL MSerial2
10097
#define Z_HARDWARE_SERIAL MSerial2
10198
#define E0_HARDWARE_SERIAL MSerial2
10299

100+
// Default TMC slave addresses
101+
#ifndef X_SLAVE_ADDRESS
102+
#define X_SLAVE_ADDRESS 0
103+
#endif
104+
#ifndef Y_SLAVE_ADDRESS
105+
#define Y_SLAVE_ADDRESS 1
106+
#endif
107+
#ifndef Z_SLAVE_ADDRESS
108+
#define Z_SLAVE_ADDRESS 2
109+
#endif
110+
#ifndef E0_SLAVE_ADDRESS
111+
#define E0_SLAVE_ADDRESS 3
112+
#endif
113+
103114
// The 4xTMC2209 module doesn't have a serial multiplexer and
104115
// needs to set *_SLAVE_ADDRESS in Configuration_adv.h for X,Y,Z,E0
105116
#if HAS_DRIVER(TMC2208)
@@ -110,7 +121,6 @@
110121

111122
// Reduce baud rate to improve software serial reliability
112123
#define TMC_BAUD_RATE 19200
113-
114124
#endif
115125

116126
//

Marlin/src/pins/stm32f1/pins_FYSETC_CHEETAH.h

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,26 @@
8080
#define E0_DIR_PIN PC14
8181
#define E0_ENABLE_PIN PC13
8282

83-
#define X_HARDWARE_SERIAL MSerial2
84-
#define Y_HARDWARE_SERIAL MSerial2
85-
#define Z_HARDWARE_SERIAL MSerial2
86-
#define E0_HARDWARE_SERIAL MSerial2
83+
#if HAS_TMC_UART
84+
#define X_HARDWARE_SERIAL MSerial2
85+
#define Y_HARDWARE_SERIAL MSerial2
86+
#define Z_HARDWARE_SERIAL MSerial2
87+
#define E0_HARDWARE_SERIAL MSerial2
88+
89+
// Default TMC slave addresses
90+
#ifndef X_SLAVE_ADDRESS
91+
#define X_SLAVE_ADDRESS 0
92+
#endif
93+
#ifndef Y_SLAVE_ADDRESS
94+
#define Y_SLAVE_ADDRESS 1
95+
#endif
96+
#ifndef Z_SLAVE_ADDRESS
97+
#define Z_SLAVE_ADDRESS 2
98+
#endif
99+
#ifndef E0_SLAVE_ADDRESS
100+
#define E0_SLAVE_ADDRESS 3
101+
#endif
102+
#endif
87103

88104
//
89105
// Heaters / Fans

buildroot/tests/STM32F103RC_btt-tests

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ opt_set X_DRIVER_TYPE TMC2209
1717
opt_set Y_DRIVER_TYPE TMC2209
1818
opt_set Z_DRIVER_TYPE TMC2209
1919
opt_set E0_DRIVER_TYPE TMC2209
20-
opt_set X_SLAVE_ADDRESS 0
21-
opt_set Y_SLAVE_ADDRESS 1
22-
opt_set Z_SLAVE_ADDRESS 2
23-
opt_set E0_SLAVE_ADDRESS 3
2420
opt_enable PINS_DEBUGGING
2521

2622
exec_test $1 $2 "BigTreeTech SKR Mini E3 1.0 - Basic Config with TMC2209 HW Serial" "$3"

0 commit comments

Comments
 (0)