File tree 1 file changed +6
-1
lines changed
libraries/ESP32/examples/Serial/RS485_Echo_Demo
1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change 13
13
*/
14
14
15
15
#include < HardwareSerial.h>
16
+ #include " hal/uart_types.h"
16
17
17
18
#define RS485_RX_PIN 16
18
19
#define RS485_TX_PIN 5
@@ -29,7 +30,11 @@ void setup() {
29
30
Serial.print (" Failed to set RS485 pins" );
30
31
}
31
32
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)) {
33
38
Serial.print (" Failed to set RS485 mode" );
34
39
}
35
40
}
You can’t perform that action at this time.
0 commit comments