From ec6f9dd5c8443f9633ae5ea9bce7e5f090d5c72b Mon Sep 17 00:00:00 2001 From: fredycpu Date: Sun, 3 Mar 2024 19:39:50 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20MKS=5FROBIN=5FPRO=20:=20I2C=20EE?= =?UTF-8?q?PROM=20+=20MKS=20Wifi=20(#26823)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Scott Lahteine --- Marlin/src/inc/Changes.h | 2 ++ Marlin/src/lcd/extui/mks_ui/mks_hardware.cpp | 12 ++++++++--- Marlin/src/lcd/extui/mks_ui/wifi_module.cpp | 4 +++- Marlin/src/lcd/extui/mks_ui/wifi_upload.cpp | 14 +++++++------ Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h | 4 ++++ .../src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h | 4 ++++ Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h | 19 ++++++++++++++++++ .../src/pins/stm32f4/pins_MKS_MONSTER8_V2.h | 2 +- .../pins/stm32f4/pins_MKS_MONSTER8_common.h | 3 --- .../stm32f4/pins_MKS_ROBIN_NANO_V3_common.h | 20 ++++++++++--------- 10 files changed, 61 insertions(+), 23 deletions(-) diff --git a/Marlin/src/inc/Changes.h b/Marlin/src/inc/Changes.h index dd8acc1ce5..1019638931 100644 --- a/Marlin/src/inc/Changes.h +++ b/Marlin/src/inc/Changes.h @@ -691,6 +691,8 @@ #error "ANET_FULL_GRAPHICS_LCD_ALT_WIRING is now CTC_A10S_A13." #elif defined(Z_PROBE_END_SCRIPT) #error "Z_PROBE_END_SCRIPT is now EVENT_GCODE_AFTER_G29." +#elif defined(WIFI_SERIAL) + #error "WIFI_SERIAL is now WIFI_SERIAL_PORT." #endif // Changes to Probe Temp Compensation (#17392) diff --git a/Marlin/src/lcd/extui/mks_ui/mks_hardware.cpp b/Marlin/src/lcd/extui/mks_ui/mks_hardware.cpp index eb9cac641a..f06ffcd89d 100644 --- a/Marlin/src/lcd/extui/mks_ui/mks_hardware.cpp +++ b/Marlin/src/lcd/extui/mks_ui/mks_hardware.cpp @@ -99,7 +99,9 @@ #define ESTATE(S) (READ(S##_PIN) == S##_ENDSTOP_HIT_STATE) void test_gpio_readlevel_L() { - WRITE(WIFI_IO0_PIN, HIGH); + #if PIN_EXISTS(WIFI_IO0) + WRITE(WIFI_IO0_PIN, HIGH); + #endif delay(10); pw_det_sta = (READ(MKS_TEST_POWER_LOSS_PIN) == LOW); pw_off_sta = (READ(MKS_TEST_PS_ON_PIN) == LOW); @@ -132,7 +134,9 @@ } void test_gpio_readlevel_H() { - WRITE(WIFI_IO0_PIN, LOW); + #if PIN_EXISTS(WIFI_IO0) + WRITE(WIFI_IO0_PIN, LOW); + #endif delay(10); pw_det_sta = (READ(MKS_TEST_POWER_LOSS_PIN) == HIGH); pw_off_sta = (READ(MKS_TEST_PS_ON_PIN) == HIGH); @@ -169,7 +173,9 @@ void init_test_gpio() { endstops.init(); - SET_OUTPUT(WIFI_IO0_PIN); + #if PIN_EXISTS(WIFI_IO0) + SET_OUTPUT(WIFI_IO0_PIN); + #endif #if PIN_EXISTS(MT_DET_1) SET_INPUT_PULLUP(MT_DET_1_PIN); diff --git a/Marlin/src/lcd/extui/mks_ui/wifi_module.cpp b/Marlin/src/lcd/extui/mks_ui/wifi_module.cpp index 122712e9e1..46ba860239 100644 --- a/Marlin/src/lcd/extui/mks_ui/wifi_module.cpp +++ b/Marlin/src/lcd/extui/mks_ui/wifi_module.cpp @@ -1920,7 +1920,9 @@ void mks_esp_wifi_init() { SET_OUTPUT(WIFI_RESET_PIN); WIFI_SET(); SET_OUTPUT(WIFI_IO1_PIN); - SET_INPUT_PULLUP(WIFI_IO0_PIN); + #if PIN_EXISTS(WIFI_IO0) + SET_INPUT_PULLUP(WIFI_IO0_PIN); + #endif WIFI_IO1_SET(); esp_state = TRANSFER_IDLE; diff --git a/Marlin/src/lcd/extui/mks_ui/wifi_upload.cpp b/Marlin/src/lcd/extui/mks_ui/wifi_upload.cpp index 2d4d19e7a2..3ce8bb42ec 100644 --- a/Marlin/src/lcd/extui/mks_ui/wifi_upload.cpp +++ b/Marlin/src/lcd/extui/mks_ui/wifi_upload.cpp @@ -650,12 +650,14 @@ void resetWiFiForUpload(int begin_or_end) { //#if 0 uint32_t start = getWifiTick(); - if (begin_or_end == 0) { - SET_OUTPUT(WIFI_IO0_PIN); - WRITE(WIFI_IO0_PIN, LOW); - } - else - SET_INPUT_PULLUP(WIFI_IO0_PIN); + #if PIN_EXISTS(WIFI_IO0) + if (begin_or_end == 0) { + SET_OUTPUT(WIFI_IO0_PIN); + WRITE(WIFI_IO0_PIN, LOW); + } + else + SET_INPUT_PULLUP(WIFI_IO0_PIN); + #endif WIFI_RESET(); while (getWifiTickDiff(start, getWifiTick()) < 500) { /* nada */ } diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h index b8ff3262c8..ae4ee3268e 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h @@ -201,10 +201,14 @@ #define WIFI_IO1_PIN PC7 #define WIFI_RESET_PIN PE9 + // + // MKS Testing for code in lcd/extui/mks_ui + // #if ENABLED(MKS_TEST) #define MKS_TEST_POWER_LOSS_PIN PA2 // PW_DET #define MKS_TEST_PS_ON_PIN PB0 // PW_OFF #endif + #else //#define POWER_LOSS_PIN PA2 // PW_DET //#define PS_ON_PIN PB2 // PW_OFF diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h index 0738afd80e..ea82c13fba 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h @@ -228,10 +228,14 @@ #define WIFI_IO1_PIN PC7 #define WIFI_RESET_PIN PE9 + // + // MKS Testing for code in lcd/extui/mks_ui + // #if ENABLED(MKS_TEST) #define MKS_TEST_POWER_LOSS_PIN PA2 // PW_DET #define MKS_TEST_PS_ON_PIN PB2 // PW_OFF #endif + #else //#define POWER_LOSS_PIN PA2 // PW_DET //#define PS_ON_PIN PB2 // PW_OFF diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h index 545b73cf02..d5689c1e71 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h @@ -41,6 +41,15 @@ // #define DISABLE_DEBUG +// +// Onboard I2C EEPROM +// +#define IIC_BL24CXX_EEPROM // Use I2C EEPROM onboard IC (AT24C04C, Size 4K, PageSize 16B) +#define MARLIN_EEPROM_SIZE 0x1000 // 4K +#define IIC_EEPROM_SDA PB7 +#define IIC_EEPROM_SCL PB6 +#define EEPROM_DEVICE_ADDRESS 0xA0 + // // SPI // @@ -403,3 +412,13 @@ #define SPI_FLASH_MISO_PIN PB14 #define SPI_FLASH_MOSI_PIN PB15 #endif + +// +// MKS WIFI pins +// +#if ENABLED(MKS_WIFI_MODULE) + #define WIFI_RESET_PIN PA5 + #define WIFI_SERIAL_PORT 1 // USART1 + #define WIFI_IO1_PIN PC7 + #define WIFI_IO0_PIN -1 // N.C. +#endif diff --git a/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_V2.h b/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_V2.h index c5c79311e3..12d3947b99 100644 --- a/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_V2.h +++ b/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_V2.h @@ -51,7 +51,7 @@ // // MKS WIFI MODULE // -//#define WIFI_SERIAL 1// USART1 +//#define WIFI_SERIAL_PORT 1 // USART1 #if ENABLED(MKS_WIFI_MODULE) #define WIFI_IO0_PIN PB14 // MKS ESP WIFI IO0 PIN #define WIFI_IO1_PIN PB15 // MKS ESP WIFI IO1 PIN diff --git a/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_common.h b/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_common.h index 4965029927..e96a679360 100644 --- a/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_common.h +++ b/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_common.h @@ -217,9 +217,6 @@ #define KILL_PIN_STATE HIGH #endif -// Random Info -#define USB_SERIAL -1 // USB Serial - /** * ------ ------ * (BEEPER) PB2 | 1 2 | PE10 (BTN_ENC) (SPI1 MISO) PA6 | 1 2 | PA5 (SPI1 SCK) diff --git a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3_common.h b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3_common.h index 0b36730467..050c8f2424 100644 --- a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3_common.h +++ b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3_common.h @@ -195,25 +195,27 @@ #define KILL_PIN_STATE HIGH #endif -// Random Info -#define USB_SERIAL -1 // USB Serial -#define WIFI_SERIAL 3 // USART3 -#define MKS_WIFI_MODULE_SERIAL 1 // USART1 -#define MKS_WIFI_MODULE_SPI 2 // SPI2 - #ifndef SDCARD_CONNECTION #define SDCARD_CONNECTION ONBOARD #endif -// MKS WIFI MODULE +// +// MKS WiFi Module +// #if ENABLED(MKS_WIFI_MODULE) #define WIFI_IO0_PIN PC13 #define WIFI_IO1_PIN PC7 #define WIFI_RESET_PIN PE9 + #define MKS_WIFI_MODULE_SERIAL 1 // USART1 + #define MKS_WIFI_MODULE_SPI 2 // SPI2 +#else + #define WIFI_SERIAL_PORT 3 // USART3 #endif -// MKS TEST -#if ENABLED(MKS_TEST) +// +// MKS Testing for code in lcd/extui/mks_ui +// +#if ALL(TFT_LVGL_UI, MKS_TEST) #define MKS_TEST_POWER_LOSS_PIN PA13 // PW_DET #define MKS_TEST_PS_ON_PIN PB2 // PW_OFF #endif