Skip to content

Commit

Permalink
🎨 TMC SPI Pins
Browse files Browse the repository at this point in the history
Co-Authored-By: Martin Turski <turningtides@outlook.de>
  • Loading branch information
thinkyhead and quiret committed Mar 24, 2023
1 parent 28666f2 commit 769ad27
Show file tree
Hide file tree
Showing 76 changed files with 574 additions and 640 deletions.
50 changes: 25 additions & 25 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -2979,38 +2979,38 @@
* Override default SPI pins for TMC2130, TMC2160, TMC2660, TMC5130 and TMC5160 drivers here.
* The default pins can be found in your board's pins file.
*/
//#define X_CS_PIN -1
//#define Y_CS_PIN -1
//#define Z_CS_PIN -1
//#define X2_CS_PIN -1
//#define Y2_CS_PIN -1
//#define Z2_CS_PIN -1
//#define Z3_CS_PIN -1
//#define Z4_CS_PIN -1
//#define I_CS_PIN -1
//#define J_CS_PIN -1
//#define K_CS_PIN -1
//#define U_CS_PIN -1
//#define V_CS_PIN -1
//#define W_CS_PIN -1
//#define E0_CS_PIN -1
//#define E1_CS_PIN -1
//#define E2_CS_PIN -1
//#define E3_CS_PIN -1
//#define E4_CS_PIN -1
//#define E5_CS_PIN -1
//#define E6_CS_PIN -1
//#define E7_CS_PIN -1
//#define X_CS_PIN -1
//#define Y_CS_PIN -1
//#define Z_CS_PIN -1
//#define X2_CS_PIN -1
//#define Y2_CS_PIN -1
//#define Z2_CS_PIN -1
//#define Z3_CS_PIN -1
//#define Z4_CS_PIN -1
//#define I_CS_PIN -1
//#define J_CS_PIN -1
//#define K_CS_PIN -1
//#define U_CS_PIN -1
//#define V_CS_PIN -1
//#define W_CS_PIN -1
//#define E0_CS_PIN -1
//#define E1_CS_PIN -1
//#define E2_CS_PIN -1
//#define E3_CS_PIN -1
//#define E4_CS_PIN -1
//#define E5_CS_PIN -1
//#define E6_CS_PIN -1
//#define E7_CS_PIN -1

/**
* Software option for SPI driven drivers (TMC2130, TMC2160, TMC2660, TMC5130 and TMC5160).
* The default SW SPI pins are defined the respective pins files,
* but you can override or define them here.
*/
//#define TMC_USE_SW_SPI
//#define TMC_SW_MOSI -1
//#define TMC_SW_MISO -1
//#define TMC_SW_SCK -1
//#define TMC_SPI_MOSI -1
//#define TMC_SPI_MISO -1
//#define TMC_SPI_SCK -1

// @section tmc/serial

Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/HAL/DUE/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
* Usually the hardware SPI pins are only available to the LCD. This makes the DUE hard SPI used at the same time
* as the TMC2130 soft SPI the most common setup.
*/
#define _IS_HW_SPI(P) (defined(TMC_SW_##P) && (TMC_SW_##P == SD_MOSI_PIN || TMC_SW_##P == SD_MISO_PIN || TMC_SW_##P == SD_SCK_PIN))
#define _IS_HW_SPI(P) (defined(TMC_SPI_##P) && (TMC_SPI_##P == SD_MOSI_PIN || TMC_SPI_##P == SD_MISO_PIN || TMC_SPI_##P == SD_SCK_PIN))

#if ENABLED(SDSUPPORT) && HAS_DRIVER(TMC2130)
#if ENABLED(TMC_USE_SW_SPI)
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/HAL/LPC1768/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o
#if USING_HW_SERIAL0
#define IS_TX0(P) (P == P0_02)
#define IS_RX0(P) (P == P0_03)
#if IS_TX0(TMC_SW_MISO) || IS_RX0(TMC_SW_MOSI)
#if IS_TX0(TMC_SPI_MISO) || IS_RX0(TMC_SPI_MOSI)
#error "Serial port pins (0) conflict with Trinamic SPI pins!"
#elif HAS_PRUSA_MMU1 && (IS_TX0(E_MUX1_PIN) || IS_RX0(E_MUX0_PIN))
#error "Serial port pins (0) conflict with Multi-Material-Unit multiplexer pins!"
Expand All @@ -111,7 +111,7 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o
#define IS_RX1(P) (P == P0_16)
#define _IS_TX1_1 IS_TX1
#define _IS_RX1_1 IS_RX1
#if IS_TX1(TMC_SW_SCK)
#if IS_TX1(TMC_SPI_SCK)
#error "Serial port pins (1) conflict with other pins!"
#elif HAS_ROTARY_ENCODER
#if IS_TX1(BTN_EN2) || IS_RX1(BTN_EN1)
Expand Down
8 changes: 8 additions & 0 deletions Marlin/src/inc/Conditionals_post.h
Original file line number Diff line number Diff line change
Expand Up @@ -2212,6 +2212,14 @@
#undef TMC_UART_IS
#undef ANY_SERIAL_IS

#if defined(__AVR_ARCH__) && defined(TMC_SPI_MISO) && defined(TMC_SPI_MOSI) && defined(TMC_SPI_SCK)
// Check that the pins are the solitary supported SPI hardware pins of the (AVR) platform.
// Otherwise we are forced to enable software SPI.
#if TMC_SPI_MISO != MISO || TMC_SPI_MOSI != MOSI || TMC_SPI_SCK != SCK
#define TMC_USE_SW_SPI
#endif
#endif

// Clean up unused ESP_WIFI pins
#ifdef ESP_WIFI_MODULE_COM
#if !SERIAL_IN_USE(ESP_WIFI_MODULE_COM)
Expand Down
2 changes: 2 additions & 0 deletions Marlin/src/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,8 @@
#error "EXTRA_LIN_ADVANCE_K is now ADVANCE_K_EXTRA."
#elif defined(POLAR_SEGMENTS_PER_SECOND) || defined(DELTA_SEGMENTS_PER_SECOND) || defined(SCARA_SEGMENTS_PER_SECOND) || defined(TPARA_SEGMENTS_PER_SECOND)
#error "(POLAR|DELTA|SCARA|TPARA)_SEGMENTS_PER_SECOND is now DEFAULT_SEGMENTS_PER_SECOND."
#elif defined(TMC_SW_MOSI) || defined(TMC_SW_MISO) || defined(TMC_SW_SCK)
#error "TMC_SW_(MOSI|MISO|SCK) is now TMC_SPI_(MOSI|MISO|SCK)."
#elif ANY(DGUS_LCD_UI_ORIGIN, DGUS_LCD_UI_FYSETC, DGUS_LCD_UI_HIPRECY, DGUS_LCD_UI_MKS, DGUS_LCD_UI_RELOADED) && !defined(DGUS_LCD_UI)
#error "DGUS_LCD_UI_[TYPE] is now set using DGUS_LCD_UI TYPE."
#elif defined(DELTA_PRINTABLE_RADIUS)
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/module/stepper/trinamic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ enum StealthIndex : uint8_t {
// AI = Axis Enum Index
// SWHW = SW/SH UART selection
#if ENABLED(TMC_USE_SW_SPI)
#define __TMC_SPI_DEFINE(IC, ST, L, AI) TMCMarlin<IC##Stepper, L, AI> stepper##ST(ST##_CS_PIN, float(ST##_RSENSE), TMC_SW_MOSI, TMC_SW_MISO, TMC_SW_SCK, ST##_CHAIN_POS)
#define __TMC_SPI_DEFINE(IC, ST, L, AI) TMCMarlin<IC##Stepper, L, AI> stepper##ST(ST##_CS_PIN, float(ST##_RSENSE), TMC_SPI_MOSI, TMC_SPI_MISO, TMC_SPI_SCK, ST##_CHAIN_POS)
#else
#define __TMC_SPI_DEFINE(IC, ST, L, AI) TMCMarlin<IC##Stepper, L, AI> stepper##ST(ST##_CS_PIN, float(ST##_RSENSE), ST##_CHAIN_POS)
#endif
Expand Down
20 changes: 9 additions & 11 deletions Marlin/src/pins/linux/pins_RAMPS_LINUX.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,18 +247,16 @@
#endif

/**
* Default pins for TMC software SPI
* Default pins for TMC SPI
*/
#if ENABLED(TMC_USE_SW_SPI)
#ifndef TMC_SW_MOSI
#define TMC_SW_MOSI 66
#endif
#ifndef TMC_SW_MISO
#define TMC_SW_MISO 44
#endif
#ifndef TMC_SW_SCK
#define TMC_SW_SCK 64
#endif
#ifndef TMC_SPI_MOSI
#define TMC_SPI_MOSI 66
#endif
#ifndef TMC_SPI_MISO
#define TMC_SPI_MISO 44
#endif
#ifndef TMC_SPI_SCK
#define TMC_SPI_SCK 64
#endif

#if HAS_TMC_UART
Expand Down
20 changes: 9 additions & 11 deletions Marlin/src/pins/lpc1768/pins_BIQU_B300_V1.0.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,16 @@
#endif

//
// Software SPI pins for TMC2130 stepper drivers
// Default pins for TMC software SPI
//
#if ENABLED(TMC_USE_SW_SPI)
#ifndef TMC_SW_MOSI
#define TMC_SW_MOSI P0_18 // ETH
#endif
#ifndef TMC_SW_MISO
#define TMC_SW_MISO P0_17 // ETH
#endif
#ifndef TMC_SW_SCK
#define TMC_SW_SCK P0_15 // ETH
#endif
#ifndef TMC_SPI_MOSI
#define TMC_SPI_MOSI P0_18 // ETH
#endif
#ifndef TMC_SPI_MISO
#define TMC_SPI_MISO P0_17 // ETH
#endif
#ifndef TMC_SPI_SCK
#define TMC_SPI_SCK P0_15 // ETH
#endif

//
Expand Down
9 changes: 4 additions & 5 deletions Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_1.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
#define E0_DIR_PIN P2_13
#define E0_ENABLE_PIN P2_12


/** ------ ------
* 1.30 | 1 2 | 2.11 0.17 | 1 2 | 0.15
* 0.18 | 3 4 | 0.16 3.26 | 3 4 | 1.23
Expand Down Expand Up @@ -165,12 +164,12 @@
// When using any TMC SPI-based drivers, software SPI is used
// because pins may be shared with the display or SD card.
#define TMC_USE_SW_SPI
#define TMC_SW_MOSI EXP2_06_PIN
#define TMC_SW_MISO EXP2_01_PIN
#define TMC_SPI_MOSI EXP2_06_PIN
#define TMC_SPI_MISO EXP2_01_PIN
// To minimize pin usage use the same clock pin as the display/SD card reader. (May generate LCD noise.)
#define TMC_SW_SCK EXP2_02_PIN
#define TMC_SPI_SCK EXP2_02_PIN
// If pin 2_06 is unused, it can be used for the clock to avoid the LCD noise.
//#define TMC_SW_SCK P2_06
//#define TMC_SPI_SCK P2_06

#if ENABLED(SOFTWARE_DRIVER_ENABLE)

Expand Down
22 changes: 10 additions & 12 deletions Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,18 +137,16 @@
#endif

//
// Software SPI pins for TMC2130 stepper drivers
// Default pins for TMC software SPI
//
#if ENABLED(TMC_USE_SW_SPI)
#ifndef TMC_SW_MOSI
#define TMC_SW_MOSI P4_28
#endif
#ifndef TMC_SW_MISO
#define TMC_SW_MISO P0_05
#endif
#ifndef TMC_SW_SCK
#define TMC_SW_SCK P0_04
#endif
#ifndef TMC_SPI_MOSI
#define TMC_SPI_MOSI P4_28
#endif
#ifndef TMC_SPI_MISO
#define TMC_SPI_MISO P0_05
#endif
#ifndef TMC_SPI_SCK
#define TMC_SPI_SCK P0_04
#endif

#if HAS_TMC_UART
Expand Down Expand Up @@ -289,7 +287,7 @@
#define DOGLCD_A0 EXP1_06_PIN
#define DOGLCD_SCK EXP1_04_PIN
#define DOGLCD_MOSI EXP1_01_PIN
#define LCD_BACKLIGHT_PIN -1
#define LCD_BACKLIGHT_PIN -1

#elif ENABLED(CR10_STOCKDISPLAY)

Expand Down
20 changes: 9 additions & 11 deletions Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,18 +194,16 @@
#define TEMP_BED_PIN P0_25_A2 // A2 (T2) - (69) - TEMP_BED_PIN

//
// Software SPI pins for TMC2130 stepper drivers
// Default pins for TMC software SPI
//
#if ENABLED(TMC_USE_SW_SPI)
#ifndef TMC_SW_MOSI
#define TMC_SW_MOSI P1_17
#endif
#ifndef TMC_SW_MISO
#define TMC_SW_MISO P0_05
#endif
#ifndef TMC_SW_SCK
#define TMC_SW_SCK P0_04
#endif
#ifndef TMC_SPI_MOSI
#define TMC_SPI_MOSI P1_17
#endif
#ifndef TMC_SPI_MISO
#define TMC_SPI_MISO P0_05
#endif
#ifndef TMC_SPI_SCK
#define TMC_SPI_SCK P0_04
#endif

#if HAS_TMC_UART
Expand Down
18 changes: 8 additions & 10 deletions Marlin/src/pins/lpc1768/pins_MKS_SBASE.h
Original file line number Diff line number Diff line change
Expand Up @@ -300,16 +300,14 @@
// Hardware SPI is on EXP2. See if you can make it work:
// https://github.com/makerbase-mks/MKS-SBASE/issues/25
#define TMC_USE_SW_SPI
#if ENABLED(TMC_USE_SW_SPI)
#ifndef TMC_SW_MOSI
#define TMC_SW_MOSI P0_03 // AUX1
#endif
#ifndef TMC_SW_MISO
#define TMC_SW_MISO P0_02 // AUX1
#endif
#ifndef TMC_SW_SCK
#define TMC_SW_SCK P0_26 // TH4
#endif
#ifndef TMC_SPI_MOSI
#define TMC_SPI_MOSI P0_03 // AUX1
#endif
#ifndef TMC_SPI_MISO
#define TMC_SPI_MISO P0_02 // AUX1
#endif
#ifndef TMC_SPI_SCK
#define TMC_SPI_SCK P0_26 // TH4
#endif

#endif
Expand Down
20 changes: 9 additions & 11 deletions Marlin/src/pins/lpc1768/pins_MKS_SGEN_L.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,18 +132,16 @@
#endif

//
// Software SPI pins for TMC2130 stepper drivers
// Default pins for TMC software SPI
//
#if ENABLED(TMC_USE_SW_SPI)
#ifndef TMC_SW_MOSI
#define TMC_SW_MOSI P4_28
#endif
#ifndef TMC_SW_MISO
#define TMC_SW_MISO P0_05
#endif
#ifndef TMC_SW_SCK
#define TMC_SW_SCK P0_04
#endif
#ifndef TMC_SPI_MOSI
#define TMC_SPI_MOSI P4_28
#endif
#ifndef TMC_SPI_MISO
#define TMC_SPI_MISO P0_05
#endif
#ifndef TMC_SPI_SCK
#define TMC_SPI_SCK P0_04
#endif

#if HAS_TMC_UART
Expand Down
21 changes: 9 additions & 12 deletions Marlin/src/pins/lpc1768/pins_RAMPS_RE_ARM.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,18 +97,16 @@
#endif

//
// Software SPI pins for TMC2130 stepper drivers
// Default pins for TMC software SPI
//
#if ENABLED(TMC_USE_SW_SPI)
#ifndef TMC_SW_MOSI
#define TMC_SW_MOSI P1_00 // ETH
#endif
#ifndef TMC_SW_MISO
#define TMC_SW_MISO P1_08 // ETH
#endif
#ifndef TMC_SW_SCK
#define TMC_SW_SCK P1_09 // ETH
#endif
#ifndef TMC_SPI_MOSI
#define TMC_SPI_MOSI P1_00 // ETH
#endif
#ifndef TMC_SPI_MISO
#define TMC_SPI_MISO P1_08 // ETH
#endif
#ifndef TMC_SPI_SCK
#define TMC_SPI_SCK P1_09 // ETH
#endif

#if HAS_TMC_UART
Expand All @@ -119,7 +117,6 @@
* If undefined software serial is used according to the pins below
*/


// P2_08 E1-Step
// P2_13 E1-Dir

Expand Down
18 changes: 8 additions & 10 deletions Marlin/src/pins/lpc1769/pins_COHESION3D_MINI.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,14 @@
//
// Default pins for TMC software SPI
//
#if ENABLED(TMC_USE_SW_SPI)
#ifndef TMC_SW_MOSI
#define TMC_SW_MOSI P1_16 // Ethernet Expansion - Pin 5
#endif
#ifndef TMC_SW_MISO
#define TMC_SW_MISO P1_17 // Ethernet Expansion - Pin 6
#endif
#ifndef TMC_SW_SCK
#define TMC_SW_SCK P1_08 // Ethernet Expansion - Pin 7
#endif
#ifndef TMC_SPI_MOSI
#define TMC_SPI_MOSI P1_16 // Ethernet Expansion - Pin 5
#endif
#ifndef TMC_SPI_MISO
#define TMC_SPI_MISO P1_17 // Ethernet Expansion - Pin 6
#endif
#ifndef TMC_SPI_SCK
#define TMC_SPI_SCK P1_08 // Ethernet Expansion - Pin 7
#endif

//
Expand Down
Loading

0 comments on commit 769ad27

Please sign in to comment.