浏览代码

Extend ESP32 HardwareSerial with flushTX. (#13588)

Kajetan Rzepecki 6 年前
父节点
当前提交
27693cec29

+ 33
- 0
Marlin/src/HAL/HAL_ESP32/FlushableHardwareSerial.cpp 查看文件

1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+#include "FlushableHardwareSerial.h"
24
+
25
+#ifdef ARDUINO_ARCH_ESP32
26
+
27
+FlushableHardwareSerial::FlushableHardwareSerial(int uart_nr)
28
+    : HardwareSerial(uart_nr)
29
+{}
30
+
31
+FlushableHardwareSerial flushableSerial(0);
32
+
33
+#endif // ARDUINO_ARCH_ESP32

+ 36
- 0
Marlin/src/HAL/HAL_ESP32/FlushableHardwareSerial.h 查看文件

1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+
23
+#ifdef ARDUINO_ARCH_ESP32
24
+
25
+#include <HardwareSerial.h>
26
+
27
+class FlushableHardwareSerial : public HardwareSerial {
28
+public:
29
+  FlushableHardwareSerial(int uart_nr);
30
+
31
+  inline void flushTX(void) { /* No need to flush the hardware serial, but defined here for compatibility. */ }
32
+};
33
+
34
+extern FlushableHardwareSerial flushableSerial;
35
+
36
+#endif // ARDUINO_ARCH_ESP32

+ 2
- 1
Marlin/src/HAL/HAL_ESP32/HAL.h 查看文件

48
 #include "HAL_timers_ESP32.h"
48
 #include "HAL_timers_ESP32.h"
49
 
49
 
50
 #include "WebSocketSerial.h"
50
 #include "WebSocketSerial.h"
51
+#include "FlushableHardwareSerial.h"
51
 
52
 
52
 // --------------------------------------------------------------------------
53
 // --------------------------------------------------------------------------
53
 // Defines
54
 // Defines
55
 
56
 
56
 extern portMUX_TYPE spinlock;
57
 extern portMUX_TYPE spinlock;
57
 
58
 
58
-#define MYSERIAL0 Serial
59
+#define MYSERIAL0 flushableSerial
59
 
60
 
60
 #if ENABLED(WIFISUPPORT)
61
 #if ENABLED(WIFISUPPORT)
61
   #define NUM_SERIAL 2
62
   #define NUM_SERIAL 2

正在加载...
取消
保存