From 3009707723d490c7dcc71093f5c461c782c16b18 Mon Sep 17 00:00:00 2001 From: TheCodeExorcist <63008968+TheCodeExorcist@users.noreply.github.com> Date: Thu, 7 Jan 2021 04:13:15 +0100 Subject: [PATCH] Improved MKS Robin support (#19333) --- Marlin/src/pins/stm32f1/pins_MKS_ROBIN.h | 120 +++++++++++++++++------ 1 file changed, 90 insertions(+), 30 deletions(-) diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN.h index ae9419ab7..99e0f0be2 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN.h @@ -42,15 +42,20 @@ #define DISABLE_JTAG // -// Enable SD EEPROM to prevent infinite boot loop +// EEPROM // -#ifdef ARDUINO_ARCH_STM32 - #define FLASH_EEPROM_EMULATION +#if NO_EEPROM_SELECTED + #ifdef ARDUINO_ARCH_STM32 + #define FLASH_EEPROM_EMULATION + #else + #define SDCARD_EEPROM_EMULATION + #endif +#endif + +#if ENABLED(FLASH_EEPROM_EMULATION) #define EEPROM_PAGE_SIZE (0x800U) // 2KB #define EEPROM_START_ADDRESS (0x8000000UL + (STM32_FLASH_SIZE) * 1024UL - (EEPROM_PAGE_SIZE) * 2UL) #define MARLIN_EEPROM_SIZE (EEPROM_PAGE_SIZE) -#else - #define SDCARD_EEPROM_EMULATION #endif // @@ -102,27 +107,56 @@ #define TEMP_BED_PIN PC0 // TB1 // -// Heaters / Fans +// Heaters // #define HEATER_0_PIN PC7 // HEATER1 #define HEATER_1_PIN PA6 // HEATER2 #define HEATER_BED_PIN PC6 // HOT BED +// +// Fan +// #define FAN_PIN PA7 // FAN -/** - * Note: MKS Robin board is using SPI2 interface. Make sure your stm32duino library is configured accordingly - */ +// +// Thermocouples +// //#define MAX6675_SS_PIN PE5 // TC1 - CS1 //#define MAX6675_SS_PIN PE6 // TC2 - CS2 -#define POWER_LOSS_PIN PA2 // PW_DET -#define PS_ON_PIN PA3 // PW_OFF +// +// Filament runout sensor +// #define FIL_RUNOUT_PIN PF11 // MT_DET +// +// Power loss detection +// +#define POWER_LOSS_PIN PA2 // PW_DET + +// +// Power supply control +// +#define PS_ON_PIN PA3 // PW_OFF + +// +// Piezzoelectric speaker +// #define BEEPER_PIN PC13 + +// +// Activity LED +// #define LED_PIN PB2 +// +// ESP12-S Wi-Fi module +// +#define WIFI_IO0_PIN PG1 + +// +// LCD screen +// #if HAS_FSMC_TFT /** * Note: MKS Robin TFT screens use various TFT controllers @@ -151,6 +185,7 @@ #define TOUCH_BUTTONS_HW_SPI #define TOUCH_BUTTONS_HW_SPI_DEVICE 2 + #define TFT_BUFFER_SIZE 14400 #endif #if NEED_TOUCH_PINS @@ -161,6 +196,7 @@ #define TOUCH_INT_PIN -1 #endif +// SPI2 is shared by LCD touch driver and flash // SPI1(PA7) & SPI3(PB5) not available #define SPI_DEVICE 2 @@ -193,31 +229,55 @@ #define SD_DETECT_PIN -1 #endif +// +// Trinamic TMC2208/2209 UART +// #if HAS_TMC_UART /** - * TMC2208/TMC2209 stepper drivers + * This board does not have dedicated TMC UART pins. Custom wiring is needed. + * You may uncomment one of the options below, or add it to your Configuration.h. * - * Hardware serial communication ports. - * If undefined software serial is used according to the pins below + * When using up to four TMC2209 drivers, hardware serial is recommented on + * MSerial0 or MSerial1. + * + * When using TMC2208 or more than four drivers, SoftwareSerial will be needed, + * to provide dedicated pins for each drier. */ - //#define X_HARDWARE_SERIAL MSerial1 - //#define Y_HARDWARE_SERIAL MSerial1 - //#define Z_HARDWARE_SERIAL MSerial1 - //#define E0_HARDWARE_SERIAL MSerial1 - //#define E1_HARDWARE_SERIAL MSerial1 - // Unused servo pins may be repurposed with SoftwareSerialM - //#define X_SERIAL_TX_PIN PF8 // SERVO3_PIN -- XS2 - 6 - //#define Y_SERIAL_TX_PIN PF9 // SERVO2_PIN -- XS2 - 5 - //#define Z_SERIAL_TX_PIN PA1 // SERVO1_PIN -- XS1 - 6 - //#define E0_SERIAL_TX_PIN PC3 // SERVO0_PIN -- XS1 - 5 - //#define X_SERIAL_RX_PIN X_SERIAL_TX_PIN - //#define Y_SERIAL_RX_PIN Y_SERIAL_TX_PIN - //#define Z_SERIAL_RX_PIN Z_SERIAL_TX_PIN - //#define E0_SERIAL_RX_PIN E0_SERIAL_TX_PIN + //#define TMC_HARDWARE_SERIAL + #if ENABLED(TMC_HARDWARE_SERIAL) + #define X_HARDWARE_SERIAL MSerial0 + #define X2_HARDWARE_SERIAL MSerial0 + #define Y_HARDWARE_SERIAL MSerial0 + #define Y2_HARDWARE_SERIAL MSerial0 + #define Z_HARDWARE_SERIAL MSerial0 + #define Z2_HARDWARE_SERIAL MSerial0 + #define E0_HARDWARE_SERIAL MSerial0 + #define E1_HARDWARE_SERIAL MSerial0 + #endif - // Reduce baud rate for software serial reliability - #if HAS_TMC_SW_SERIAL + //#define TMC_SOFTWARE_SERIAL + #if ENABLED(TMC_SOFTWARE_SERIAL) + #define X_SERIAL_TX_PIN PF8 // SERVO3_PIN -- XS2 - 6 + #define Y_SERIAL_TX_PIN PF9 // SERVO2_PIN -- XS2 - 5 + #define Z_SERIAL_TX_PIN PA1 // SERVO1_PIN -- XS1 - 6 + #define E0_SERIAL_TX_PIN PC3 // SERVO0_PIN -- XS1 - 5 + #define X_SERIAL_RX_PIN X_SERIAL_TX_PIN + #define Y_SERIAL_RX_PIN Y_SERIAL_TX_PIN + #define Z_SERIAL_RX_PIN Z_SERIAL_TX_PIN + #define E0_SERIAL_RX_PIN E0_SERIAL_TX_PIN #define TMC_BAUD_RATE 19200 #endif #endif + +// +// W25Q64 64Mb (8MB) SPI flash +// +#define HAS_SPI_FLASH 1 +#if HAS_SPI_FLASH + #define SPI_FLASH_SIZE 0x800000 // 8MB + #define W25QXX_CS_PIN PG9 + #define W25QXX_MOSI_PIN PB15 + #define W25QXX_MISO_PIN PB14 + #define W25QXX_SCK_PIN PB13 +#endif