Skip to content

Commit 812b696

Browse files
committed
Fix - SAMD uart hardware.cpp
1 parent 194491e commit 812b696

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/components/uart/hardware.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,9 @@ bool UARTHardware::ConfigureSerial() {
126126
_baud_rate = _config.baud_rate;
127127
#endif // HAS_SW_SERIAL
128128
} else {
129-
#ifdef ARDUINO_ARCH_RP2040
129+
#ifdef ARDUINO_ARCH_RP2040 || defined(ADAFRUIT_METRO_M4_EXPRESS) || \
130+
defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) || defined(ADAFRUIT_PYPORTAL) || \
131+
defined(ADAFRUIT_PYPORTAL_M4_TITANO)
130132
if (_config.uart_nbr == 1) {
131133
_hwSerial = &Serial1;
132134
} else if (_config.uart_nbr == 2) {
@@ -135,10 +137,10 @@ bool UARTHardware::ConfigureSerial() {
135137
WS_DEBUG_PRINTLN("[uart] ERROR: Invalid UART number for ESP32!");
136138
return false;
137139
}
138-
#else
140+
#else
139141
// Create a new HardwareSerial instance
140142
_hwSerial = new HardwareSerial(_config.uart_nbr);
141-
#endif
143+
#endif
142144
if (_hwSerial == nullptr) {
143145
WS_DEBUG_PRINTLN(
144146
"[uart] ERROR: Failed to allocate HardwareSerial instance!");
@@ -152,15 +154,15 @@ bool UARTHardware::ConfigureSerial() {
152154
// Pins are already defined by the Serial1/Serial2 instances
153155
_hwSerial->begin((unsigned long)_config.baud_rate, (uint32_t)cfg);
154156
#else
155-
// ESP8266, SAMD, and other platforms
156-
// take the default Arduino/Wiring API arguments
157-
#ifdef ARDUINO_ARCH_ESP8266
157+
// ESP8266, SAMD, and other platforms
158+
// take the default Arduino/Wiring API arguments
159+
#ifdef ARDUINO_ARCH_ESP8266
158160
// We want to pass the cfg as an enum for ESP8266
159161
_hwSerial->begin((unsigned long)_config.baud_rate, (SerialConfig)cfg);
160-
#else
162+
#else
161163
// We want to cast the cfg for other platforms
162164
_hwSerial->begin((unsigned long)_config.baud_rate, (uint32_t)cfg);
163-
#endif
165+
#endif
164166
#endif
165167
_baud_rate = _config.baud_rate;
166168
}

0 commit comments

Comments
 (0)