From 5c69d45f5bc96d6cc122813baa3e2a76b5a87580 Mon Sep 17 00:00:00 2001 From: teemuatlut Date: Fri, 2 Feb 2018 05:49:40 +0200 Subject: [PATCH] [2.0.x] TMC2130 support for LPC platform (#9114) --- Marlin/Configuration_adv.h | 6 +++ Marlin/src/HAL/HAL_LPC1768/HAL.h | 2 +- Marlin/src/HAL/HAL_LPC1768/HAL_spi.cpp | 16 +++++++ Marlin/src/HAL/HAL_LPC1768/LPC1768_PWM.cpp | 2 +- Marlin/src/HAL/HAL_LPC1768/LPC_SPI.h | 44 +++++++++++++++++++ Marlin/src/HAL/HAL_LPC1768/SoftwareSerial.cpp | 2 +- Marlin/src/HAL/HAL_LPC1768/SoftwareSerial.h | 2 +- Marlin/src/HAL/HAL_LPC1768/WInterrupts.cpp | 2 +- Marlin/src/HAL/HAL_LPC1768/fastio.h | 2 +- .../include/{arduino.h => Arduino.h} | 0 Marlin/src/HAL/HAL_LPC1768/main.cpp | 2 +- Marlin/src/HAL/HAL_TEENSY35_36/HAL_Teensy.h | 4 +- Marlin/src/HAL/SPI.h | 4 ++ Marlin/src/config/default/Configuration_adv.h | 6 +++ .../AlephObjects/TAZ4/Configuration_adv.h | 6 +++ .../examples/Anet/A6/Configuration_adv.h | 6 +++ .../examples/Anet/A8/Configuration_adv.h | 6 +++ .../examples/Azteeg/X5GT/Configuration_adv.h | 6 +++ .../examples/BQ/Hephestos/Configuration_adv.h | 6 +++ .../BQ/Hephestos_2/Configuration_adv.h | 6 +++ .../examples/BQ/WITBOX/Configuration_adv.h | 6 +++ .../examples/Cartesio/Configuration_adv.h | 6 +++ .../Creality/CR-10/Configuration_adv.h | 6 +++ .../config/examples/Felix/Configuration_adv.h | 6 +++ .../FolgerTech/i3-2020/Configuration_adv.h | 6 +++ .../Infitary/i3-M508/Configuration_adv.h | 6 +++ .../examples/MakerParts/Configuration_adv.h | 6 +++ .../examples/Malyan/M150/Configuration_adv.h | 6 +++ .../examples/Malyan/M200/Configuration_adv.h | 6 +++ .../Micromake/C1/enhanced/Configuration_adv.h | 6 +++ .../examples/Mks/Sbase/Configuration_adv.h | 6 +++ .../examples/RigidBot/Configuration_adv.h | 6 +++ .../config/examples/SCARA/Configuration_adv.h | 6 +++ .../examples/Sanguinololu/Configuration_adv.h | 6 +++ .../examples/TinyBoy2/Configuration_adv.h | 6 +++ .../UltiMachine/Archim2/Configuration_adv.h | 6 +++ .../Velleman/K8200/Configuration_adv.h | 6 +++ .../Velleman/K8400/Configuration_adv.h | 6 +++ .../Wanhao/Duplicator 6/Configuration_adv.h | 6 +++ .../FLSUN/auto_calibrate/Configuration_adv.h | 6 +++ .../FLSUN/kossel_mini/Configuration_adv.h | 6 +++ .../delta/generic/Configuration_adv.h | 6 +++ .../delta/kossel_mini/Configuration_adv.h | 6 +++ .../delta/kossel_pro/Configuration_adv.h | 6 +++ .../delta/kossel_xl/Configuration_adv.h | 6 +++ .../gCreate/gMax1.5+/Configuration_adv.h | 6 +++ .../examples/makibox/Configuration_adv.h | 6 +++ .../tvrrug/Round2/Configuration_adv.h | 6 +++ .../config/examples/wt150/Configuration_adv.h | 6 +++ Marlin/src/module/stepper_indirection.cpp | 6 ++- Marlin/src/pins/pins_ARCHIM2.h | 10 +++++ Marlin/src/pins/pins_RAMPS_RE_ARM.h | 15 +++++++ .../CMSIS/LPC1768/lib/LiquidCrystal.cpp | 2 +- frameworks/CMSIS/LPC1768/lib/Stream.cpp | 2 +- platformio.ini | 1 + 55 files changed, 328 insertions(+), 12 deletions(-) create mode 100644 Marlin/src/HAL/HAL_LPC1768/LPC_SPI.h rename Marlin/src/HAL/HAL_LPC1768/include/{arduino.h => Arduino.h} (100%) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index b5a4aa46ad..1ac1363d08 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1085,6 +1085,12 @@ #define E4_CURRENT 800 #define E4_MICROSTEPS 16 + /** + * Use software SPI for TMC2130. + * SW SPI pins are defined the respective pins files. + */ + //#define TMC_USE_SW_SPI + /** * Use Trinamic's ultra quiet stepping mode. * When disabled, Marlin will use spreadCycle stepping mode. diff --git a/Marlin/src/HAL/HAL_LPC1768/HAL.h b/Marlin/src/HAL/HAL_LPC1768/HAL.h index 7e24512750..1ec5901517 100644 --- a/Marlin/src/HAL/HAL_LPC1768/HAL.h +++ b/Marlin/src/HAL/HAL_LPC1768/HAL.h @@ -56,7 +56,7 @@ extern "C" volatile uint32_t _millis; #define B01 1 #define B10 2 -#include "include/arduino.h" +#include "include/Arduino.h" #include "pinmapping.h" #include "fastio.h" diff --git a/Marlin/src/HAL/HAL_LPC1768/HAL_spi.cpp b/Marlin/src/HAL/HAL_LPC1768/HAL_spi.cpp index f027d60744..6484140405 100644 --- a/Marlin/src/HAL/HAL_LPC1768/HAL_spi.cpp +++ b/Marlin/src/HAL/HAL_LPC1768/HAL_spi.cpp @@ -56,6 +56,8 @@ //#include "../../../MarlinConfig.h" //works except in U8g #include "spi_pins.h" #include "fastio.h" +#include "LPC_SPI.h" +#include "../SPI.h" // -------------------------------------------------------------------------- // Public Variables @@ -191,6 +193,20 @@ WRITE(SS_PIN, HIGH); } + void SPIClass::begin() { spiBegin(); } + + uint8_t SPIClass::transfer(uint8_t B) { + return spiTransfer(B); + } + uint16_t SPIClass::transfer16(uint16_t data) { + uint16_t buffer; + buffer = transfer((data>>8) & 0xFF) << 8; + buffer |= transfer(data & 0xFF) && 0xFF; + return buffer; + } + + SPIClass SPI; + #else // hardware SPI diff --git a/Marlin/src/HAL/HAL_LPC1768/LPC1768_PWM.cpp b/Marlin/src/HAL/HAL_LPC1768/LPC1768_PWM.cpp index e9bbb9bb09..6b6ae070b7 100644 --- a/Marlin/src/HAL/HAL_LPC1768/LPC1768_PWM.cpp +++ b/Marlin/src/HAL/HAL_LPC1768/LPC1768_PWM.cpp @@ -74,7 +74,7 @@ #include "../../inc/MarlinConfig.h" #include #include "LPC1768_PWM.h" -#include "arduino.h" +#include "Arduino.h" #define NUM_ISR_PWMS 20 diff --git a/Marlin/src/HAL/HAL_LPC1768/LPC_SPI.h b/Marlin/src/HAL/HAL_LPC1768/LPC_SPI.h new file mode 100644 index 0000000000..35286bcf19 --- /dev/null +++ b/Marlin/src/HAL/HAL_LPC1768/LPC_SPI.h @@ -0,0 +1,44 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once +#ifdef TARGET_LPC1768 +#include + +#define MSBFIRST 0 +#define SPI_MODE3 0 + +class SPISettings { + public: + SPISettings(int a, int b, int c) {}; +}; + +class SPIClass { + public: + void begin(); + void beginTransaction(SPISettings foo) {}; + void endTransaction() {}; + uint8_t transfer(uint8_t data); + uint16_t transfer16(uint16_t data); +}; + +extern SPIClass SPI; +#endif diff --git a/Marlin/src/HAL/HAL_LPC1768/SoftwareSerial.cpp b/Marlin/src/HAL/HAL_LPC1768/SoftwareSerial.cpp index 61cb23203d..337ca4492a 100644 --- a/Marlin/src/HAL/HAL_LPC1768/SoftwareSerial.cpp +++ b/Marlin/src/HAL/HAL_LPC1768/SoftwareSerial.cpp @@ -39,7 +39,7 @@ #include "../../inc/MarlinConfig.h" #include #include -#include "include/arduino.h" +#include "include/Arduino.h" #include "pinmapping.h" #include "fastio.h" #include "SoftwareSerial.h" diff --git a/Marlin/src/HAL/HAL_LPC1768/SoftwareSerial.h b/Marlin/src/HAL/HAL_LPC1768/SoftwareSerial.h index fc3dcfe0c8..8c6e5ba141 100644 --- a/Marlin/src/HAL/HAL_LPC1768/SoftwareSerial.h +++ b/Marlin/src/HAL/HAL_LPC1768/SoftwareSerial.h @@ -33,7 +33,7 @@ #ifndef SOFTWARESERIAL_H #define SOFTWARESERIAL_H -#include "include/arduino.h" +#include "include/Arduino.h" #include //#include "serial.h" #include diff --git a/Marlin/src/HAL/HAL_LPC1768/WInterrupts.cpp b/Marlin/src/HAL/HAL_LPC1768/WInterrupts.cpp index 80de9f3697..36d3cc6280 100644 --- a/Marlin/src/HAL/HAL_LPC1768/WInterrupts.cpp +++ b/Marlin/src/HAL/HAL_LPC1768/WInterrupts.cpp @@ -19,7 +19,7 @@ #ifdef TARGET_LPC1768 #include "../../inc/MarlinConfig.h" -#include "include/arduino.h" +#include "include/Arduino.h" #include "pinmapping.h" //#include "HAL_timers.h" #include "fastio.h" diff --git a/Marlin/src/HAL/HAL_LPC1768/fastio.h b/Marlin/src/HAL/HAL_LPC1768/fastio.h index 00a3d0ccac..d86cc81cc2 100644 --- a/Marlin/src/HAL/HAL_LPC1768/fastio.h +++ b/Marlin/src/HAL/HAL_LPC1768/fastio.h @@ -36,7 +36,7 @@ #define _FASTIO_LPC1768_H #include -#include "include/arduino.h" +#include "include/Arduino.h" #include "pinmapping.h" bool useable_hardware_PWM(pin_t pin); diff --git a/Marlin/src/HAL/HAL_LPC1768/include/arduino.h b/Marlin/src/HAL/HAL_LPC1768/include/Arduino.h similarity index 100% rename from Marlin/src/HAL/HAL_LPC1768/include/arduino.h rename to Marlin/src/HAL/HAL_LPC1768/include/Arduino.h diff --git a/Marlin/src/HAL/HAL_LPC1768/main.cpp b/Marlin/src/HAL/HAL_LPC1768/main.cpp index da3e0c6481..e5103ec5f1 100644 --- a/Marlin/src/HAL/HAL_LPC1768/main.cpp +++ b/Marlin/src/HAL/HAL_LPC1768/main.cpp @@ -30,7 +30,7 @@ extern "C" { #include "HAL_timers.h" #include #include -#include "include/arduino.h" +#include "include/Arduino.h" #include "serial.h" #include "LPC1768_PWM.h" diff --git a/Marlin/src/HAL/HAL_TEENSY35_36/HAL_Teensy.h b/Marlin/src/HAL/HAL_TEENSY35_36/HAL_Teensy.h index 120772ffd7..ff98147100 100644 --- a/Marlin/src/HAL/HAL_TEENSY35_36/HAL_Teensy.h +++ b/Marlin/src/HAL/HAL_TEENSY35_36/HAL_Teensy.h @@ -82,8 +82,8 @@ typedef int8_t pin_t; #define CRITICAL_SECTION_START unsigned char _sreg = SREG; cli(); #define CRITICAL_SECTION_END SREG = _sreg; -// On AVR this is in math.h? -#define square(x) ((x)*(x)) +#undef sq +#define sq(x) ((x)*(x)) #ifndef strncpy_P #define strncpy_P(dest, src, num) strncpy((dest), (src), (num)) diff --git a/Marlin/src/HAL/SPI.h b/Marlin/src/HAL/SPI.h index d8c67076c2..0a4367e6c4 100644 --- a/Marlin/src/HAL/SPI.h +++ b/Marlin/src/HAL/SPI.h @@ -79,4 +79,8 @@ void spiSendBlock(uint8_t token, const uint8_t* buf); /** Begin SPI transaction, set clock, bit order, data mode */ void spiBeginTransaction(uint32_t spiClock, uint8_t bitOrder, uint8_t dataMode); +#ifdef TARGET_LPC1768 + #include "HAL_LPC1768/LPC_SPI.h" +#endif + #endif // _SPI_H_ diff --git a/Marlin/src/config/default/Configuration_adv.h b/Marlin/src/config/default/Configuration_adv.h index b5a4aa46ad..1ac1363d08 100644 --- a/Marlin/src/config/default/Configuration_adv.h +++ b/Marlin/src/config/default/Configuration_adv.h @@ -1085,6 +1085,12 @@ #define E4_CURRENT 800 #define E4_MICROSTEPS 16 + /** + * Use software SPI for TMC2130. + * SW SPI pins are defined the respective pins files. + */ + //#define TMC_USE_SW_SPI + /** * Use Trinamic's ultra quiet stepping mode. * When disabled, Marlin will use spreadCycle stepping mode. diff --git a/Marlin/src/config/examples/AlephObjects/TAZ4/Configuration_adv.h b/Marlin/src/config/examples/AlephObjects/TAZ4/Configuration_adv.h index 8ce80807d0..901d7f1a1a 100644 --- a/Marlin/src/config/examples/AlephObjects/TAZ4/Configuration_adv.h +++ b/Marlin/src/config/examples/AlephObjects/TAZ4/Configuration_adv.h @@ -1085,6 +1085,12 @@ #define E4_CURRENT 800 #define E4_MICROSTEPS 16 + /** + * Use software SPI for TMC2130. + * SW SPI pins are defined the respective pins files. + */ + //#define TMC_USE_SW_SPI + /** * Use Trinamic's ultra quiet stepping mode. * When disabled, Marlin will use spreadCycle stepping mode. diff --git a/Marlin/src/config/examples/Anet/A6/Configuration_adv.h b/Marlin/src/config/examples/Anet/A6/Configuration_adv.h index 56d18e4256..7afe0d4457 100644 --- a/Marlin/src/config/examples/Anet/A6/Configuration_adv.h +++ b/Marlin/src/config/examples/Anet/A6/Configuration_adv.h @@ -1085,6 +1085,12 @@ #define E4_CURRENT 800 #define E4_MICROSTEPS 16 + /** + * Use software SPI for TMC2130. + * SW SPI pins are defined the respective pins files. + */ + //#define TMC_USE_SW_SPI + /** * Use Trinamic's ultra quiet stepping mode. * When disabled, Marlin will use spreadCycle stepping mode. diff --git a/Marlin/src/config/examples/Anet/A8/Configuration_adv.h b/Marlin/src/config/examples/Anet/A8/Configuration_adv.h index 4445a2ab97..68c60435e1 100644 --- a/Marlin/src/config/examples/Anet/A8/Configuration_adv.h +++ b/Marlin/src/config/examples/Anet/A8/Configuration_adv.h @@ -1085,6 +1085,12 @@ #define E4_CURRENT 800 #define E4_MICROSTEPS 16 + /** + * Use software SPI for TMC2130. + * SW SPI pins are defined the respective pins files. + */ + //#define TMC_USE_SW_SPI + /** * Use Trinamic's ultra quiet stepping mode. * When disabled, Marlin will use spreadCycle stepping mode. diff --git a/Marlin/src/config/examples/Azteeg/X5GT/Configuration_adv.h b/Marlin/src/config/examples/Azteeg/X5GT/Configuration_adv.h index e49aa08a37..619cd03fc0 100644 --- a/Marlin/src/config/examples/Azteeg/X5GT/Configuration_adv.h +++ b/Marlin/src/config/examples/Azteeg/X5GT/Configuration_adv.h @@ -1086,6 +1086,12 @@ #define E4_CURRENT 800 #define E4_MICROSTEPS 16 + /** + * Use software SPI for TMC2130. + * SW SPI pins are defined the respective pins files. + */ + //#define TMC_USE_SW_SPI + /** * Use Trinamic's ultra quiet stepping mode. * When disabled, Marlin will use spreadCycle stepping mode. diff --git a/Marlin/src/config/examples/BQ/Hephestos/Configuration_adv.h b/Marlin/src/config/examples/BQ/Hephestos/Configuration_adv.h index dde7b9ace9..0d7ff440f5 100644 --- a/Marlin/src/config/examples/BQ/Hephestos/Configuration_adv.h +++ b/Marlin/src/config/examples/BQ/Hephestos/Configuration_adv.h @@ -1085,6 +1085,12 @@ #define E4_CURRENT 800 #define E4_MICROSTEPS 16 + /** + * Use software SPI for TMC2130. + * SW SPI pins are defined the respective pins files. + */ + //#define TMC_USE_SW_SPI + /** * Use Trinamic's ultra quiet stepping mode. * When disabled, Marlin will use spreadCycle stepping mode. diff --git a/Marlin/src/config/examples/BQ/Hephestos_2/Configuration_adv.h b/Marlin/src/config/examples/BQ/Hephestos_2/Configuration_adv.h index 80b293a6bb..43084cf998 100644 --- a/Marlin/src/config/examples/BQ/Hephestos_2/Configuration_adv.h +++ b/Marlin/src/config/examples/BQ/Hephestos_2/Configuration_adv.h @@ -1085,6 +1085,12 @@ #define E4_CURRENT 800 #define E4_MICROSTEPS 16 + /** + * Use software SPI for TMC2130. + * SW SPI pins are defined the respective pins files. + */ + //#define TMC_USE_SW_SPI + /** * Use Trinamic's ultra quiet stepping mode. * When disabled, Marlin will use spreadCycle stepping mode. diff --git a/Marlin/src/config/examples/BQ/WITBOX/Configuration_adv.h b/Marlin/src/config/examples/BQ/WITBOX/Configuration_adv.h index dde7b9ace9..0d7ff440f5 100644 --- a/Marlin/src/config/examples/BQ/WITBOX/Configuration_adv.h +++ b/Marlin/src/config/examples/BQ/WITBOX/Configuration_adv.h @@ -1085,6 +1085,12 @@ #define E4_CURRENT 800 #define E4_MICROSTEPS 16 + /** + * Use software SPI for TMC2130. + * SW SPI pins are defined the respective pins files. + */ + //#define TMC_USE_SW_SPI + /** * Use Trinamic's ultra quiet stepping mode. * When disabled, Marlin will use spreadCycle stepping mode. diff --git a/Marlin/src/config/examples/Cartesio/Configuration_adv.h b/Marlin/src/config/examples/Cartesio/Configuration_adv.h index 880b84151b..cc38a94b65 100644 --- a/Marlin/src/config/examples/Cartesio/Configuration_adv.h +++ b/Marlin/src/config/examples/Cartesio/Configuration_adv.h @@ -1085,6 +1085,12 @@ #define E4_CURRENT 800 #define E4_MICROSTEPS 16 + /** + * Use software SPI for TMC2130. + * SW SPI pins are defined the respective pins files. + */ + //#define TMC_USE_SW_SPI + /** * Use Trinamic's ultra quiet stepping mode. * When disabled, Marlin will use spreadCycle stepping mode. diff --git a/Marlin/src/config/examples/Creality/CR-10/Configuration_adv.h b/Marlin/src/config/examples/Creality/CR-10/Configuration_adv.h index c825e9878b..e379e7e235 100755 --- a/Marlin/src/config/examples/Creality/CR-10/Configuration_adv.h +++ b/Marlin/src/config/examples/Creality/CR-10/Configuration_adv.h @@ -1085,6 +1085,12 @@ #define E4_CURRENT 800 #define E4_MICROSTEPS 16 + /** + * Use software SPI for TMC2130. + * SW SPI pins are defined the respective pins files. + */ + //#define TMC_USE_SW_SPI + /** * Use Trinamic's ultra quiet stepping mode. * When disabled, Marlin will use spreadCycle stepping mode. diff --git a/Marlin/src/config/examples/Felix/Configuration_adv.h b/Marlin/src/config/examples/Felix/Configuration_adv.h index 998231b19e..bad192f996 100644 --- a/Marlin/src/config/examples/Felix/Configuration_adv.h +++ b/Marlin/src/config/examples/Felix/Configuration_adv.h @@ -1085,6 +1085,12 @@ #define E4_CURRENT 800 #define E4_MICROSTEPS 16 + /** + * Use software SPI for TMC2130. + * SW SPI pins are defined the respective pins files. + */ + //#define TMC_USE_SW_SPI + /** * Use Trinamic's ultra quiet stepping mode. * When disabled, Marlin will use spreadCycle stepping mode. diff --git a/Marlin/src/config/examples/FolgerTech/i3-2020/Configuration_adv.h b/Marlin/src/config/examples/FolgerTech/i3-2020/Configuration_adv.h index 3e15443355..1b4b24a698 100644 --- a/Marlin/src/config/examples/FolgerTech/i3-2020/Configuration_adv.h +++ b/Marlin/src/config/examples/FolgerTech/i3-2020/Configuration_adv.h @@ -1085,6 +1085,12 @@ #define E4_CURRENT 800 #define E4_MICROSTEPS 16 + /** + * Use software SPI for TMC2130. + * SW SPI pins are defined the respective pins files. + */ + //#define TMC_USE_SW_SPI + /** * Use Trinamic's ultra quiet stepping mode. * When disabled, Marlin will use spreadCycle stepping mode. diff --git a/Marlin/src/config/examples/Infitary/i3-M508/Configuration_adv.h b/Marlin/src/config/examples/Infitary/i3-M508/Configuration_adv.h index 66c1937155..f6533f6116 100644 --- a/Marlin/src/config/examples/Infitary/i3-M508/Configuration_adv.h +++ b/Marlin/src/config/examples/Infitary/i3-M508/Configuration_adv.h @@ -1085,6 +1085,12 @@ #define E4_CURRENT 800 #define E4_MICROSTEPS 16 + /** + * Use software SPI for TMC2130. + * SW SPI pins are defined the respective pins files. + */ + //#define TMC_USE_SW_SPI + /** * Use Trinamic's ultra quiet stepping mode. * When disabled, Marlin will use spreadCycle stepping mode. diff --git a/Marlin/src/config/examples/MakerParts/Configuration_adv.h b/Marlin/src/config/examples/MakerParts/Configuration_adv.h index 66d9022793..a80749bb6c 100644 --- a/Marlin/src/config/examples/MakerParts/Configuration_adv.h +++ b/Marlin/src/config/examples/MakerParts/Configuration_adv.h @@ -1086,6 +1086,12 @@ #define E4_CURRENT 800 #define E4_MICROSTEPS 16 + /** + * Use software SPI for TMC2130. + * SW SPI pins are defined the respective pins files. + */ + //#define TMC_USE_SW_SPI + /** * Use Trinamic's ultra quiet stepping mode. * When disabled, Marlin will use spreadCycle stepping mode. diff --git a/Marlin/src/config/examples/Malyan/M150/Configuration_adv.h b/Marlin/src/config/examples/Malyan/M150/Configuration_adv.h index 46c2217c8f..404875323f 100644 --- a/Marlin/src/config/examples/Malyan/M150/Configuration_adv.h +++ b/Marlin/src/config/examples/Malyan/M150/Configuration_adv.h @@ -1085,6 +1085,12 @@ #define E4_CURRENT 800 #define E4_MICROSTEPS 16 + /** + * Use software SPI for TMC2130. + * SW SPI pins are defined the respective pins files. + */ + //#define TMC_USE_SW_SPI + /** * Use Trinamic's ultra quiet stepping mode. * When disabled, Marlin will use spreadCycle stepping mode. diff --git a/Marlin/src/config/examples/Malyan/M200/Configuration_adv.h b/Marlin/src/config/examples/Malyan/M200/Configuration_adv.h index d833df27ea..90fd7c0ca8 100644 --- a/Marlin/src/config/examples/Malyan/M200/Configuration_adv.h +++ b/Marlin/src/config/examples/Malyan/M200/Configuration_adv.h @@ -1085,6 +1085,12 @@ #define E4_CURRENT 800 #define E4_MICROSTEPS 16 + /** + * Use software SPI for TMC2130. + * SW SPI pins are defined the respective pins files. + */ + //#define TMC_USE_SW_SPI + /** * Use Trinamic's ultra quiet stepping mode. * When disabled, Marlin will use spreadCycle stepping mode. diff --git a/Marlin/src/config/examples/Micromake/C1/enhanced/Configuration_adv.h b/Marlin/src/config/examples/Micromake/C1/enhanced/Configuration_adv.h index ed4ca02d71..38d43dddc0 100644 --- a/Marlin/src/config/examples/Micromake/C1/enhanced/Configuration_adv.h +++ b/Marlin/src/config/examples/Micromake/C1/enhanced/Configuration_adv.h @@ -1085,6 +1085,12 @@ #define E4_CURRENT 800 #define E4_MICROSTEPS 16 + /** + * Use software SPI for TMC2130. + * SW SPI pins are defined the respective pins files. + */ + //#define TMC_USE_SW_SPI + /** * Use Trinamic's ultra quiet stepping mode. * When disabled, Marlin will use spreadCycle stepping mode. diff --git a/Marlin/src/config/examples/Mks/Sbase/Configuration_adv.h b/Marlin/src/config/examples/Mks/Sbase/Configuration_adv.h index d946bc4d25..1c6837e251 100644 --- a/Marlin/src/config/examples/Mks/Sbase/Configuration_adv.h +++ b/Marlin/src/config/examples/Mks/Sbase/Configuration_adv.h @@ -1093,6 +1093,12 @@ #define E4_CURRENT 800 #define E4_MICROSTEPS 16 + /** + * Use software SPI for TMC2130. + * SW SPI pins are defined the respective pins files. + */ + //#define TMC_USE_SW_SPI + /** * Use Trinamic's ultra quiet stepping mode. * When disabled, Marlin will use spreadCycle stepping mode. diff --git a/Marlin/src/config/examples/RigidBot/Configuration_adv.h b/Marlin/src/config/examples/RigidBot/Configuration_adv.h index 120b0e380d..323036e709 100644 --- a/Marlin/src/config/examples/RigidBot/Configuration_adv.h +++ b/Marlin/src/config/examples/RigidBot/Configuration_adv.h @@ -1085,6 +1085,12 @@ #define E4_CURRENT 800 #define E4_MICROSTEPS 16 + /** + * Use software SPI for TMC2130. + * SW SPI pins are defined the respective pins files. + */ + //#define TMC_USE_SW_SPI + /** * Use Trinamic's ultra quiet stepping mode. * When disabled, Marlin will use spreadCycle stepping mode. diff --git a/Marlin/src/config/examples/SCARA/Configuration_adv.h b/Marlin/src/config/examples/SCARA/Configuration_adv.h index 59fa09e2d3..a010bf682b 100644 --- a/Marlin/src/config/examples/SCARA/Configuration_adv.h +++ b/Marlin/src/config/examples/SCARA/Configuration_adv.h @@ -1085,6 +1085,12 @@ #define E4_CURRENT 800 #define E4_MICROSTEPS 16 + /** + * Use software SPI for TMC2130. + * SW SPI pins are defined the respective pins files. + */ + //#define TMC_USE_SW_SPI + /** * Use Trinamic's ultra quiet stepping mode. * When disabled, Marlin will use spreadCycle stepping mode. diff --git a/Marlin/src/config/examples/Sanguinololu/Configuration_adv.h b/Marlin/src/config/examples/Sanguinololu/Configuration_adv.h index 66a1fe4b13..62d62df77c 100644 --- a/Marlin/src/config/examples/Sanguinololu/Configuration_adv.h +++ b/Marlin/src/config/examples/Sanguinololu/Configuration_adv.h @@ -1085,6 +1085,12 @@ #define E4_CURRENT 800 #define E4_MICROSTEPS 16 + /** + * Use software SPI for TMC2130. + * SW SPI pins are defined the respective pins files. + */ + //#define TMC_USE_SW_SPI + /** * Use Trinamic's ultra quiet stepping mode. * When disabled, Marlin will use spreadCycle stepping mode. diff --git a/Marlin/src/config/examples/TinyBoy2/Configuration_adv.h b/Marlin/src/config/examples/TinyBoy2/Configuration_adv.h index 74e3d1c50c..4fab657eef 100644 --- a/Marlin/src/config/examples/TinyBoy2/Configuration_adv.h +++ b/Marlin/src/config/examples/TinyBoy2/Configuration_adv.h @@ -1085,6 +1085,12 @@ #define E4_CURRENT 800 #define E4_MICROSTEPS 16 + /** + * Use software SPI for TMC2130. + * SW SPI pins are defined the respective pins files. + */ + //#define TMC_USE_SW_SPI + /** * Use Trinamic's ultra quiet stepping mode. * When disabled, Marlin will use spreadCycle stepping mode. diff --git a/Marlin/src/config/examples/UltiMachine/Archim2/Configuration_adv.h b/Marlin/src/config/examples/UltiMachine/Archim2/Configuration_adv.h index 94f6b54d8a..946352e995 100644 --- a/Marlin/src/config/examples/UltiMachine/Archim2/Configuration_adv.h +++ b/Marlin/src/config/examples/UltiMachine/Archim2/Configuration_adv.h @@ -1085,6 +1085,12 @@ #define E4_CURRENT 800 #define E4_MICROSTEPS 16 + /** + * Use software SPI for TMC2130. + * SW SPI pins are defined the respective pins files. + */ + //#define TMC_USE_SW_SPI + /** * Use Trinamic's ultra quiet stepping mode. * When disabled, Marlin will use spreadCycle stepping mode. diff --git a/Marlin/src/config/examples/Velleman/K8200/Configuration_adv.h b/Marlin/src/config/examples/Velleman/K8200/Configuration_adv.h index 554618acfe..c64f2287ff 100644 --- a/Marlin/src/config/examples/Velleman/K8200/Configuration_adv.h +++ b/Marlin/src/config/examples/Velleman/K8200/Configuration_adv.h @@ -1098,6 +1098,12 @@ #define E4_CURRENT 800 #define E4_MICROSTEPS 16 + /** + * Use software SPI for TMC2130. + * SW SPI pins are defined the respective pins files. + */ + //#define TMC_USE_SW_SPI + /** * Use Trinamic's ultra quiet stepping mode. * When disabled, Marlin will use spreadCycle stepping mode. diff --git a/Marlin/src/config/examples/Velleman/K8400/Configuration_adv.h b/Marlin/src/config/examples/Velleman/K8400/Configuration_adv.h index aec834b664..b81af0095b 100644 --- a/Marlin/src/config/examples/Velleman/K8400/Configuration_adv.h +++ b/Marlin/src/config/examples/Velleman/K8400/Configuration_adv.h @@ -1085,6 +1085,12 @@ #define E4_CURRENT 800 #define E4_MICROSTEPS 16 + /** + * Use software SPI for TMC2130. + * SW SPI pins are defined the respective pins files. + */ + //#define TMC_USE_SW_SPI + /** * Use Trinamic's ultra quiet stepping mode. * When disabled, Marlin will use spreadCycle stepping mode. diff --git a/Marlin/src/config/examples/Wanhao/Duplicator 6/Configuration_adv.h b/Marlin/src/config/examples/Wanhao/Duplicator 6/Configuration_adv.h index 073d5c9ce2..010a7e440d 100644 --- a/Marlin/src/config/examples/Wanhao/Duplicator 6/Configuration_adv.h +++ b/Marlin/src/config/examples/Wanhao/Duplicator 6/Configuration_adv.h @@ -1087,6 +1087,12 @@ #define E4_CURRENT 800 #define E4_MICROSTEPS 16 + /** + * Use software SPI for TMC2130. + * SW SPI pins are defined the respective pins files. + */ + //#define TMC_USE_SW_SPI + /** * Use Trinamic's ultra quiet stepping mode. * When disabled, Marlin will use spreadCycle stepping mode. diff --git a/Marlin/src/config/examples/delta/FLSUN/auto_calibrate/Configuration_adv.h b/Marlin/src/config/examples/delta/FLSUN/auto_calibrate/Configuration_adv.h index 97e1d9861c..145acc4fd1 100644 --- a/Marlin/src/config/examples/delta/FLSUN/auto_calibrate/Configuration_adv.h +++ b/Marlin/src/config/examples/delta/FLSUN/auto_calibrate/Configuration_adv.h @@ -1087,6 +1087,12 @@ #define E4_CURRENT 800 #define E4_MICROSTEPS 16 + /** + * Use software SPI for TMC2130. + * SW SPI pins are defined the respective pins files. + */ + //#define TMC_USE_SW_SPI + /** * Use Trinamic's ultra quiet stepping mode. * When disabled, Marlin will use spreadCycle stepping mode. diff --git a/Marlin/src/config/examples/delta/FLSUN/kossel_mini/Configuration_adv.h b/Marlin/src/config/examples/delta/FLSUN/kossel_mini/Configuration_adv.h index d16e7e6655..53d433d686 100644 --- a/Marlin/src/config/examples/delta/FLSUN/kossel_mini/Configuration_adv.h +++ b/Marlin/src/config/examples/delta/FLSUN/kossel_mini/Configuration_adv.h @@ -1087,6 +1087,12 @@ #define E4_CURRENT 800 #define E4_MICROSTEPS 16 + /** + * Use software SPI for TMC2130. + * SW SPI pins are defined the respective pins files. + */ + //#define TMC_USE_SW_SPI + /** * Use Trinamic's ultra quiet stepping mode. * When disabled, Marlin will use spreadCycle stepping mode. diff --git a/Marlin/src/config/examples/delta/generic/Configuration_adv.h b/Marlin/src/config/examples/delta/generic/Configuration_adv.h index d16e7e6655..53d433d686 100644 --- a/Marlin/src/config/examples/delta/generic/Configuration_adv.h +++ b/Marlin/src/config/examples/delta/generic/Configuration_adv.h @@ -1087,6 +1087,12 @@ #define E4_CURRENT 800 #define E4_MICROSTEPS 16 + /** + * Use software SPI for TMC2130. + * SW SPI pins are defined the respective pins files. + */ + //#define TMC_USE_SW_SPI + /** * Use Trinamic's ultra quiet stepping mode. * When disabled, Marlin will use spreadCycle stepping mode. diff --git a/Marlin/src/config/examples/delta/kossel_mini/Configuration_adv.h b/Marlin/src/config/examples/delta/kossel_mini/Configuration_adv.h index d16e7e6655..53d433d686 100644 --- a/Marlin/src/config/examples/delta/kossel_mini/Configuration_adv.h +++ b/Marlin/src/config/examples/delta/kossel_mini/Configuration_adv.h @@ -1087,6 +1087,12 @@ #define E4_CURRENT 800 #define E4_MICROSTEPS 16 + /** + * Use software SPI for TMC2130. + * SW SPI pins are defined the respective pins files. + */ + //#define TMC_USE_SW_SPI + /** * Use Trinamic's ultra quiet stepping mode. * When disabled, Marlin will use spreadCycle stepping mode. diff --git a/Marlin/src/config/examples/delta/kossel_pro/Configuration_adv.h b/Marlin/src/config/examples/delta/kossel_pro/Configuration_adv.h index 3d32d052ac..bb5765fe8b 100644 --- a/Marlin/src/config/examples/delta/kossel_pro/Configuration_adv.h +++ b/Marlin/src/config/examples/delta/kossel_pro/Configuration_adv.h @@ -1092,6 +1092,12 @@ #define E4_CURRENT 800 #define E4_MICROSTEPS 16 + /** + * Use software SPI for TMC2130. + * SW SPI pins are defined the respective pins files. + */ + //#define TMC_USE_SW_SPI + /** * Use Trinamic's ultra quiet stepping mode. * When disabled, Marlin will use spreadCycle stepping mode. diff --git a/Marlin/src/config/examples/delta/kossel_xl/Configuration_adv.h b/Marlin/src/config/examples/delta/kossel_xl/Configuration_adv.h index 87b77e3243..f130c43d47 100644 --- a/Marlin/src/config/examples/delta/kossel_xl/Configuration_adv.h +++ b/Marlin/src/config/examples/delta/kossel_xl/Configuration_adv.h @@ -1087,6 +1087,12 @@ #define E4_CURRENT 800 #define E4_MICROSTEPS 16 + /** + * Use software SPI for TMC2130. + * SW SPI pins are defined the respective pins files. + */ + //#define TMC_USE_SW_SPI + /** * Use Trinamic's ultra quiet stepping mode. * When disabled, Marlin will use spreadCycle stepping mode. diff --git a/Marlin/src/config/examples/gCreate/gMax1.5+/Configuration_adv.h b/Marlin/src/config/examples/gCreate/gMax1.5+/Configuration_adv.h index 471a84e1f6..f81a912f6e 100644 --- a/Marlin/src/config/examples/gCreate/gMax1.5+/Configuration_adv.h +++ b/Marlin/src/config/examples/gCreate/gMax1.5+/Configuration_adv.h @@ -1085,6 +1085,12 @@ #define E4_CURRENT 800 #define E4_MICROSTEPS 16 + /** + * Use software SPI for TMC2130. + * SW SPI pins are defined the respective pins files. + */ + //#define TMC_USE_SW_SPI + /** * Use Trinamic's ultra quiet stepping mode. * When disabled, Marlin will use spreadCycle stepping mode. diff --git a/Marlin/src/config/examples/makibox/Configuration_adv.h b/Marlin/src/config/examples/makibox/Configuration_adv.h index 6aeb06c29d..53269b3b50 100644 --- a/Marlin/src/config/examples/makibox/Configuration_adv.h +++ b/Marlin/src/config/examples/makibox/Configuration_adv.h @@ -1085,6 +1085,12 @@ #define E4_CURRENT 800 #define E4_MICROSTEPS 16 + /** + * Use software SPI for TMC2130. + * SW SPI pins are defined the respective pins files. + */ + //#define TMC_USE_SW_SPI + /** * Use Trinamic's ultra quiet stepping mode. * When disabled, Marlin will use spreadCycle stepping mode. diff --git a/Marlin/src/config/examples/tvrrug/Round2/Configuration_adv.h b/Marlin/src/config/examples/tvrrug/Round2/Configuration_adv.h index a25aa195ac..e81c1d8611 100644 --- a/Marlin/src/config/examples/tvrrug/Round2/Configuration_adv.h +++ b/Marlin/src/config/examples/tvrrug/Round2/Configuration_adv.h @@ -1085,6 +1085,12 @@ #define E4_CURRENT 800 #define E4_MICROSTEPS 16 + /** + * Use software SPI for TMC2130. + * SW SPI pins are defined the respective pins files. + */ + //#define TMC_USE_SW_SPI + /** * Use Trinamic's ultra quiet stepping mode. * When disabled, Marlin will use spreadCycle stepping mode. diff --git a/Marlin/src/config/examples/wt150/Configuration_adv.h b/Marlin/src/config/examples/wt150/Configuration_adv.h index e56be25e8f..83032ee656 100644 --- a/Marlin/src/config/examples/wt150/Configuration_adv.h +++ b/Marlin/src/config/examples/wt150/Configuration_adv.h @@ -1086,6 +1086,12 @@ #define E4_CURRENT 800 #define E4_MICROSTEPS 16 + /** + * Use software SPI for TMC2130. + * SW SPI pins are defined the respective pins files. + */ + //#define TMC_USE_SW_SPI + /** * Use Trinamic's ultra quiet stepping mode. * When disabled, Marlin will use spreadCycle stepping mode. diff --git a/Marlin/src/module/stepper_indirection.cpp b/Marlin/src/module/stepper_indirection.cpp index 4e685da74e..bee6fdde44 100644 --- a/Marlin/src/module/stepper_indirection.cpp +++ b/Marlin/src/module/stepper_indirection.cpp @@ -137,7 +137,11 @@ #include "planner.h" #include "../core/enum.h" - #define _TMC2130_DEFINE(ST) TMC2130Stepper stepper##ST(ST##_ENABLE_PIN, ST##_DIR_PIN, ST##_STEP_PIN, ST##_CS_PIN) + #if ENABLED(TMC_USE_SW_SPI) + #define _TMC2130_DEFINE(ST) TMC2130Stepper stepper##ST(ST##_ENABLE_PIN, ST##_DIR_PIN, ST##_STEP_PIN, ST##_CS_PIN, TMC_SW_MOSI, TMC_SW_MISO, TMC_SW_SCK) + #else + #define _TMC2130_DEFINE(ST) TMC2130Stepper stepper##ST(ST##_ENABLE_PIN, ST##_DIR_PIN, ST##_STEP_PIN, ST##_CS_PIN) + #endif // Stepper objects of TMC2130 steppers used #if ENABLED(X_IS_TMC2130) diff --git a/Marlin/src/pins/pins_ARCHIM2.h b/Marlin/src/pins/pins_ARCHIM2.h index b466460357..ef9bc2a713 100644 --- a/Marlin/src/pins/pins_ARCHIM2.h +++ b/Marlin/src/pins/pins_ARCHIM2.h @@ -93,6 +93,16 @@ #define E1_CS_PIN 19 // PA10 E2_nCS #define E1_DIAG_PIN 25 // PD0 E2_DIAG +// +// Software SPI pins for TMC2130 stepper drivers. +// Required for the Archim2 board. +// +#if ENABLED(TMC_USE_SW_SPI) + #define TMC_SW_MOSI 28 // PD3 + #define TMC_SW_MISO 26 // PD1 + #define TMC_SW_SCK 27 // PD2 +#endif + // // Temperature Sensors // diff --git a/Marlin/src/pins/pins_RAMPS_RE_ARM.h b/Marlin/src/pins/pins_RAMPS_RE_ARM.h index cd814dbd88..66e06e241f 100644 --- a/Marlin/src/pins/pins_RAMPS_RE_ARM.h +++ b/Marlin/src/pins/pins_RAMPS_RE_ARM.h @@ -68,26 +68,41 @@ #define X_STEP_PIN P2_01 // (54) #define X_DIR_PIN P0_11 // (55) #define X_ENABLE_PIN P0_10 // (38) +#define X_CS_PIN P1_01 // ETH #define Y_STEP_PIN P2_02 // (60) #define Y_DIR_PIN P0_20 // (61) #define Y_ENABLE_PIN P0_19 // (56) +#define Y_CS_PIN P1_04 // ETH #define Z_STEP_PIN P2_03 // (46) #define Z_DIR_PIN P0_22 // (48) #define Z_ENABLE_PIN P0_21 // (62) +#define Z_CS_PIN P1_10 // ETH #define E0_STEP_PIN P2_00 // (26) #define E0_DIR_PIN P0_05 // (28) #define E0_ENABLE_PIN P0_04 // (24) +#define E0_CS_PIN P1_14 // ETH #define E1_STEP_PIN P2_08 // (36) #define E1_DIR_PIN P2_13 // (34) #define E1_ENABLE_PIN P4_29 // (30) +#define E1_CS_PIN -1 #define E2_STEP_PIN P2_08 // (36) #define E2_DIR_PIN P2_13 // (34) #define E2_ENABLE_PIN P4_29 // (30) +#define E2_CS_PIN -1 + +// +// Software SPI pins for TMC2130 stepper drivers +// +#if ENABLED(TMC_USE_SW_SPI) + #define TMC_SW_MOSI P1_00 // ETH + #define TMC_SW_MISO P1_08 // ETH + #define TMC_SW_SCK P1_09 // ETH +#endif // // Temperature Sensors diff --git a/frameworks/CMSIS/LPC1768/lib/LiquidCrystal.cpp b/frameworks/CMSIS/LPC1768/lib/LiquidCrystal.cpp index b2b8c9c370..79245c1815 100644 --- a/frameworks/CMSIS/LPC1768/lib/LiquidCrystal.cpp +++ b/frameworks/CMSIS/LPC1768/lib/LiquidCrystal.cpp @@ -3,7 +3,7 @@ #include #include #include -#include +#include // When the display powers up, it is configured as follows: // diff --git a/frameworks/CMSIS/LPC1768/lib/Stream.cpp b/frameworks/CMSIS/LPC1768/lib/Stream.cpp index 809a79c529..fb99a18ef4 100644 --- a/frameworks/CMSIS/LPC1768/lib/Stream.cpp +++ b/frameworks/CMSIS/LPC1768/lib/Stream.cpp @@ -23,7 +23,7 @@ */ #include -#include +#include #include "Stream.h" diff --git a/platformio.ini b/platformio.ini index 79f751d9ac..caea5e4548 100644 --- a/platformio.ini +++ b/platformio.ini @@ -113,6 +113,7 @@ lib_ldf_mode = off lib_extra_dirs = frameworks lib_deps = CMSIS-LPC1768 U8glib-HAL + TMC2130Stepper@>=2.1.1 extra_scripts = Marlin/src/HAL/HAL_LPC1768/lpc1768_flag_script.py src_filter = ${common.default_src_filter}