From f5d809f3667846e962c86d1d4f4b8ac97e8a3e5f Mon Sep 17 00:00:00 2001 From: Bob Kuhn Date: Thu, 16 Apr 2020 03:55:33 -0500 Subject: [PATCH] SKR Pro 1.1 WiFi and LCD SD card support (#17531) --- Marlin/src/HAL/shared/esp_wifi.cpp | 35 +++++++++++++++++ Marlin/src/HAL/shared/esp_wifi.h | 24 ++++++++++++ Marlin/src/MarlinCore.cpp | 3 ++ Marlin/src/pins/pinsDebug_list.h | 6 +++ .../src/pins/stm32f4/pins_BLACK_STM32F407VE.h | 6 ++- .../src/pins/stm32f4/pins_BTT_SKR_PRO_V1_1.h | 39 ++++++++++++++++--- Marlin/src/pins/stm32f4/pins_FLYF407ZG.h | 6 ++- 7 files changed, 111 insertions(+), 8 deletions(-) create mode 100644 Marlin/src/HAL/shared/esp_wifi.cpp create mode 100644 Marlin/src/HAL/shared/esp_wifi.h diff --git a/Marlin/src/HAL/shared/esp_wifi.cpp b/Marlin/src/HAL/shared/esp_wifi.cpp new file mode 100644 index 0000000000..ab073d6f08 --- /dev/null +++ b/Marlin/src/HAL/shared/esp_wifi.cpp @@ -0,0 +1,35 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 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 . + * + */ + +#include "../../inc/MarlinConfig.h" +#include "Delay.h" + +void esp_wifi_init(void) { + #if PIN_EXISTS(ESP_WIFI_MODULE_RESET) + OUT_WRITE(ESP_WIFI_MODULE_RESET_PIN, LOW); + delay(1); + OUT_WRITE(ESP_WIFI_MODULE_RESET_PIN, HIGH); + #endif + #if PIN_EXISTS(ESP_WIFI_MODULE_ENABLE) + OUT_WRITE(ESP_WIFI_MODULE_ENABLE_PIN, HIGH); + #endif +} diff --git a/Marlin/src/HAL/shared/esp_wifi.h b/Marlin/src/HAL/shared/esp_wifi.h new file mode 100644 index 0000000000..e8aa50446b --- /dev/null +++ b/Marlin/src/HAL/shared/esp_wifi.h @@ -0,0 +1,24 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2020 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 + +void esp_wifi_init(); diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index e4fbf31a27..759d3b2132 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -44,6 +44,7 @@ #include "feature/closedloop.h" #include "HAL/shared/Delay.h" +#include "HAL/shared/esp_wifi.h" #include "module/stepper/indirection.h" @@ -962,6 +963,8 @@ void setup() { BOARD_INIT(); #endif + SETUP_RUN(esp_wifi_init()); + // Check startup - does nothing if bootloader sets MCUSR to 0 byte mcu = HAL_get_reset_source(); if (mcu & 1) SERIAL_ECHOLNPGM(STR_POWERUP); diff --git a/Marlin/src/pins/pinsDebug_list.h b/Marlin/src/pins/pinsDebug_list.h index 28478973fb..bb7ececa92 100644 --- a/Marlin/src/pins/pinsDebug_list.h +++ b/Marlin/src/pins/pinsDebug_list.h @@ -1409,3 +1409,9 @@ #if PIN_EXISTS(CLOSED_LOOP_MOVE_COMPLETE) REPORT_NAME_DIGITAL(__LINE__, CLOSED_LOOP_MOVE_COMPLETE_PIN) #endif +#if PIN_EXISTS(ESP_WIFI_MODULE_RESET) + REPORT_NAME_DIGITAL(__LINE__, ESP_WIFI_MODULE_RESET_PIN) +#endif +#if PIN_EXISTS(ESP_WIFI_MODULE_ENABLE) + REPORT_NAME_DIGITAL(__LINE__, ESP_WIFI_MODULE_ENABLE_PIN) +#endif diff --git a/Marlin/src/pins/stm32f4/pins_BLACK_STM32F407VE.h b/Marlin/src/pins/stm32f4/pins_BLACK_STM32F407VE.h index f9b548420d..1a6bd80ae6 100644 --- a/Marlin/src/pins/stm32f4/pins_BLACK_STM32F407VE.h +++ b/Marlin/src/pins/stm32f4/pins_BLACK_STM32F407VE.h @@ -142,7 +142,11 @@ #define SDIO_CK_PIN PC12 #define SDIO_CMD_PIN PD2 -#if !defined(SDCARD_CONNECTION) || SD_CONNECTION_IS(ONBOARD) +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif + +#if SD_CONNECTION_IS(ONBOARD) #define SDIO_SUPPORT // Use SDIO for onboard SD #ifndef SDIO_SUPPORT diff --git a/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_V1_1.h b/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_V1_1.h index 77acbc5b48..84b9796774 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_V1_1.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_SKR_PRO_V1_1.h @@ -31,7 +31,7 @@ // Use one of these or SDCard-based Emulation will be used //#define SRAM_EEPROM_EMULATION // Use BackSRAM-based EEPROM emulation -//#define FLASH_EEPROM_EMULATION // Use Flash-based EEPROM emulation +#define FLASH_EEPROM_EMULATION // Use Flash-based EEPROM emulation // // Servos @@ -215,7 +215,11 @@ #define HEATER_BED_PIN PD12 // Hotbed #define FAN_PIN PC8 // Fan0 #define FAN1_PIN PE5 // Fan1 -#define FAN2_PIN PE6 // Fan2 +#define FAN2_PIN PE6 + +#ifndef E0_AUTO_FAN_PIN + #define E0_AUTO_FAN_PIN PC9 +#endif // // Misc. Functions @@ -227,16 +231,14 @@ // // Onboard SD card -// NOT compatible with LCD +// Must use soft SPI because Marlin's default hardware SPI is tied to LCD's EXP2 // -#if SDCARD_CONNECTION == ONBOARD && !HAS_SPI_LCD +#if SD_CONNECTION_IS(ONBOARD) #define SOFTWARE_SPI // Use soft SPI for onboard SD #define SDSS PA4 #define SCK_PIN PA5 #define MISO_PIN PA6 #define MOSI_PIN PB5 -#else - #define SDSS PB12 #endif /** @@ -256,6 +258,9 @@ #if HAS_SPI_LCD #define BEEPER_PIN PG4 #define BTN_ENC PA8 + #if SD_CONNECTION_IS(LCD) + #define SDSS PB12 // Uses default hardware SPI for LCD's SD + #endif #if ENABLED(CR10_STOCKDISPLAY) #define LCD_PINS_RS PG6 @@ -272,6 +277,10 @@ #undef ST7920_DELAY_2 #undef ST7920_DELAY_3 + #elif ENABLED(MKS_MINI_12864) + #define DOGLCD_A0 PG6 + #define DOGLCD_CS PG3 + #else #define LCD_PINS_RS PD10 @@ -321,3 +330,21 @@ #endif #endif // HAS_SPI_LCD + +// +// WIFI +// + +/** + * _____ + * TX | 1 2 | GND Enable PG1 // Must be high for module to run + * Enable | 3 4 | GPIO2 Reset PG0 // Leave as unused (OK to leave floating) + * Reset | 5 6 | GPIO0 GPIO2 PF15 // Leave as unused (best to leave floating) + * 3.3V| 7 8 | RX GPIO0 PF14 // Leave as unused (best to leave floating) + *  ̄ ̄ + * W1 + */ +#define ESP_WIFI_MODULE_COM 6 // must also set SERIAL_PORT or SERIAL_PORT_2 to this +#define ESP_WIFI_MODULE_BAUDRATE BAUDRATE //115200 // use BAUDRATE ? would guarantee same baud rate as SERIAL_PORT & SERIAL_PORT_2 +#define ESP_WIFI_MODULE_RESET_PIN -1 +#define ESP_WIFI_MODULE_ENABLE_PIN PG1 diff --git a/Marlin/src/pins/stm32f4/pins_FLYF407ZG.h b/Marlin/src/pins/stm32f4/pins_FLYF407ZG.h index ffae5cc0ef..3681fde8d1 100644 --- a/Marlin/src/pins/stm32f4/pins_FLYF407ZG.h +++ b/Marlin/src/pins/stm32f4/pins_FLYF407ZG.h @@ -164,7 +164,11 @@ #define SDIO_CK_PIN PC12 #define SDIO_CMD_PIN PD2 -#if !defined(SDCARD_CONNECTION) || SD_CONNECTION_IS(ONBOARD) +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif + +#if SD_CONNECTION_IS(ONBOARD) #define SDIO_SUPPORT // Use SDIO for onboard SD #ifndef SDIO_SUPPORT