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 b5a4aa46a..1ac1363d0 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 7e2451275..1ec590151 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 f027d6074..648414040 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 e9bbb9bb0..6b6ae070b 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 000000000..35286bcf1 --- /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 61cb23203..337ca4492 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 fc3dcfe0c..8c6e5ba14 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 80de9f369..36d3cc628 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 00a3d0cca..d86cc81cc 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 da3e0c648..e5103ec5f 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 120772ffd..ff9814710 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 d8c67076c..0a4367e6c 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 b5a4aa46a..1ac1363d0 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 8ce80807d..901d7f1a1 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 56d18e425..7afe0d445 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 4445a2ab9..68c60435e 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 e49aa08a3..619cd03fc 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 dde7b9ace..0d7ff440f 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 80b293a6b..43084cf99 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 dde7b9ace..0d7ff440f 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 880b84151..cc38a94b6 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 c825e9878..e379e7e23 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 998231b19..bad192f99 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 3e1544335..1b4b24a69 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 66c193715..f6533f611 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 66d902279..a80749bb6 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 46c2217c8..404875323 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 d833df27e..90fd7c0ca 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 ed4ca02d7..38d43dddc 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 d946bc4d2..1c6837e25 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 120b0e380..323036e70 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 59fa09e2d..a010bf682 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 66a1fe4b1..62d62df77 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 74e3d1c50..4fab657ee 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 94f6b54d8..946352e99 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 554618acf..c64f2287f 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 aec834b66..b81af0095 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 073d5c9ce..010a7e440 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 97e1d9861..145acc4fd 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 d16e7e665..53d433d68 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 d16e7e665..53d433d68 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 d16e7e665..53d433d68 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 3d32d052a..bb5765fe8 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 87b77e324..f130c43d4 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 471a84e1f..f81a912f6 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 6aeb06c29..53269b3b5 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 a25aa195a..e81c1d861 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 e56be25e8..83032ee65 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 4e685da74..bee6fdde4 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 b46646035..ef9bc2a71 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 cd814dbd8..66e06e241 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 b2b8c9c37..79245c181 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 809a79c52..fb99a18ef 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 79f751d9a..caea5e454 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}