[2.0.x] TMC2130 support for LPC platform (#9114)

This commit is contained in:
teemuatlut 2018-02-02 05:49:40 +02:00 committed by Scott Lahteine
parent 34160806c0
commit 5c69d45f5b
55 changed files with 328 additions and 12 deletions

View File

@ -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.

View File

@ -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"

View File

@ -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

View File

@ -74,7 +74,7 @@
#include "../../inc/MarlinConfig.h"
#include <lpc17xx_pinsel.h>
#include "LPC1768_PWM.h"
#include "arduino.h"
#include "Arduino.h"
#define NUM_ISR_PWMS 20

View File

@ -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 <http://www.gnu.org/licenses/>.
*
*/
#pragma once
#ifdef TARGET_LPC1768
#include <stdint.h>
#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

View File

@ -39,7 +39,7 @@
#include "../../inc/MarlinConfig.h"
#include <stdint.h>
#include <stdarg.h>
#include "include/arduino.h"
#include "include/Arduino.h"
#include "pinmapping.h"
#include "fastio.h"
#include "SoftwareSerial.h"

View File

@ -33,7 +33,7 @@
#ifndef SOFTWARESERIAL_H
#define SOFTWARESERIAL_H
#include "include/arduino.h"
#include "include/Arduino.h"
#include <stdint.h>
//#include "serial.h"
#include <Stream.h>

View File

@ -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"

View File

@ -36,7 +36,7 @@
#define _FASTIO_LPC1768_H
#include <LPC17xx.h>
#include "include/arduino.h"
#include "include/Arduino.h"
#include "pinmapping.h"
bool useable_hardware_PWM(pin_t pin);

View File

@ -30,7 +30,7 @@ extern "C" {
#include "HAL_timers.h"
#include <stdio.h>
#include <stdarg.h>
#include "include/arduino.h"
#include "include/Arduino.h"
#include "serial.h"
#include "LPC1768_PWM.h"

View File

@ -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))

View File

@ -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_

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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)

View File

@ -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
//

View File

@ -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

View File

@ -3,7 +3,7 @@
#include <stdio.h>
#include <string.h>
#include <inttypes.h>
#include <arduino.h>
#include <Arduino.h>
// When the display powers up, it is configured as follows:
//

View File

@ -23,7 +23,7 @@
*/
#include <stdlib.h>
#include <arduino.h>
#include <Arduino.h>
#include "Stream.h"

View File

@ -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}