@@ -166,12 +166,104 @@ HardwareSerial::HardwareSerial(void* peripheral)
166
166
// If Serial is defined in variant set
167
167
// the Rx/Tx pins for com port if defined
168
168
#if defined(Serial) && defined(PIN_SERIAL_RX) && defined(PIN_SERIAL_TX)
169
- if (this == &Serial)
170
- {
169
+ if (this == &Serial) {
171
170
setRx (PIN_SERIAL_RX);
172
171
setTx (PIN_SERIAL_TX);
173
- }
174
- else
172
+ } else
173
+ #endif
174
+ #if defined(PIN_SERIAL1_RX) && defined(PIN_SERIAL1_TX) && defined(USART1_BASE)
175
+ if (peripheral == USART1) {
176
+ setRx (PIN_SERIAL1_RX);
177
+ setTx (PIN_SERIAL1_TX);
178
+ } else
179
+ #endif
180
+ #if defined(PIN_SERIAL2_RX) && defined(PIN_SERIAL2_TX) && defined(USART2_BASE)
181
+ if (peripheral == USART2) {
182
+ setRx (PIN_SERIAL2_RX);
183
+ setTx (PIN_SERIAL2_TX);
184
+ } else
185
+ #endif
186
+ #if defined(PIN_SERIAL3_RX) && defined(PIN_SERIAL3_TX) && defined(USART3_BASE)
187
+ if (peripheral == USART3) {
188
+ setRx (PIN_SERIAL3_RX);
189
+ setTx (PIN_SERIAL3_TX);
190
+ }else
191
+ #endif
192
+ #if defined(PIN_SERIAL4_RX) && defined(PIN_SERIAL4_TX) &&\
193
+ (defined (USART4_BASE) || defined (UART4_BASE))
194
+ #if defined(USART4_BASE)
195
+ if (peripheral == USART4)
196
+ #elif defined(UART4_BASE)
197
+ if (peripheral == UART4)
198
+ #endif
199
+ {
200
+ setRx (PIN_SERIAL4_RX);
201
+ setTx (PIN_SERIAL4_TX);
202
+ } else
203
+ #endif
204
+ #if defined(PIN_SERIAL5_RX) && defined(PIN_SERIAL5_TX) &&\
205
+ (defined (USART5_BASE) || defined (UART5_BASE))
206
+ #if defined(USART5_BASE)
207
+ if (peripheral == USART5)
208
+ #elif defined(UART5_BASE)
209
+ if (peripheral == UART5)
210
+ #endif
211
+ {
212
+ setRx (PIN_SERIAL5_RX);
213
+ setTx (PIN_SERIAL5_TX);
214
+ } else
215
+ #endif
216
+ #if defined(PIN_SERIAL6_RX) && defined(PIN_SERIAL6_TX) && defined(USART6_BASE)
217
+ if (peripheral == USART6)
218
+ {
219
+ setRx (PIN_SERIAL6_RX);
220
+ setTx (PIN_SERIAL6_TX);
221
+ } else
222
+ #endif
223
+ #if defined(PIN_SERIAL7_RX) && defined(PIN_SERIAL7_TX) &&\
224
+ (defined (USART7_BASE) || defined (UART7_BASE))
225
+ #if defined(USART7_BASE)
226
+ if (peripheral == USART7)
227
+ #elif defined(UART7_BASE)
228
+ if (peripheral == UART7)
229
+ #endif
230
+ {
231
+ setRx (PIN_SERIAL7_RX);
232
+ setTx (PIN_SERIAL7_TX);
233
+ } else
234
+ #endif
235
+ #if defined(PIN_SERIAL8_RX) && defined(PIN_SERIAL8_TX) &&\
236
+ (defined (USART8_BASE) || defined (UART8_BASE))
237
+ #if defined(USART8_BASE)
238
+ if (peripheral == USART8)
239
+ #elif defined(UART8_BASE)
240
+ if (peripheral == UART8)
241
+ #endif
242
+ {
243
+ setRx (PIN_SERIAL8_RX);
244
+ setTx (PIN_SERIAL8_TX);
245
+ } else
246
+ #endif
247
+ #if defined(PIN_SERIAL9_RX) && defined(PIN_SERIAL9_TX) && defined(UART9)
248
+ if (peripheral == UART9)
249
+ {
250
+ setRx (PIN_SERIAL9_RX);
251
+ setTx (PIN_SERIAL9_TX);
252
+ } else
253
+ #endif
254
+ #if defined(PIN_SERIAL10_RX) && defined(PIN_SERIAL10_TX) && defined(UART10)
255
+ if (peripheral == UART10)
256
+ {
257
+ setRx (PIN_SERIAL10_RX);
258
+ setTx (PIN_SERIAL10_TX);
259
+ } else
260
+ #endif
261
+ #if defined(PIN_SERIALLP1_RX) && defined(PIN_SERIALLP1_TX) && defined(LPUART1_BASE)
262
+ if (peripheral == LPUART1)
263
+ {
264
+ setRx (PIN_SERIALLP1_RX);
265
+ setTx (PIN_SERIALLP1_TX);
266
+ } else
175
267
#endif
176
268
// else get the pins of the first peripheral occurence in PinMap
177
269
{
0 commit comments