Browse Source

Fix STM32F1 Serial and ADC pins (#13331)

Msq001 5 years ago
parent
commit
fb3302feda
2 changed files with 44 additions and 18 deletions
  1. 4
    1
      Marlin/src/HAL/HAL_STM32F1/HAL.cpp
  2. 40
    17
      Marlin/src/HAL/HAL_STM32F1/HAL.h

+ 4
- 1
Marlin/src/HAL/HAL_STM32F1/HAL.cpp View File

@@ -33,6 +33,7 @@
33 33
 
34 34
 #include "HAL.h"
35 35
 #include <STM32ADC.h>
36
+#include "../../inc/MarlinConfig.h"
36 37
 
37 38
 // --------------------------------------------------------------------------
38 39
 // Externals
@@ -91,7 +92,9 @@
91 92
 // --------------------------------------------------------------------------
92 93
 // Public Variables
93 94
 // --------------------------------------------------------------------------
94
-USBSerial SerialUSB;
95
+#ifdef SERIAL_USB
96
+  USBSerial SerialUSB;
97
+#endif
95 98
 
96 99
 uint16_t HAL_adc_result;
97 100
 

+ 40
- 17
Marlin/src/HAL/HAL_STM32F1/HAL.h View File

@@ -51,46 +51,69 @@
51 51
 #include "watchdog_STM32F1.h"
52 52
 
53 53
 #include "HAL_timers_STM32F1.h"
54
-
54
+#include "../../inc/MarlinConfigPre.h"
55 55
 
56 56
 // --------------------------------------------------------------------------
57 57
 // Defines
58 58
 // --------------------------------------------------------------------------
59 59
 
60
-#if !WITHIN(SERIAL_PORT, -1, 3)
61
-  #error "SERIAL_PORT must be from -1 to 3"
60
+#ifdef SERIAL_USB
61
+  #define UsbSerial Serial
62
+  #define MSerial1  Serial1
63
+  #define MSerial2  Serial2
64
+  #define MSerial3  Serial3
65
+  #define MSerial4  Serial4
66
+  #define MSerial5  Serial5
67
+#else
68
+  extern USBSerial SerialUSB;
69
+  #define UsbSerial SerialUSB
70
+  #define MSerial1  Serial
71
+  #define MSerial2  Serial1
72
+  #define MSerial3  Serial2
73
+  #define MSerial4  Serial3
74
+  #define MSerial5  Serial4
75
+#endif
76
+
77
+#if !WITHIN(SERIAL_PORT, -1, 5)
78
+  #error "SERIAL_PORT must be from -1 to 5"
62 79
 #endif
63 80
 #if SERIAL_PORT == -1
64
-  extern USBSerial SerialUSB;
65
-  #define MYSERIAL0 SerialUSB
81
+  #define MYSERIAL0 UsbSerial
66 82
 #elif SERIAL_PORT == 0
67
-  #define MYSERIAL0 Serial
83
+  #error "Serial port 0 does not exist"
68 84
 #elif SERIAL_PORT == 1
69
-  #define MYSERIAL0 Serial1
85
+  #define MYSERIAL0 MSerial1
70 86
 #elif SERIAL_PORT == 2
71
-  #define MYSERIAL0 Serial2
87
+  #define MYSERIAL0 MSerial2
72 88
 #elif SERIAL_PORT == 3
73
-  #define MYSERIAL0 Serial3
89
+  #define MYSERIAL0 MSerial3
90
+#elif SERIAL_PORT == 4
91
+  #define MYSERIAL0 MSerial4
92
+#elif SERIAL_PORT == 5
93
+  #define MYSERIAL0 MSerial5
74 94
 #endif
75 95
 
76 96
 #ifdef SERIAL_PORT_2
77
-  #if !WITHIN(SERIAL_PORT_2, -1, 3)
78
-    #error "SERIAL_PORT_2 must be from -1 to 3"
97
+  #if !WITHIN(SERIAL_PORT_2, -1, 5)
98
+    #error "SERIAL_PORT_2 must be from -1 to 5"
79 99
   #elif SERIAL_PORT_2 == SERIAL_PORT
80 100
     #error "SERIAL_PORT_2 must be different than SERIAL_PORT"
81 101
   #endif
82 102
   #define NUM_SERIAL 2
83 103
   #if SERIAL_PORT_2 == -1
84
-    extern USBSerial SerialUSB;
85
-    #define MYSERIAL1 SerialUSB
104
+    #define MYSERIAL1 UsbSerial
86 105
   #elif SERIAL_PORT_2 == 0
87
-    #define MYSERIAL1 Serial
106
+  #error "Serial port 0 does not exist"
88 107
   #elif SERIAL_PORT_2 == 1
89
-    #define MYSERIAL1 Serial1
108
+    #define MYSERIAL1 MSerial1
90 109
   #elif SERIAL_PORT_2 == 2
91
-    #define MYSERIAL1 Serial2
110
+    #define MYSERIAL1 MSerial2
92 111
   #elif SERIAL_PORT_2 == 3
93
-    #define MYSERIAL1 Serial3
112
+    #define MYSERIAL1 MSerial3
113
+  #elif SERIAL_PORT_2 == 4
114
+    #define MYSERIAL1 MSerial4
115
+  #elif SERIAL_PORT_2 == 5
116
+    #define MYSERIAL1 MSerial5
94 117
   #endif
95 118
 #else
96 119
   #define NUM_SERIAL 1

Loading…
Cancel
Save