|
@@ -27,6 +27,7 @@
|
27
|
27
|
#include <rom/rtc.h>
|
28
|
28
|
#include <driver/adc.h>
|
29
|
29
|
#include <esp_adc_cal.h>
|
|
30
|
+#include <HardwareSerial.h>
|
30
|
31
|
|
31
|
32
|
#include "../../inc/MarlinConfigPre.h"
|
32
|
33
|
|
|
@@ -105,6 +106,27 @@ void HAL_init_board() {
|
105
|
106
|
#endif
|
106
|
107
|
server.begin();
|
107
|
108
|
#endif
|
|
109
|
+
|
|
110
|
+ // ESP32 uses a GPIO matrix that allows pins to be assigned to hardware serial ports.
|
|
111
|
+ // The following code initializes hardware Serial1 and Serial2 to use user-defined pins
|
|
112
|
+ // if they have been defined.
|
|
113
|
+ #if defined(HARDWARE_SERIAL1_RX) && defined(HARDWARE_SERIAL1_TX)
|
|
114
|
+ HardwareSerial Serial1(1);
|
|
115
|
+ #ifdef TMC_BAUD_RATE // use TMC_BAUD_RATE for Serial1 if defined
|
|
116
|
+ Serial1.begin(TMC_BAUD_RATE, SERIAL_8N1, HARDWARE_SERIAL1_RX, HARDWARE_SERIAL1_TX);
|
|
117
|
+ #else // use default BAUDRATE if TMC_BAUD_RATE not defined
|
|
118
|
+ Serial1.begin(BAUDRATE, SERIAL_8N1, HARDWARE_SERIAL1_RX, HARDWARE_SERIAL1_TX);
|
|
119
|
+ #endif
|
|
120
|
+ #endif
|
|
121
|
+ #if defined(HARDWARE_SERIAL2_RX) && defined(HARDWARE_SERIAL2_TX)
|
|
122
|
+ HardwareSerial Serial2(2);
|
|
123
|
+ #ifdef TMC_BAUD_RATE // use TMC_BAUD_RATE for Serial1 if defined
|
|
124
|
+ Serial2.begin(TMC_BAUD_RATE, SERIAL_8N1, HARDWARE_SERIAL2_RX, HARDWARE_SERIAL2_TX);
|
|
125
|
+ #else // use default BAUDRATE if TMC_BAUD_RATE not defined
|
|
126
|
+ Serial2.begin(BAUDRATE, SERIAL_8N1, HARDWARE_SERIAL2_RX, HARDWARE_SERIAL2_TX);
|
|
127
|
+ #endif
|
|
128
|
+ #endif
|
|
129
|
+
|
108
|
130
|
}
|
109
|
131
|
|
110
|
132
|
void HAL_idletask() {
|