Ver código fonte

Extend ESP32 HardwareSerial with flushTX. (#13588)

Kajetan Rzepecki 5 anos atrás
pai
commit
27693cec29

+ 33
- 0
Marlin/src/HAL/HAL_ESP32/FlushableHardwareSerial.cpp Ver arquivo

@@ -0,0 +1,33 @@
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 Ver arquivo

@@ -0,0 +1,36 @@
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 Ver arquivo

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

Carregando…
Cancelar
Salvar