Skip to content

Commit

Permalink
🎨 Trinamic cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Nov 26, 2024
1 parent 580c99e commit c57f715
Show file tree
Hide file tree
Showing 13 changed files with 39 additions and 54 deletions.
2 changes: 1 addition & 1 deletion Marlin/src/MarlinCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1258,7 +1258,7 @@ void setup() {
SETUP_RUN(runout.setup());
#endif

#if HAS_TMC220x
#if HAS_TMC_UART
SETUP_RUN(tmc_serial_begin());
#endif

Expand Down
6 changes: 4 additions & 2 deletions Marlin/src/feature/tmc_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -614,9 +614,10 @@
default: break;
}
}
#endif
#endif // TMC2160 || TMC5160

#if HAS_TMC220x

static void _tmc_status(TMC2208Stepper &st, const TMC_debug_enum i) {
switch (i) {
case TMC_PWM_SCALE_SUM: SERIAL_ECHO(st.pwm_scale_sum()); break;
Expand Down Expand Up @@ -664,7 +665,8 @@
}
}
#endif
#endif

#endif // HAS_TMC220x

#if HAS_DRIVER(TMC2660)
static void _tmc_parse_drv_status(TMC2660Stepper, const TMC_drv_status_enum) { }
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/feature/tmc_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include <TMCStepper.h>
#include "../module/planner.h"

#define CHOPPER_DEFAULT_12V { 3, -1, 1 }
#define CHOPPER_DEFAULT_12V { 3, -1, 1 } // { toff, hend, hstrt }
#define CHOPPER_DEFAULT_19V { 4, 1, 1 }
#define CHOPPER_DEFAULT_24V { 4, 2, 1 }
#define CHOPPER_DEFAULT_36V { 5, 2, 4 }
Expand Down
3 changes: 2 additions & 1 deletion Marlin/src/module/stepper/trinamic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ enum StealthIndex : uint8_t {
#else
#define TMC_UART_HW_DEFINE(IC, ST, L, AI) TMCMarlin<IC##Stepper, L, AI> stepper##ST(&ST##_HARDWARE_SERIAL, float(ST##_RSENSE), ST##_SLAVE_ADDRESS)
#endif

#define TMC_UART_SW_DEFINE(IC, ST, L, AI) TMCMarlin<IC##Stepper, L, AI> stepper##ST(ST##_SERIAL_RX_PIN, ST##_SERIAL_TX_PIN, float(ST##_RSENSE), ST##_SLAVE_ADDRESS)

#define _TMC_SPI_DEFINE(IC, ST, AI) __TMC_SPI_DEFINE(IC, ST, TMC_##ST##_LABEL, AI)
Expand Down Expand Up @@ -292,7 +293,7 @@ enum StealthIndex : uint8_t {
//
// TMC2208/2209 Driver objects and inits
//
#if HAS_TMC220x
#if HAS_TMC_UART
#if AXIS_HAS_UART(X)
#ifdef X_HARDWARE_SERIAL
TMC_UART_DEFINE(HW, X, X);
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/module/stepper/trinamic.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
#define CHOPPER_TIMING_E CHOPPER_TIMING
#endif

#if HAS_TMC220x
#if HAS_TMC_UART
void tmc_serial_begin();
#endif

Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/pins/esp32/pins_FYSETC_E4.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

#if HAS_TMC_UART
//
// TMC2209 stepper drivers
// TMC2208/TMC2209 stepper drivers
//
#define X_HARDWARE_SERIAL Serial1
#define Y_HARDWARE_SERIAL Serial1
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/pins/esp32/pins_GODI_CONTROLLER_V1_0.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@

#if HAS_TMC_UART
//
// TMC2209 stepper drivers
// TMC2208/TMC2209 stepper drivers
//

//
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/pins/lpc1768/pins_MKS_SBASE.h
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@
#endif // HAS_WIRED_LCD

/**
* Example for trinamic drivers using the J8 connector on MKs Sbase.
* Example for Trinamic drivers using the J8 connector on MKS Sbase.
* 2130s need 1 pin for each driver. 2208/2209s need 2 pins for serial control.
* This board does not have enough pins to use hardware serial.
*/
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/pins/ramps/pins_ZRIB_V53.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@

#if HAS_TMC_UART
/**
* TMC2209 stepper drivers
* TMC2208/TMC2209 stepper drivers
*
* Hardware serial communication ports.
* If undefined software serial is used according to the pins below
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/pins/stm32f1/pins_BTT_SKR_CR6.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@

#if HAS_TMC_UART
/**
* TMC2209 stepper drivers
* TMC2208/TMC2209 stepper drivers
* Hardware serial communication ports.
*/
#define X_HARDWARE_SERIAL MSerial4
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/pins/stm32f1/pins_FLSUN_HISPEED.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
*/
#if HAS_TMC_UART
// SoftwareSerial with one pin per driver
// Compatible with TMC2208 and TMC2209 drivers
// Compatible with TMC2208/TMC2209 drivers
#define X_SERIAL_TX_PIN PA10 // RXD1
#define Y_SERIAL_TX_PIN PA9 // TXD1
#define Z_SERIAL_TX_PIN PC7 // IO1
Expand Down Expand Up @@ -169,7 +169,7 @@
//
// EXTRUDER
//
#if AXIS_DRIVER_TYPE_E0(TMC2208) || AXIS_DRIVER_TYPE_E0(TMC2209)
#if AXIS_HAS_UART(E0)
#define E0_SERIAL_TX_PIN PA8 // IO0
#else
// Motor current PWM pins
Expand Down
62 changes: 22 additions & 40 deletions Marlin/src/pins/stm32f1/pins_KEDI_CONTROLLER_V1_2.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,47 +94,29 @@
#endif

// CS Pins (One pin for each driver)
#if HAS_DRIVER(TMC2130) || HAS_DRIVER(TMC2160) || HAS_DRIVER(TMC2660) || HAS_DRIVER(TMC5130) || HAS_DRIVER(TMC5160)
#ifndef X_CS_PIN
#define X_CS_PIN PC10
#endif
#ifndef Y_CS_PIN
#define Y_CS_PIN PC11
#endif
#ifndef Z_CS_PIN
#define Z_CS_PIN PC12
#endif
#ifndef E0_CS_PIN
#define E0_CS_PIN PC14
#endif
#if HAS_TMC_SPI
#ifndef X_CS_PIN
#define X_CS_PIN PC10
#endif
#ifndef Y_CS_PIN
#define Y_CS_PIN PC11
#endif
#ifndef Z_CS_PIN
#define Z_CS_PIN PC12
#endif
#ifndef E0_CS_PIN
#define E0_CS_PIN PC14
#endif
#endif

// TMC2208 or TMC2209 on UART
#if HAS_DRIVER(TMC2208) || HAS_DRIVER(TMC2209)

// UART Pins (Single pin for both RX & TX)
#ifndef X_PIN_UART
#define X_PIN_UART PC10
#endif
#ifndef Y_PIN_UART
#define Y_PIN_UART PC11
#endif
#ifndef Z_PIN_UART
#define Z_PIN_UART PC12
#endif
#ifndef E0_PIN_UART
#define E0_PIN_UART PC14
#endif

// Configurating Pins
#define X_SERIAL_TX_PIN X_PIN_UART
#define X_SERIAL_RX_PIN X_PIN_UART
#define Y_SERIAL_TX_PIN Y_PIN_UART
#define Y_SERIAL_RX_PIN Y_PIN_UART
#define Z_SERIAL_TX_PIN Z_PIN_UART
#define Z_SERIAL_RX_PIN Z_PIN_UART
#define E0_SERIAL_TX_PIN E0_PIN_UART
#define E0_SERIAL_RX_PIN E0_PIN_UART
/**
* TMC2208/TMC2209 stepper drivers
*/
#if HAS_TMC_UART
#define X_SERIAL_TX_PIN PC10
#define Y_SERIAL_TX_PIN PC11
#define Z_SERIAL_TX_PIN PC12
#define E0_SERIAL_TX_PIN PC14
#endif

//
Expand Down Expand Up @@ -225,7 +207,7 @@

#define FORCE_SOFT_SPI // SPI MODE3

#define LED_PIN EXP1_05_PIN // red pwm
#define LED_PIN EXP1_05_PIN // red pwm
//#define LED_PIN EXP1_04_PIN // green
//#define LED_PIN EXP1_03_PIN // blue

Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/pins/stm32f1/pins_MKS_ROBIN.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@
#endif

//
// Trinamic TMC2208/2209 UART
// Trinamic TMC2208/TMC2209 UART
//
#if HAS_TMC_UART
/**
Expand Down

0 comments on commit c57f715

Please sign in to comment.