diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index a3b9360320..f8aca9aa99 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -2961,7 +2961,7 @@ */ #if HAS_TRINAMIC_CONFIG || HAS_TMC26X - #define HOLD_MULTIPLIER 0.5 // Scales down the holding current from run current + #define HOLD_MULTIPLIER 0.7 // Scales down the holding current from run current /** * Interpolate microsteps to 256 @@ -2973,7 +2973,7 @@ #define X_CURRENT 800 // (mA) RMS current. Multiply by 1.414 for peak current. #define X_CURRENT_HOME X_CURRENT // (mA) RMS current for sensorless homing #define X_MICROSTEPS 16 // 0..256 - #define X_RSENSE 0.11 // Multiplied x1000 for TMC26X + #define X_RSENSE 0.022 // Multiplied x1000 for TMC26X #define X_CHAIN_POS -1 // -1..0: Not chained. 1: MCU MOSI connected. 2: Next in chain, ... //#define X_INTERPOLATE true // Enable to override 'INTERPOLATE' for the X axis //#define X_HOLD_MULTIPLIER 0.5 // Enable to override 'HOLD_MULTIPLIER' for the X axis @@ -2993,7 +2993,7 @@ #define Y_CURRENT 800 #define Y_CURRENT_HOME Y_CURRENT #define Y_MICROSTEPS 16 - #define Y_RSENSE 0.11 + #define Y_RSENSE 0.022 #define Y_CHAIN_POS -1 //#define Y_INTERPOLATE true //#define Y_HOLD_MULTIPLIER 0.5 @@ -3215,7 +3215,7 @@ * 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_USE_SW_SPI //#define TMC_SPI_MOSI -1 //#define TMC_SPI_MISO -1 //#define TMC_SPI_SCK -1 @@ -3275,7 +3275,7 @@ * When disabled, Marlin will use spreadCycle stepping mode. */ #if HAS_STEALTHCHOP - #define STEALTHCHOP_XY + //#define STEALTHCHOP_XY #define STEALTHCHOP_Z #define STEALTHCHOP_I #define STEALTHCHOP_J @@ -3301,11 +3301,11 @@ * Define your own with: * { , , hysteresis_start[1..8] } */ - #define CHOPPER_TIMING CHOPPER_DEFAULT_24V // All axes (override below) - //#define CHOPPER_TIMING_X CHOPPER_TIMING // For X Axes (override below) + //#define CHOPPER_TIMING CHOPPER_DEFAULT_36V // All axes (override below) + #define CHOPPER_TIMING_X CHOPPER_DEFAULT_36V // For X Axes (override below) //#define CHOPPER_TIMING_X2 CHOPPER_TIMING_X - //#define CHOPPER_TIMING_Y CHOPPER_TIMING // For Y Axes (override below) - //#define CHOPPER_TIMING_Y2 CHOPPER_TIMING_Y + #define CHOPPER_TIMING_Y CHOPPER_DEFAULT_36V // For Y Axes (override below) + #define CHOPPER_TIMING_Y2 CHOPPER_TIMING_Y //#define CHOPPER_TIMING_Z CHOPPER_TIMING // For Z Axes (override below) //#define CHOPPER_TIMING_Z2 CHOPPER_TIMING_Z //#define CHOPPER_TIMING_Z3 CHOPPER_TIMING_Z @@ -3316,7 +3316,7 @@ //#define CHOPPER_TIMING_U CHOPPER_TIMING // For U Axis //#define CHOPPER_TIMING_V CHOPPER_TIMING // For V Axis //#define CHOPPER_TIMING_W CHOPPER_TIMING // For W Axis - //#define CHOPPER_TIMING_E CHOPPER_TIMING // For Extruders (override below) + #define CHOPPER_TIMING_E CHOPPER_DEFAULT_24V // For Extruders (override below) //#define CHOPPER_TIMING_E1 CHOPPER_TIMING_E //#define CHOPPER_TIMING_E2 CHOPPER_TIMING_E //#define CHOPPER_TIMING_E3 CHOPPER_TIMING_E @@ -3338,12 +3338,12 @@ * M912 - Clear stepper driver overtemperature pre-warn condition flag. * M122 - Report driver parameters (Requires TMC_DEBUG) */ - //#define MONITOR_DRIVER_STATUS + #define MONITOR_DRIVER_STATUS #if ENABLED(MONITOR_DRIVER_STATUS) #define CURRENT_STEP_DOWN 50 // [mA] #define REPORT_CURRENT_CHANGE - #define STOP_ON_ERROR + //#define STOP_ON_ERROR #endif // @section tmc/hybrid diff --git a/Marlin/src/HAL/LPC4078/HAL_SPI.cpp b/Marlin/src/HAL/LPC4078/HAL_SPI.cpp index 3af5677fbc..4aefb25143 100644 --- a/Marlin/src/HAL/LPC4078/HAL_SPI.cpp +++ b/Marlin/src/HAL/LPC4078/HAL_SPI.cpp @@ -164,123 +164,103 @@ // /** // * @brief Wait until TXE (tx empty) flag is set and BSY (busy) flag unset. // */ -// static inline void waitSpiTxEnd(LPC_SSP_TypeDef *spi_d) { -// while (SSP_GetStatus(spi_d, SSP_STAT_TXFIFO_EMPTY) == RESET) { /* nada */ } // wait until TXE=1 -// while (SSP_GetStatus(spi_d, SSP_STAT_BUSY) == SET) { /* nada */ } // wait until BSY=0 -// } +static inline void waitSpiTxEnd(void *spi_d) { + #warning unimplemented + // while (SSP_GetStatus(spi_d, SSP_STAT_TXFIFO_EMPTY) == RESET) { /* nada */ } // wait until TXE=1 + // while (SSP_GetStatus(spi_d, SSP_STAT_BUSY) == SET) { /* nada */ } // wait until BSY=0 +} // // Retain the pin init state of the SPI, to avoid init more than once, // // even if more instances of SPIClass exist -// static bool spiInitialised[BOARD_NR_SPI] = { false }; +static bool spiInitialised[BOARD_NR_SPI] = { false }; -// SPIClass::SPIClass(uint8_t device) { +SPIClass::SPIClass(uint8_t device) { // // Init things specific to each SPI device // // clock divider setup is a bit of hack, and needs to be improved at a later date. -// #if BOARD_NR_SPI >= 1 -// _settings[0].spi_d = LPC_SSP0; + #if BOARD_NR_SPI >= 1 + _settings[0].device_id = 0; + _settings[0].m_config.pin_miso = BOARD_SPI1_MISO_PIN; + _settings[0].m_config.pin_mosi = BOARD_SPI1_MOSI_PIN; + _settings[0].m_config.pin_sck = BOARD_SPI1_SCK_PIN; + _settings[0].m_config.pin_ssel = BOARD_SPI1_NSS_PIN; // _settings[0].dataMode = SPI_MODE0; // _settings[0].dataSize = DATA_SIZE_8BIT; // _settings[0].clock = SPI_CLOCK_MAX; // //_settings[0].clockDivider = determine_baud_rate(_settings[0].spi_d, _settings[0].clock); -// #endif + #endif -// #if BOARD_NR_SPI >= 2 -// _settings[1].spi_d = LPC_SSP1; + #if BOARD_NR_SPI >= 2 + _settings[1].device_id = 2; + _settings[1].m_config.pin_miso = BOARD_SPI2_MISO_PIN; + _settings[1].m_config.pin_mosi = BOARD_SPI2_MOSI_PIN; + _settings[1].m_config.pin_sck = BOARD_SPI2_SCK_PIN; + _settings[1].m_config.pin_ssel = BOARD_SPI2_NSS_PIN; // _settings[1].dataMode = SPI_MODE0; // _settings[1].dataSize = DATA_SIZE_8BIT; // _settings[1].clock = SPI_CLOCK_MAX; // //_settings[1].clockDivider = determine_baud_rate(_settings[1].spi_d, _settings[1].clock); -// #endif + #endif -// setModule(device); + setModule(device); // // Init the GPDMA controller // // TODO: call once in the constructor? or each time? // GPDMA_Init(); -// } +} -// SPIClass::SPIClass(pin_t mosi, pin_t miso, pin_t sclk, pin_t ssel) { -// #if BOARD_NR_SPI >= 1 -// if (mosi == BOARD_SPI1_MOSI_PIN) SPIClass(1); -// #endif -// #if BOARD_NR_SPI >= 2 -// if (mosi == BOARD_SPI2_MOSI_PIN) SPIClass(2); -// #endif -// } +SPIClass::SPIClass(pin_t mosi, pin_t miso, pin_t sclk, pin_t ssel) { + #if BOARD_NR_SPI >= 1 + if (mosi == BOARD_SPI1_MOSI_PIN) SPIClass(1); + #endif + #if BOARD_NR_SPI >= 2 + if (mosi == BOARD_SPI2_MOSI_PIN) SPIClass(2); + #endif +} -// void SPIClass::begin() { +void SPIClass::begin() { // // Init the SPI pins in the first begin call -// if ((_currentSetting->spi_d == LPC_SSP0 && spiInitialised[0] == false) || -// (_currentSetting->spi_d == LPC_SSP1 && spiInitialised[1] == false)) { -// pin_t sck, miso, mosi; -// if (_currentSetting->spi_d == LPC_SSP0) { -// sck = BOARD_SPI1_SCK_PIN; -// miso = BOARD_SPI1_MISO_PIN; -// mosi = BOARD_SPI1_MOSI_PIN; -// spiInitialised[0] = true; -// } -// else if (_currentSetting->spi_d == LPC_SSP1) { -// sck = BOARD_SPI2_SCK_PIN; -// miso = BOARD_SPI2_MISO_PIN; -// mosi = BOARD_SPI2_MOSI_PIN; -// spiInitialised[1] = true; -// } -// PINSEL_CFG_Type PinCfg; // data structure to hold init values -// PinCfg.Funcnum = 2; -// PinCfg.OpenDrain = 0; -// PinCfg.Pinmode = 0; -// PinCfg.Pinnum = LPC176x::pin_bit(sck); -// PinCfg.Portnum = LPC176x::pin_port(sck); -// PINSEL_ConfigPin(&PinCfg); -// SET_OUTPUT(sck); + if ((_currentSetting->device_id == 0 && spiInitialised[0] == false) || + (_currentSetting->device_id == 1 && spiInitialised[1] == false) || + (_currentSetting->device_id == 2 && spiInitialised[2] == false)) { + MCUI::SSP::init(_currentSetting->device_id, _currentSetting->m_config); + spiInitialised[_currentSetting->device_id] = true; + } + updateSettings(); +} -// PinCfg.Pinnum = LPC176x::pin_bit(miso); -// PinCfg.Portnum = LPC176x::pin_port(miso); -// PINSEL_ConfigPin(&PinCfg); -// SET_INPUT(miso); +void SPIClass::beginTransaction(const SPISettings &cfg) { + setBitOrder(cfg.bitOrder); + setDataMode(cfg.dataMode); + setDataSize(cfg.dataSize); + //setClockDivider(determine_baud_rate(_currentSetting->spi_d, settings.clock)); + begin(); +} -// PinCfg.Pinnum = LPC176x::pin_bit(mosi); -// PinCfg.Portnum = LPC176x::pin_port(mosi); -// PINSEL_ConfigPin(&PinCfg); -// SET_OUTPUT(mosi); -// } +uint8_t SPIClass::transfer(const uint16_t b) { + uint16_t rx_word = 0; + // clear rx fifo + while(MCUI::SSP::read(_currentSetting->device_id, &rx_word) == 1); + MCUI::SSP::write(_currentSetting->device_id, b); + while(MCUI::SSP::read(_currentSetting->device_id, &rx_word) != 1); + return rx_word; +} -// updateSettings(); -// SSP_Cmd(_currentSetting->spi_d, ENABLE); // start SSP running -// } +uint16_t SPIClass::transfer16(const uint16_t data) { + return (transfer((data >> 8) & 0xFF) << 8) | (transfer(data & 0xFF) & 0xFF); +} -// void SPIClass::beginTransaction(const SPISettings &cfg) { -// setBitOrder(cfg.bitOrder); -// setDataMode(cfg.dataMode); -// setDataSize(cfg.dataSize); -// //setClockDivider(determine_baud_rate(_currentSetting->spi_d, settings.clock)); -// begin(); -// } - -// uint8_t SPIClass::transfer(const uint16_t b) { -// // Send and receive a single byte -// SSP_ReceiveData(_currentSetting->spi_d); // read any previous data -// SSP_SendData(_currentSetting->spi_d, b); -// waitSpiTxEnd(_currentSetting->spi_d); // wait for it to finish -// return SSP_ReceiveData(_currentSetting->spi_d); -// } - -// uint16_t SPIClass::transfer16(const uint16_t data) { -// return (transfer((data >> 8) & 0xFF) << 8) | (transfer(data & 0xFF) & 0xFF); -// } - -// void SPIClass::end() { +void SPIClass::end() { // // Neither is needed for Marlin // //SSP_Cmd(_currentSetting->spi_d, DISABLE); // //SSP_DeInit(_currentSetting->spi_d); -// } +} -// void SPIClass::send(uint8_t data) { -// SSP_SendData(_currentSetting->spi_d, data); -// } +void SPIClass::send(uint8_t data) { + MCUI::SSP::write(_currentSetting->device_id, data); +} -// void SPIClass::dmaSend(void *buf, uint16_t length, bool minc) { +void SPIClass::dmaSend(void *buf, uint16_t length, bool minc) { // //TODO: LPC dma can only write 0xFFF bytes at once. // GPDMA_Channel_CFG_Type GPDMACfg; @@ -329,76 +309,46 @@ // waitSpiTxEnd(_currentSetting->spi_d); // SSP_DMACmd(_currentSetting->spi_d, SSP_DMA_TX, DISABLE); -// } +} -// uint16_t SPIClass::read() { -// return SSP_ReceiveData(_currentSetting->spi_d); -// } +uint16_t SPIClass::read() { + uint16_t rx_word = 0; + MCUI::SSP::read(_currentSetting->device_id, &rx_word); + return rx_word; +} -// void SPIClass::read(uint8_t *buf, uint32_t len) { -// for (uint16_t i = 0; i < len; i++) buf[i] = transfer(0xFF); -// } +void SPIClass::read(uint8_t *buf, uint32_t len) { + uint16_t rx_word = 0; + // clear rx fifo + while(MCUI::SSP::read(_currentSetting->device_id, &rx_word) == 1); + for (uint16_t i = 0; i < len; i++) { + MCUI::SSP::write(_currentSetting->device_id, 0xFF); + while(MCUI::SSP::read(_currentSetting->device_id, &rx_word) != 1); + buf[i] = rx_word; + } +} -// void SPIClass::setClock(uint32_t clock) { _currentSetting->clock = clock; } +void SPIClass::setClock(uint32_t clock) { _currentSetting->clock = clock; } -// void SPIClass::setModule(uint8_t device) { _currentSetting = &_settings[device - 1]; } // SPI channels are called 1, 2, and 3 but the array is zero-indexed +void SPIClass::setModule(uint8_t device) { _currentSetting = &_settings[device - 1]; } // SPI channels are called 1, 2, and 3 but the array is zero-indexed -// void SPIClass::setBitOrder(uint8_t bitOrder) { _currentSetting->bitOrder = bitOrder; } +void SPIClass::setBitOrder(uint8_t bitOrder) { _currentSetting->bitOrder = bitOrder; } -// void SPIClass::setDataMode(uint8_t dataMode) { _currentSetting->dataMode = dataMode; } +void SPIClass::setDataMode(uint8_t dataMode) { _currentSetting->dataMode = dataMode; } -// void SPIClass::setDataSize(uint32_t dataSize) { _currentSetting->dataSize = dataSize; } +void SPIClass::setDataSize(uint32_t dataSize) { _currentSetting->dataSize = dataSize; } // /** // * Set up/tear down // */ -// void SPIClass::updateSettings() { -// //SSP_DeInit(_currentSetting->spi_d); //todo: need force de init?! +void SPIClass::updateSettings() { } -// // Divide PCLK by 2 for SSP0 -// //CLKPWR_SetPCLKDiv(_currentSetting->spi_d == LPC_SSP0 ? CLKPWR_PCLKSEL_SSP0 : CLKPWR_PCLKSEL_SSP1, CLKPWR_PCLKSEL_CCLK_DIV_2); +SPIClass SPI(1); -// SSP_CFG_Type HW_SPI_init; // data structure to hold init values -// SSP_ConfigStructInit(&HW_SPI_init); // set values for SPI mode -// HW_SPI_init.ClockRate = _currentSetting->clock; -// HW_SPI_init.Databit = _currentSetting->dataSize; - -// /** -// * SPI Mode CPOL CPHA Shift SCK-edge Capture SCK-edge -// * 0 0 0 Falling Rising -// * 1 0 1 Rising Falling -// * 2 1 0 Rising Falling -// * 3 1 1 Falling Rising -// */ -// switch (_currentSetting->dataMode) { -// case SPI_MODE0: -// HW_SPI_init.CPHA = SSP_CPHA_FIRST; -// HW_SPI_init.CPOL = SSP_CPOL_HI; -// break; -// case SPI_MODE1: -// HW_SPI_init.CPHA = SSP_CPHA_SECOND; -// HW_SPI_init.CPOL = SSP_CPOL_HI; -// break; -// case SPI_MODE2: -// HW_SPI_init.CPHA = SSP_CPHA_FIRST; -// HW_SPI_init.CPOL = SSP_CPOL_LO; -// break; -// case SPI_MODE3: -// HW_SPI_init.CPHA = SSP_CPHA_SECOND; -// HW_SPI_init.CPOL = SSP_CPOL_LO; -// break; -// default: -// break; -// } - -// // TODO: handle bitOrder -// SSP_Init(_currentSetting->spi_d, &HW_SPI_init); // puts the values into the proper bits in the SSP0 registers -// } - -// #if SD_MISO_PIN == BOARD_SPI1_MISO_PIN -// SPIClass SPI(1); -// #elif SD_MISO_PIN == BOARD_SPI2_MISO_PIN -// SPIClass SPI(2); -// #endif +#if SD_MISO_PIN == BOARD_SPI1_MISO_PIN + SPIClass SPI(1); +#elif SD_MISO_PIN == BOARD_SPI2_MISO_PIN + SPIClass SPI(2); +#endif #endif // TARGET_LPC4078 diff --git a/Marlin/src/HAL/LPC4078/include/SPI.h b/Marlin/src/HAL/LPC4078/include/SPI.h index 02bfdf8398..a1b2f4623f 100644 --- a/Marlin/src/HAL/LPC4078/include/SPI.h +++ b/Marlin/src/HAL/LPC4078/include/SPI.h @@ -24,8 +24,7 @@ #include "../../shared/HAL_SPI.h" #include -// #include -// #include +#include //#define MSBFIRST 1 @@ -63,17 +62,25 @@ #define SPI_CLOCK_MAX SPI_CLOCK_DIV2 -#define BOARD_NR_SPI 2 +#define BOARD_NR_SPI 3 -//#define BOARD_SPI1_NSS_PIN PA4 ?! -#define BOARD_SPI1_SCK_PIN P0_15 -#define BOARD_SPI1_MISO_PIN P0_17 -#define BOARD_SPI1_MOSI_PIN P0_18 +// SSP0 TMC port +#define BOARD_SPI1_NSS_PIN P_NC +#define BOARD_SPI1_SCK_PIN P1_20 +#define BOARD_SPI1_MISO_PIN P1_23 +#define BOARD_SPI1_MOSI_PIN P1_24 -//#define BOARD_SPI2_NSS_PIN PB12 ?! -#define BOARD_SPI2_SCK_PIN P0_07 -#define BOARD_SPI2_MISO_PIN P0_08 -#define BOARD_SPI2_MOSI_PIN P0_09 +// SSP2 LCD SD port +#define BOARD_SPI2_NSS_PIN P_NC +#define BOARD_SPI2_SCK_PIN P1_00 +#define BOARD_SPI2_MISO_PIN P1_04 +#define BOARD_SPI2_MOSI_PIN P1_01 + +// SSP1 Onboard SD port +#define BOARD_SPI3_NSS_PIN P_NC +#define BOARD_SPI3_SCK_PIN P0_07 +#define BOARD_SPI3_MISO_PIN P0_08 +#define BOARD_SPI3_MOSI_PIN P0_09 class SPISettings { public: @@ -115,13 +122,16 @@ private: dataSize = inDataSize; } + MCUI::SSP::Config m_config; + //uint32_t spi_speed; uint32_t clock; uint32_t dataSize; //uint32_t clockDivider; uint8_t bitOrder; uint8_t dataMode; - //LPC_SSP_TypeDef *spi_d; + + uint8_t device_id; friend class SPIClass; }; diff --git a/Marlin/src/pins/lpc4078/pins_EBAB.h b/Marlin/src/pins/lpc4078/pins_EBAB.h index 6e2e1ccb04..c0bc2e19ac 100644 --- a/Marlin/src/pins/lpc4078/pins_EBAB.h +++ b/Marlin/src/pins/lpc4078/pins_EBAB.h @@ -255,14 +255,14 @@ * Default pins for TMC software SPI */ #if ENABLED(TMC_USE_SW_SPI) - #ifndef TMC_SW_MOSI - #define TMC_SW_MOSI P1_24 + #ifndef TMC_SPI_MOSI + #define TMC_SPI_MOSI P1_24 #endif - #ifndef TMC_SW_MISO - #define TMC_SW_MISO P1_23 + #ifndef TMC_SPI_MISO + #define TMC_SPI_MISO P1_23 #endif - #ifndef TMC_SW_SCK - #define TMC_SW_SCK P1_20 + #ifndef TMC_SPI_SCK + #define TMC_SPI_SCK P1_20 #endif #endif diff --git a/Marlin/src/pins/native/pins_RAMPS_NATIVE.h b/Marlin/src/pins/native/pins_RAMPS_NATIVE.h index f08dc3c3ed..d1da0336bc 100644 --- a/Marlin/src/pins/native/pins_RAMPS_NATIVE.h +++ b/Marlin/src/pins/native/pins_RAMPS_NATIVE.h @@ -22,11 +22,31 @@ #pragma once /** - * Native with a RAMPS like board with additional pins + * Arduino Mega with RAMPS v1.4 (or v1.3) pin assignments + * + * Applies to the following boards: + * + * RAMPS_14_EFB (Hotend, Fan, Bed) + * RAMPS_14_EEB (Hotend0, Hotend1, Bed) + * RAMPS_14_EFF (Hotend, Fan0, Fan1) + * RAMPS_14_EEF (Hotend0, Hotend1, Fan) + * RAMPS_14_SF (Spindle, Controller Fan) + * + * RAMPS_13_EFB (Hotend, Fan, Bed) + * RAMPS_13_EEB (Hotend0, Hotend1, Bed) + * RAMPS_13_EFF (Hotend, Fan0, Fan1) + * RAMPS_13_EEF (Hotend0, Hotend1, Fan) + * RAMPS_13_SF (Spindle, Controller Fan) + * + * Other pins_MYBOARD.h files may override these defaults + * + * Differences between + * RAMPS_13 | RAMPS_14 + * 7 | 11 */ #ifndef BOARD_INFO_NAME - #define BOARD_INFO_NAME "RAMPS Native" + #define BOARD_INFO_NAME "RAMPS 1.4" #endif #ifndef DEFAULT_MACHINE_NAME @@ -40,24 +60,28 @@ // // Servos // -#define SERVO0_PIN 151 -#define SERVO1_PIN 152 -#define SERVO2_PIN 153 +#ifdef IS_RAMPS_13 + #define SERVO0_PIN 7 // RAMPS_13 // Will conflict with BTN_EN2 on LCD_I2C_VIKI +#else + #define SERVO0_PIN 11 +#endif +#define SERVO1_PIN 6 +#define SERVO2_PIN 5 #ifndef SERVO3_PIN - #define SERVO3_PIN 154 + #define SERVO3_PIN 4 #endif // // Limit Switches // -#define X_MIN_PIN 155 +#define X_MIN_PIN 3 #ifndef X_MAX_PIN - #define X_MAX_PIN 156 + #define X_MAX_PIN 2 #endif -#define Y_MIN_PIN 157 -#define Y_MAX_PIN 158 -#define Z_MIN_PIN 159 -#define Z_MAX_PIN 160 +#define Y_MIN_PIN 14 +#define Y_MAX_PIN 15 +#define Z_MIN_PIN 18 +#define Z_MAX_PIN 19 // // Z Probe (when not Z_MIN_PIN) @@ -104,60 +128,24 @@ #define E1_CS_PIN 44 #endif -#define E2_STEP_PIN 100 -#define E2_DIR_PIN 101 -#define E2_ENABLE_PIN 102 -#ifndef E2_CS_PIN - #define E2_CS_PIN 103 -#endif +#define Z4_STEP_PIN 13 +#define Z4_DIR_PIN 71 +#define Z4_ENABLE_PIN 12 -#define E3_STEP_PIN 104 -#define E3_DIR_PIN 105 -#define E3_ENABLE_PIN 106 -#ifndef E3_CS_PIN - #define E3_CS_PIN 107 -#endif +#define Z2_STEP_PIN 4 +#define Z2_DIR_PIN 5 +#define Z2_ENABLE_PIN 6 -#define E4_STEP_PIN 108 -#define E4_DIR_PIN 109 -#define E4_ENABLE_PIN 110 -#ifndef E4_CS_PIN - #define E4_CS_PIN 111 -#endif - -#define E5_STEP_PIN 112 -#define E5_DIR_PIN 113 -#define E5_ENABLE_PIN 114 -#ifndef E5_CS_PIN - #define E5_CS_PIN 115 -#endif - -#define E6_STEP_PIN 116 -#define E6_DIR_PIN 117 -#define E6_ENABLE_PIN 118 -#ifndef E6_CS_PIN - #define E6_CS_PIN 119 -#endif - -#define E7_STEP_PIN 120 -#define E7_DIR_PIN 121 -#define E7_ENABLE_PIN 122 -#ifndef E7_CS_PIN - #define E7_CS_PIN 123 -#endif +#define Z3_STEP_PIN 12 +#define Z3_DIR_PIN 40 +#define Z3_ENABLE_PIN 44 // // Temperature Sensors // #define TEMP_0_PIN 0 // Analog Input #define TEMP_1_PIN 1 // Analog Input -#define TEMP_2_PIN 2 // Analog Input -#define TEMP_3_PIN 3 // Analog Input -#define TEMP_4_PIN 4 // Analog Input -#define TEMP_5_PIN 5 // Analog Input -#define TEMP_6_PIN 6 // Analog Input -#define TEMP_7_PIN 7 // Analog Input -#define TEMP_BED_PIN 8 // Analog Input +#define TEMP_BED_PIN 2 // Analog Input // SPI for MAX Thermocouple #if !HAS_MEDIA @@ -169,33 +157,55 @@ // // Heaters / Fans // -#define HEATER_0_PIN 10 -#define HEATER_1_PIN 9 -#define HEATER_2_PIN 8 -#define HEATER_3_PIN 125 -#define HEATER_4_PIN 126 -#define HEATER_5_PIN 127 -#define HEATER_6_PIN 128 -#define HEATER_7_PIN 129 -#define HEATER_BED_PIN 108 +#ifndef MOSFET_A_PIN + #define MOSFET_A_PIN 10 +#endif +#ifndef MOSFET_B_PIN + #define MOSFET_B_PIN 9 +#endif +#ifndef MOSFET_C_PIN + #define MOSFET_C_PIN 8 +#endif +#ifndef MOSFET_D_PIN + #define MOSFET_D_PIN -1 +#endif + +#define HEATER_0_PIN MOSFET_A_PIN + +#if FET_ORDER_EFB // Hotend, Fan, Bed + #define FAN0_PIN MOSFET_B_PIN + #define HEATER_BED_PIN MOSFET_C_PIN +#elif FET_ORDER_EEF // Hotend, Hotend, Fan + #define HEATER_1_PIN MOSFET_B_PIN + #define FAN0_PIN MOSFET_C_PIN +#elif FET_ORDER_EEB // Hotend, Hotend, Bed + #define HEATER_1_PIN MOSFET_B_PIN + #define HEATER_BED_PIN MOSFET_C_PIN +#elif FET_ORDER_EFF // Hotend, Fan, Fan + #define FAN0_PIN MOSFET_B_PIN + #define FAN1_PIN MOSFET_C_PIN +#elif FET_ORDER_SF // Spindle, Fan + #define FAN0_PIN MOSFET_C_PIN +#else // Non-specific are "EFB" (i.e., "EFBF" or "EFBE") + #define FAN0_PIN MOSFET_B_PIN + #define HEATER_BED_PIN MOSFET_C_PIN + #if HOTENDS == 1 && DISABLED(HEATERS_PARALLEL) + #define FAN1_PIN MOSFET_D_PIN + #else + #define HEATER_1_PIN MOSFET_D_PIN + #endif +#endif #ifndef FAN0_PIN - #define FAN0_PIN 161 // IO pin. Buffer needed + #define FAN0_PIN 4 // IO pin. Buffer needed #endif -#define FAN1_PIN 162 // IO pin. Buffer needed -#define FAN2_PIN 163 // IO pin. Buffer needed -#define FAN3_PIN 164 // IO pin. Buffer needed -#define FAN4_PIN 165 // IO pin. Buffer needed -#define FAN5_PIN 166 // IO pin. Buffer needed -#define FAN6_PIN 167 // IO pin. Buffer needed -#define FAN7_PIN 168 // IO pin. Buffer needed // // Misc. Functions // #define SDSS 53 #define LED_PIN 13 -#define BOARD_NEOPIXEL_PIN 71 +#define NEOPIXEL_PIN 71 #ifndef FILWIDTH_PIN #define FILWIDTH_PIN 5 // Analog Input on AUX2 @@ -373,37 +383,9 @@ #endif #endif -/** Faux Expansion Headers - * ------ ------ - * (BEEP) 37 | 1 2 | 35 (ENC) (MISO) 50 | 1 2 | 52 (SCK) - * (LCD_EN) 17 | 3 4 | 16 (LCD_RS) (EN1) 31 | 3 4 | 53 (SDSS) - * (LCD_D4) 23 5 6 | 25 (LCD_D5) (EN2) 33 5 6 | 51 (MOSI) - * (LCD_D6) 27 | 7 8 | 29 (LCD_D7) (SD_DET) 49 | 7 8 | 41 (KILL) - * -- | 9 10 | -- -- | 9 10 | -- - * ------ ------ - * EXP1 EXP2 - */ -#define EXP1_01_PIN 37 // BEEPER -#define EXP1_02_PIN 35 // ENC -#define EXP1_03_PIN 17 // LCD_EN -#define EXP1_04_PIN 16 // LCD_RS -#define EXP1_05_PIN 23 // LCD_D4 -#define EXP1_06_PIN 25 // LCD_D5 -#define EXP1_07_PIN 27 // LCD_D6 -#define EXP1_08_PIN 29 // LCD_D7 - -#define EXP2_01_PIN 50 // MISO -#define EXP2_02_PIN 52 // SCK -#define EXP2_03_PIN 31 // EN1 -#define EXP2_04_PIN 53 // SDSS -#define EXP2_05_PIN 33 // EN2 -#define EXP2_06_PIN 51 // MOSI -#define EXP2_07_PIN 49 // SD_DET -#define EXP2_08_PIN 41 // KILL - -// -// LCD / Controller -// +////////////////////////// +// LCDs and Controllers // +////////////////////////// #if ANY(TFT_COLOR_UI, TFT_CLASSIC_UI, TFT_LVGL_UI) @@ -415,11 +397,10 @@ #define TFT_MOSI_PIN SD_MOSI_PIN #define LCD_USE_DMA_SPI - #define BEEPER_PIN 42 - - #define BTN_ENC 59 #define BTN_EN1 40 #define BTN_EN2 63 + #define BTN_ENC 59 + #define BEEPER_PIN 42 #define TOUCH_CS_PIN 33 @@ -504,9 +485,9 @@ // #if ENABLED(REPRAPWORLD_GRAPHICAL_LCD) - #define LCD_PINS_RS EXP2_07_PIN // CS chip select /SS chip slave select - #define LCD_PINS_EN EXP2_06_PIN // SID (MOSI) - #define LCD_PINS_D4 EXP2_02_PIN // SCK (CLK) clock + #define LCD_PINS_RS 49 // CS chip select /SS chip slave select + #define LCD_PINS_EN 51 // SID (MOSI) + #define LCD_PINS_D4 52 // SCK (CLK) clock #elif ALL(IS_NEWPANEL, PANEL_ONE) @@ -521,12 +502,12 @@ #if ENABLED(CR10_STOCKDISPLAY) - #define LCD_PINS_RS EXP1_07_PIN - #define LCD_PINS_EN EXP1_08_PIN - #define LCD_PINS_D4 EXP1_06_PIN + #define LCD_PINS_RS 27 + #define LCD_PINS_EN 29 + #define LCD_PINS_D4 25 #if !IS_NEWPANEL - #define BEEPER_PIN EXP1_01_PIN + #define BEEPER_PIN 37 #endif #elif ENABLED(ZONESTAR_LCD) @@ -541,28 +522,38 @@ #else #if ANY(MKS_12864OLED, MKS_12864OLED_SSD1306) - #define LCD_PINS_DC EXP1_06_PIN // Set as output on init - #define LCD_PINS_RS EXP1_07_PIN // Pull low for 1s to init + #define LCD_PINS_DC 25 // Set as output on init + #define LCD_PINS_RS 27 // Pull low for 1s to init // DOGM SPI LCD Support - #define DOGLCD_CS EXP1_04_PIN - #define DOGLCD_MOSI EXP1_03_PIN - #define DOGLCD_SCK EXP1_05_PIN + #define DOGLCD_CS 16 + #define DOGLCD_MOSI 17 + #define DOGLCD_SCK 23 #define DOGLCD_A0 LCD_PINS_DC #else - #define LCD_PINS_RS EXP1_04_PIN - #define LCD_PINS_EN EXP1_03_PIN - #define LCD_PINS_D4 EXP1_05_PIN - #define LCD_PINS_D5 EXP1_06_PIN - #define LCD_PINS_D6 EXP1_07_PIN + #define LCD_PINS_RS 16 + #define LCD_PINS_EN 17 + #define LCD_PINS_D4 23 + #define LCD_PINS_D5 25 + #define LCD_PINS_D6 27 #endif - #define LCD_PINS_D7 EXP1_08_PIN + #define LCD_PINS_D7 29 #if !IS_NEWPANEL - #define BEEPER_PIN EXP2_05_PIN + #define BEEPER_PIN 33 #endif #endif + + #if !IS_NEWPANEL + // Buttons attached to a shift register + // Not wired yet + //#define SHIFT_CLK_PIN 38 + //#define SHIFT_LD_PIN 42 + //#define SHIFT_OUT_PIN 40 + //#define SHIFT_EN_PIN 17 + #endif + #endif // @@ -572,19 +563,19 @@ #if ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER) - #define BEEPER_PIN EXP1_01_PIN + #define BEEPER_PIN 37 #if ENABLED(CR10_STOCKDISPLAY) - #define BTN_EN1 EXP1_03_PIN - #define BTN_EN2 EXP1_05_PIN + #define BTN_EN1 17 + #define BTN_EN2 23 #else - #define BTN_EN1 EXP2_03_PIN - #define BTN_EN2 EXP2_05_PIN + #define BTN_EN1 31 + #define BTN_EN2 33 #endif - #define BTN_ENC EXP1_02_PIN - #define SD_DETECT_PIN EXP2_07_PIN - #define KILL_PIN EXP2_08_PIN + #define BTN_ENC 35 + #define SD_DETECT_PIN 49 + #define KILL_PIN 41 #if ENABLED(BQ_LCD_SMART_CONTROLLER) #define LCD_BACKLIGHT_PIN 39 @@ -634,34 +625,34 @@ #elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER) - #define DOGLCD_CS EXP1_08_PIN - #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_CS 29 + #define DOGLCD_A0 27 - #define BEEPER_PIN EXP1_05_PIN - #define LCD_BACKLIGHT_PIN EXP2_05_PIN + #define BEEPER_PIN 23 + #define LCD_BACKLIGHT_PIN 33 - #define BTN_EN1 EXP1_02_PIN - #define BTN_EN2 EXP1_01_PIN - #define BTN_ENC EXP2_03_PIN + #define BTN_EN1 35 + #define BTN_EN2 37 + #define BTN_ENC 31 #define LCD_SDSS SDSS - #define SD_DETECT_PIN EXP2_07_PIN - #define KILL_PIN EXP2_08_PIN + #define SD_DETECT_PIN 49 + #define KILL_PIN 41 #elif ENABLED(MKS_MINI_12864) - #define DOGLCD_A0 EXP1_07_PIN - #define DOGLCD_CS EXP1_06_PIN + #define DOGLCD_A0 27 + #define DOGLCD_CS 25 - #define BEEPER_PIN EXP1_01_PIN + #define BEEPER_PIN 37 // not connected to a pin #define LCD_BACKLIGHT_PIN 65 // backlight LED on A11/D65 - #define BTN_EN1 EXP2_03_PIN - #define BTN_EN2 EXP2_05_PIN - #define BTN_ENC EXP1_02_PIN + #define BTN_EN1 31 + #define BTN_EN2 33 + #define BTN_ENC 35 - #define SD_DETECT_PIN EXP2_07_PIN + #define SD_DETECT_PIN 49 #define KILL_PIN 64 //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 @@ -694,6 +685,7 @@ #else + // Beeper on AUX-4 #define BEEPER_PIN 33 // Buttons are directly attached to AUX-2 @@ -709,15 +701,15 @@ #define BTN_EN2 63 // AUX2 PIN 4 #define BTN_ENC 49 // AUX3 PIN 7 #else - #define BTN_EN1 EXP1_01_PIN - #define BTN_EN2 EXP1_02_PIN - #define BTN_ENC EXP2_03_PIN - #define SD_DETECT_PIN EXP2_08_PIN + #define BTN_EN1 37 + #define BTN_EN2 35 + #define BTN_ENC 31 + #define SD_DETECT_PIN 41 #endif #if ENABLED(G3D_PANEL) - #define SD_DETECT_PIN EXP2_07_PIN - #define KILL_PIN EXP2_08_PIN + #define SD_DETECT_PIN 49 + #define KILL_PIN 41 #endif #endif @@ -727,7 +719,3 @@ #endif // IS_NEWPANEL #endif // HAS_WIRED_LCD - -#ifndef KILL_PIN - #define KILL_PIN EXP2_08_PIN -#endif