Parcourir la source

STM32F1: Dummy SoftwareSerial (as TMCStepper fallback) (#14861)

Tanguy Pruvot il y a 5 ans
Parent
révision
535018ef0e

+ 60
- 0
Marlin/src/HAL/HAL_STM32F1/SoftwareSerial.cpp Voir le fichier

@@ -0,0 +1,60 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * This program is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
+ *
18
+ */
19
+#ifdef __STM32F1__
20
+
21
+/**
22
+ * Empty class for Software Serial implementation (Custom RX/TX pins)
23
+ *
24
+ * TODO: Optionally use https://github.com/FYSETC/SoftwareSerialM if TMC UART is wanted
25
+ */
26
+
27
+#include "SoftwareSerial.h"
28
+
29
+// Constructor
30
+
31
+SoftwareSerial::SoftwareSerial(pin_t RX_pin, pin_t TX_pin) {}
32
+
33
+// Public
34
+
35
+void SoftwareSerial::begin(const uint32_t baudrate) {
36
+}
37
+
38
+bool SoftwareSerial::available() {
39
+  return false;
40
+}
41
+
42
+uint8_t SoftwareSerial::read() {
43
+  return 0;
44
+}
45
+
46
+uint16_t SoftwareSerial::write(uint8_t byte) {
47
+  return 0;
48
+}
49
+
50
+void SoftwareSerial::flush() {}
51
+
52
+void SoftwareSerial::listen() {
53
+  listening = true;
54
+}
55
+
56
+void SoftwareSerial::stopListening() {
57
+  listening = false;
58
+}
59
+
60
+#endif //__STM32F1__

+ 42
- 0
Marlin/src/HAL/HAL_STM32F1/SoftwareSerial.h Voir le fichier

@@ -0,0 +1,42 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * This program is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or
8
+ * (at your option) any later version.
9
+ *
10
+ * This program is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
+ * GNU General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License
16
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
+ *
18
+ */
19
+#pragma once
20
+
21
+#include "HAL.h"
22
+
23
+#define SW_SERIAL_PLACEHOLDER 1
24
+
25
+class SoftwareSerial {
26
+public:
27
+  SoftwareSerial(pin_t RX_pin, pin_t TX_pin);
28
+
29
+  void begin(const uint32_t baudrate);
30
+
31
+  bool available();
32
+
33
+  uint8_t read();
34
+  uint16_t write(uint8_t byte);
35
+  void flush();
36
+
37
+  void listen();
38
+  void stopListening();
39
+
40
+protected:
41
+  bool listening;
42
+};

Chargement…
Annuler
Enregistrer