Skip to content

Commit f275ce5

Browse files
authored
Use enum for C++ to avoid macro pitfalls (espressif#7926)
1 parent c0737f5 commit f275ce5

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

cores/esp32/esp32-hal-uart.h

+29
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,34 @@ extern "C" {
2525
#include "freertos/FreeRTOS.h"
2626
#include "freertos/queue.h"
2727

28+
#ifdef __cplusplus
29+
enum SerialConfig {
30+
SERIAL_5N1 = 0x8000010,
31+
SERIAL_6N1 = 0x8000014,
32+
SERIAL_7N1 = 0x8000018,
33+
SERIAL_8N1 = 0x800001c,
34+
SERIAL_5N2 = 0x8000030,
35+
SERIAL_6N2 = 0x8000034,
36+
SERIAL_7N2 = 0x8000038,
37+
SERIAL_8N2 = 0x800003c,
38+
SERIAL_5E1 = 0x8000012,
39+
SERIAL_6E1 = 0x8000016,
40+
SERIAL_7E1 = 0x800001a,
41+
SERIAL_8E1 = 0x800001e,
42+
SERIAL_5E2 = 0x8000032,
43+
SERIAL_6E2 = 0x8000036,
44+
SERIAL_7E2 = 0x800003a,
45+
SERIAL_8E2 = 0x800003e,
46+
SERIAL_5O1 = 0x8000013,
47+
SERIAL_6O1 = 0x8000017,
48+
SERIAL_7O1 = 0x800001b,
49+
SERIAL_8O1 = 0x800001f,
50+
SERIAL_5O2 = 0x8000033,
51+
SERIAL_6O2 = 0x8000037,
52+
SERIAL_7O2 = 0x800003b,
53+
SERIAL_8O2 = 0x800003f
54+
};
55+
#else
2856
#define SERIAL_5N1 0x8000010
2957
#define SERIAL_6N1 0x8000014
3058
#define SERIAL_7N1 0x8000018
@@ -49,6 +77,7 @@ extern "C" {
4977
#define SERIAL_6O2 0x8000037
5078
#define SERIAL_7O2 0x800003b
5179
#define SERIAL_8O2 0x800003f
80+
#endif // __cplusplus
5281

5382
// These are Hardware Flow Contol possible usage
5483
// equivalent to UDF enum uart_hw_flowcontrol_t from

0 commit comments

Comments
 (0)