Skip to content

Commit 371bf9b

Browse files
authored
Fix when no Serial pin defined
Some boards does not have Hardware Serial defined per default but used USB Serial.
1 parent e1f038b commit 371bf9b

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

examples/NonReg/CheckVariant/CheckVariant.ino

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include "utils.h"
88

99
#if !defined(STM32_CORE_VERSION) || (STM32_CORE_VERSION <= 0x01090000)
10-
#error "This sketch is not compatible with core version prior to 2.0.0"
10+
#error "This sketch is not compatible with core version prior to 2.0.0"
1111
#endif
1212

1313
#define PORTx(pn) (char)('A' + STM_PORT(pn))
@@ -24,6 +24,7 @@
2424
*/
2525
bool checkSerial(void) {
2626
bool testPassed = true;
27+
#if defined(PinMap_UART_RX) && defined(PinMap_UART_TX)
2728
USART_TypeDef *uart_rx = (USART_TypeDef *)pinmap_peripheral(digitalPinToPinName(PIN_SERIAL_RX), PinMap_UART_RX);
2829
USART_TypeDef *uart_tx = (USART_TypeDef *)pinmap_peripheral(digitalPinToPinName(PIN_SERIAL_TX), PinMap_UART_TX);
2930
if (uart_rx == NP) {
@@ -38,7 +39,7 @@ bool checkSerial(void) {
3839
/* PIN_SERIAL_RX (%d) doesn't match PIN_SERIAL_TX peripheral */
3940
testPassed = false;
4041
}
41-
42+
#endif
4243
return testPassed;
4344
}
4445

0 commit comments

Comments
 (0)