Skip to content

Commit ad8589f

Browse files
committed
Switched to UART_MODE definitions from uart_types.h in order to accomodate some versions of Arduino core
1 parent 6022ef6 commit ad8589f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

libraries/ESP32/examples/Serial/RS485_Echo_Demo/RS485_Echo_Demo.ino

+6-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
*/
1414

1515
#include <HardwareSerial.h>
16+
#include "hal/uart_types.h"
1617

1718
#define RS485_RX_PIN 16
1819
#define RS485_TX_PIN 5
@@ -29,7 +30,11 @@ void setup() {
2930
Serial.print("Failed to set RS485 pins");
3031
}
3132

32-
if(!RS485.setMode(MODE_RS485_HALF_DUPLEX)) {
33+
// Certain versions of Arduino core don't define MODE_RS485_HALF_DUPLEX and so fail to compile.
34+
// By using UART_MODE_RS485_HALF_DUPLEX defined in hal/uart_types.h we work around this problem.
35+
// If using a newer IDF and Arduino core you can ommit including hal/uart_types.h and use MODE_RS485_HALF_DUPLEX
36+
// defined in esp32-hal-uart.h (included during other build steps) instead.
37+
if(!RS485.setMode(UART_MODE_RS485_HALF_DUPLEX)) {
3338
Serial.print("Failed to set RS485 mode");
3439
}
3540
}

0 commit comments

Comments
 (0)