|
30 | 30 | #if defined(HAVE_HWSERIAL1) || defined(HAVE_HWSERIAL2) || defined(HAVE_HWSERIAL3) ||\
|
31 | 31 | defined(HAVE_HWSERIAL4) || defined(HAVE_HWSERIAL5) || defined(HAVE_HWSERIAL6) ||\
|
32 | 32 | defined(HAVE_HWSERIAL7) || defined(HAVE_HWSERIAL8) || defined(HAVE_HWSERIAL9) ||\
|
33 |
| - defined(HAVE_HWSERIAL10) || defined(HAVE_HWSERIALLP1) |
| 33 | + defined(HAVE_HWSERIAL10) || defined(HAVE_HWSERIALLP1) || defined(HAVE_HWSERIALLP2) |
34 | 34 | // SerialEvent functions are weak, so when the user doesn't define them,
|
35 | 35 | // the linker just sets their address to 0 (which is checked below).
|
36 | 36 | #if defined(HAVE_HWSERIAL1)
|
|
107 | 107 | HardwareSerial SerialLP1(LPUART1);
|
108 | 108 | void serialEventLP1() __attribute__((weak));
|
109 | 109 | #endif
|
| 110 | + |
| 111 | + #if defined(HAVE_HWSERIALLP2) |
| 112 | + HardwareSerial SerialLP2(LPUART2); |
| 113 | + void serialEventLP2() __attribute__((weak)); |
| 114 | + #endif |
110 | 115 | #endif // HAVE_HWSERIALx
|
111 | 116 |
|
112 | 117 | // Constructors ////////////////////////////////////////////////////////////////
|
@@ -252,11 +257,19 @@ HardwareSerial::HardwareSerial(void *peripheral, HalfDuplexMode_t halfDuplex)
|
252 | 257 | setTx(PIN_SERIALLP1_TX);
|
253 | 258 | } else
|
254 | 259 | #endif
|
255 |
| - // else get the pins of the first peripheral occurence in PinMap |
256 |
| - { |
257 |
| - _serial.pin_rx = pinmap_pin(peripheral, PinMap_UART_RX); |
258 |
| - _serial.pin_tx = pinmap_pin(peripheral, PinMap_UART_TX); |
259 |
| - } |
| 260 | +#if defined(PIN_SERIALLP2_TX) && defined(LPUART2_BASE) |
| 261 | + if (peripheral == LPUART2) { |
| 262 | +#if defined(PIN_SERIALLP2_RX) |
| 263 | + setRx(PIN_SERIALLP2_RX); |
| 264 | +#endif |
| 265 | + setTx(PIN_SERIALLP2_TX); |
| 266 | + } else |
| 267 | +#endif |
| 268 | + // else get the pins of the first peripheral occurence in PinMap |
| 269 | + { |
| 270 | + _serial.pin_rx = pinmap_pin(peripheral, PinMap_UART_RX); |
| 271 | + _serial.pin_tx = pinmap_pin(peripheral, PinMap_UART_TX); |
| 272 | + } |
260 | 273 | if (halfDuplex == HALF_DUPLEX_ENABLED) {
|
261 | 274 | _serial.pin_rx = NC;
|
262 | 275 | }
|
|
0 commit comments