Skip to content

Commit 1acc014

Browse files
committed
🔧 Fix up WiFi options (MarlinFirmware#25586)
1 parent 8e25e38 commit 1acc014

17 files changed

+217
-183
lines changed

Marlin/src/HAL/ESP32/HAL.h

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,12 @@
5050

5151
#define MYSERIAL1 flushableSerial
5252

53-
#if EITHER(WIFISUPPORT, ESP3D_WIFISUPPORT)
54-
#if ENABLED(ESP3D_WIFISUPPORT)
55-
typedef ForwardSerial1Class< decltype(Serial2Socket) > DefaultSerial1;
56-
extern DefaultSerial1 MSerial0;
57-
#define MYSERIAL2 MSerial0
58-
#else
59-
#define MYSERIAL2 webSocketSerial
60-
#endif
53+
#if ENABLED(ESP3D_WIFISUPPORT)
54+
typedef ForwardSerial1Class< decltype(Serial2Socket) > DefaultSerial1;
55+
extern DefaultSerial1 MSerial0;
56+
#define MYSERIAL2 MSerial0
57+
#elif ENABLED(WIFISUPPORT)
58+
#define MYSERIAL2 webSocketSerial
6159
#endif
6260

6361
#define CRITICAL_SECTION_START() portENTER_CRITICAL(&hal.spinlock)

Marlin/src/HAL/shared/esp_wifi.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
*/
2222

2323
#include "../../inc/MarlinConfig.h"
24+
25+
#if ENABLED(WIFISUPPORT)
26+
2427
#include "Delay.h"
2528

2629
void esp_wifi_init(void) { // init ESP01 WIFI module pins
@@ -41,3 +44,5 @@ void esp_wifi_init(void) { // init ESP01 WIFI module pi
4144
OUT_WRITE(ESP_WIFI_MODULE_ENABLE_PIN, HIGH);
4245
#endif
4346
}
47+
48+
#endif // WIFISUPPORT

Marlin/src/MarlinCore.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@
3434
#include "HAL/shared/esp_wifi.h"
3535
#include "HAL/shared/cpu_exception/exception_hook.h"
3636

37+
#if ENABLED(WIFISUPPORT)
38+
#include "HAL/shared/esp_wifi.h"
39+
#endif
40+
3741
#ifdef ARDUINO
3842
#include <pins_arduino.h>
3943
#endif
@@ -1270,7 +1274,9 @@ void setup() {
12701274

12711275
SETUP_RUN(hal.init_board());
12721276

1273-
SETUP_RUN(esp_wifi_init());
1277+
#if ENABLED(WIFISUPPORT)
1278+
SETUP_RUN(esp_wifi_init());
1279+
#endif
12741280

12751281
// Report Reset Reason
12761282
if (mcu & RST_POWER_ON) SERIAL_ECHOLNPGM(STR_POWERUP);

Marlin/src/inc/SanityCheck.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4307,10 +4307,14 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive.");
43074307
#endif
43084308

43094309
/**
4310-
* Sanity check for WIFI
4310+
* Sanity check WiFi options
43114311
*/
4312-
#if EITHER(ESP3D_WIFISUPPORT, WIFISUPPORT) && DISABLED(ARDUINO_ARCH_ESP32)
4313-
#error "ESP3D_WIFISUPPORT or WIFISUPPORT requires an ESP32 MOTHERBOARD."
4312+
#if ENABLED(ESP3D_WIFISUPPORT) && DISABLED(ARDUINO_ARCH_ESP32)
4313+
#error "ESP3D_WIFISUPPORT requires an ESP32 MOTHERBOARD."
4314+
#elif ENABLED(WEBSUPPORT) && NONE(ARDUINO_ARCH_ESP32, WIFISUPPORT)
4315+
#error "WEBSUPPORT requires WIFISUPPORT and an ESP32 MOTHERBOARD."
4316+
#elif BOTH(ESP3D_WIFISUPPORT, WIFISUPPORT)
4317+
#error "Enable only one of ESP3D_WIFISUPPORT or WIFISUPPORT."
43144318
#endif
43154319

43164320
/**

Marlin/src/pins/sam/pins_RURAMPS4D_11.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,13 @@
163163
#define TFT_LCD_MODULE_COM 1
164164
#define TFT_LCD_MODULE_BAUDRATE 115600
165165

166-
// ESP WiFi Use internal USART-2
167-
#define ESP_WIFI_MODULE_COM 2
168-
#define ESP_WIFI_MODULE_BAUDRATE 115600
169-
#define ESP_WIFI_MODULE_RESET_PIN -1
170-
#define PIGGY_GPIO_PIN -1
166+
#if ENABLED(WIFISUPPORT)
167+
// ESP WiFi Use internal USART-2
168+
#define ESP_WIFI_MODULE_COM 2
169+
#define ESP_WIFI_MODULE_BAUDRATE 115600
170+
#define ESP_WIFI_MODULE_RESET_PIN -1
171+
#define PIGGY_GPIO_PIN -1
172+
#endif
171173

172174
//
173175
// EEPROM

Marlin/src/pins/sam/pins_RURAMPS4D_13.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,13 @@
153153
#define TFT_LCD_MODULE_COM 1
154154
#define TFT_LCD_MODULE_BAUDRATE 115200
155155

156-
// ESP WiFi Use internal USART-2
157-
#define ESP_WIFI_MODULE_COM 2
158-
#define ESP_WIFI_MODULE_BAUDRATE 115200
159-
#define ESP_WIFI_MODULE_RESET_PIN -1
160-
#define PIGGY_GPIO_PIN -1
156+
#if ENABLED(WIFISUPPORT)
157+
// ESP WiFi Use internal USART-2
158+
#define ESP_WIFI_MODULE_COM 2
159+
#define ESP_WIFI_MODULE_BAUDRATE 115200
160+
#define ESP_WIFI_MODULE_RESET_PIN -1
161+
#define PIGGY_GPIO_PIN -1
162+
#endif
161163

162164
//
163165
// EEPROM

Marlin/src/pins/stm32f1/pins_FLSUN_HISPEED.h

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -138,27 +138,29 @@
138138
#define DEFAULT_PWM_MOTOR_CURRENT { 800, 800, 800 }
139139
#endif
140140

141-
/**
142-
* MKS Robin_Wifi or another ESP8266 module
143-
*
144-
* __ESP(M1)__ -J1-
145-
* GND| 15 | | 08 |+3v3 (22) RXD1 (PA10)
146-
* | 16 | | 07 |MOSI (21) TXD1 (PA9) Active LOW, probably OK to leave floating
147-
* IO2| 17 | | 06 |MISO (19) IO1 (PC7) Leave as unused (ESP3D software configures this with a pullup so OK to leave as floating)
148-
* IO0| 18 | | 05 |CLK (18) IO0 (PA8) Must be HIGH (ESP3D software configures this with a pullup so OK to leave as floating)
149-
* IO1| 19 | | 03 |EN (03) WIFI_EN Must be HIGH for module to run
150-
* | nc | | nc | (01) WIFI_CTRL (PA5)
151-
* RX| 21 | | nc |
152-
* TX| 22 | | 01 |RST
153-
*  ̄ ̄ AE ̄ ̄
154-
*/
155-
// Module ESP-WIFI
156-
#define ESP_WIFI_MODULE_COM 2 // Must also set either SERIAL_PORT or SERIAL_PORT_2 to this
157-
#define ESP_WIFI_MODULE_BAUDRATE BAUDRATE // Must use same BAUDRATE as SERIAL_PORT & SERIAL_PORT_2
158-
#define ESP_WIFI_MODULE_RESET_PIN PA5 // WIFI CTRL/RST
159-
#define ESP_WIFI_MODULE_ENABLE_PIN -1
160-
#define ESP_WIFI_MODULE_TXD_PIN PA9 // MKS or ESP WIFI RX PIN
161-
#define ESP_WIFI_MODULE_RXD_PIN PA10 // MKS or ESP WIFI TX PIN
141+
#if ENABLED(WIFISUPPORT)
142+
/**
143+
* MKS Robin_Wifi or another ESP8266 module
144+
*
145+
* __ESP(M1)__ -J1-
146+
* GND| 15 | | 08 |+3v3 (22) RXD1 (PA10)
147+
* | 16 | | 07 |MOSI (21) TXD1 (PA9) Active LOW, probably OK to leave floating
148+
* IO2| 17 | | 06 |MISO (19) IO1 (PC7) Leave as unused (ESP3D software configures this with a pullup so OK to leave as floating)
149+
* IO0| 18 | | 05 |CLK (18) IO0 (PA8) Must be HIGH (ESP3D software configures this with a pullup so OK to leave as floating)
150+
* IO1| 19 | | 03 |EN (03) WIFI_EN Must be HIGH for module to run
151+
* | nc | | nc | (01) WIFI_CTRL (PA5)
152+
* RX| 21 | | nc |
153+
* TX| 22 | | 01 |RST
154+
*  ̄ ̄ AE ̄ ̄
155+
*/
156+
// Module ESP-WIFI
157+
#define ESP_WIFI_MODULE_COM 2 // Must also set either SERIAL_PORT or SERIAL_PORT_2 to this
158+
#define ESP_WIFI_MODULE_BAUDRATE BAUDRATE // Must use same BAUDRATE as SERIAL_PORT & SERIAL_PORT_2
159+
#define ESP_WIFI_MODULE_RESET_PIN PA5 // WIFI CTRL/RST
160+
#define ESP_WIFI_MODULE_ENABLE_PIN -1
161+
#define ESP_WIFI_MODULE_TXD_PIN PA9 // MKS or ESP WIFI RX PIN
162+
#define ESP_WIFI_MODULE_RXD_PIN PA10 // MKS or ESP WIFI TX PIN
163+
#endif
162164
#endif
163165

164166
//

Marlin/src/pins/stm32f1/pins_GTM32_MINI.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -226,10 +226,11 @@
226226

227227
#define SDSS SD_SS_PIN
228228

229-
//
230-
// ESP WiFi can be soldered to J9 connector which is wired to USART2.
231-
// Must define WIFISUPPORT in Configuration.h for the printer.
232-
//
233-
#define ESP_WIFI_MODULE_COM 2
234-
#define ESP_WIFI_MODULE_BAUDRATE 115200
235-
#define ESP_WIFI_MODULE_RESET_PIN -1
229+
#if ENABLED(WIFISUPPORT)
230+
//
231+
// ESP WiFi can be soldered to J9 connector which is wired to USART2.
232+
//
233+
#define ESP_WIFI_MODULE_COM 2
234+
#define ESP_WIFI_MODULE_BAUDRATE 115200
235+
#define ESP_WIFI_MODULE_RESET_PIN -1
236+
#endif

Marlin/src/pins/stm32f1/pins_GTM32_MINI_A30.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -220,10 +220,11 @@
220220

221221
#define SDSS SD_SS_PIN
222222

223-
//
224-
// ESP WiFi can be soldered to J9 connector which is wired to USART2.
225-
// Must define WIFISUPPORT in Configuration.h for the printer.
226-
//
227-
#define ESP_WIFI_MODULE_COM 2
228-
#define ESP_WIFI_MODULE_BAUDRATE 115200
229-
#define ESP_WIFI_MODULE_RESET_PIN -1
223+
#if ENABLED(WIFISUPPORT)
224+
//
225+
// ESP WiFi can be soldered to J9 connector which is wired to USART2.
226+
//
227+
#define ESP_WIFI_MODULE_COM 2
228+
#define ESP_WIFI_MODULE_BAUDRATE 115200
229+
#define ESP_WIFI_MODULE_RESET_PIN -1
230+
#endif

Marlin/src/pins/stm32f1/pins_GTM32_PRO_VB.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,11 @@
231231

232232
#define SDSS SD_SS_PIN
233233

234-
//
235-
// ESP WiFi can be soldered to J9 connector which is wired to USART2.
236-
// Must define WIFISUPPORT in Configuration.h for the printer.
237-
//
238-
#define ESP_WIFI_MODULE_COM 2
239-
#define ESP_WIFI_MODULE_BAUDRATE 115200
240-
#define ESP_WIFI_MODULE_RESET_PIN -1
234+
#if ENABLED(WIFISUPPORT)
235+
//
236+
// ESP WiFi can be soldered to J9 connector which is wired to USART2.
237+
//
238+
#define ESP_WIFI_MODULE_COM 2
239+
#define ESP_WIFI_MODULE_BAUDRATE 115200
240+
#define ESP_WIFI_MODULE_RESET_PIN -1
241+
#endif

0 commit comments

Comments
 (0)