Sfoglia il codice sorgente

Tricked-out declaration

Scott Lahteine 3 anni fa
parent
commit
048f6b4731
2 ha cambiato i file con 14 aggiunte e 3 eliminazioni
  1. 6
    1
      Marlin/src/HAL/TEENSY35_36/HAL.cpp
  2. 8
    2
      Marlin/src/HAL/TEENSY35_36/HAL.h

+ 6
- 1
Marlin/src/HAL/TEENSY35_36/HAL.cpp Vedi File

@@ -31,7 +31,12 @@
31 31
 
32 32
 #include <Wire.h>
33 33
 
34
-DefaultSerial1 MSerial0(false);
34
+#define _IMPLEMENT_SERIAL(X) DefaultSerial##X MSerial##X(false)
35
+#define IMPLEMENT_SERIAL(X)  _IMPLEMENT_SERIAL(X)
36
+#if WITHIN(SERIAL_PORT, 0, 3)
37
+  IMPLEMENT_SERIAL(SERIAL_PORT);
38
+#endif
39
+
35 40
 USBSerialType USBSerial(false, SerialUSB);
36 41
 
37 42
 uint16_t HAL_adc_result, HAL_adc_select;

+ 8
- 2
Marlin/src/HAL/TEENSY35_36/HAL.h Vedi File

@@ -54,8 +54,13 @@
54 54
 #endif
55 55
 
56 56
 #include "../../core/serial_hook.h"
57
-typedef Serial1Class<decltype(Serial)> DefaultSerial1;
58
-extern DefaultSerial1 MSerial0;
57
+
58
+#define Serial0 Serial
59
+#define _DECLARE_SERIAL(X) \
60
+  typedef Serial1Class<decltype(Serial##X)> DefaultSerial##X; \
61
+  extern DefaultSerial##X MSerial##X
62
+#define DECLARE_SERIAL(X) _DECLARE_SERIAL(X)
63
+
59 64
 typedef ForwardSerial1Class<decltype(SerialUSB)> USBSerialType;
60 65
 extern USBSerialType USBSerial;
61 66
 
@@ -66,6 +71,7 @@ extern USBSerialType USBSerial;
66 71
   #define MYSERIAL1 USBSerial
67 72
 #elif WITHIN(SERIAL_PORT, 0, 3)
68 73
   #define MYSERIAL1 MSERIAL(SERIAL_PORT)
74
+  DECLARE_SERIAL(SERIAL_PORT);
69 75
 #endif
70 76
 
71 77
 #define HAL_SERVO_LIB libServo

Loading…
Annulla
Salva