Use enum for C++ to avoid macro pitfalls (#7926)

This commit is contained in:
Dirk O. Kaar 2023-03-31 13:32:48 +02:00 committed by GitHub
parent c0737f53f2
commit f275ce5563
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -25,6 +25,34 @@ extern "C" {
#include "freertos/FreeRTOS.h" #include "freertos/FreeRTOS.h"
#include "freertos/queue.h" #include "freertos/queue.h"
#ifdef __cplusplus
enum SerialConfig {
SERIAL_5N1 = 0x8000010,
SERIAL_6N1 = 0x8000014,
SERIAL_7N1 = 0x8000018,
SERIAL_8N1 = 0x800001c,
SERIAL_5N2 = 0x8000030,
SERIAL_6N2 = 0x8000034,
SERIAL_7N2 = 0x8000038,
SERIAL_8N2 = 0x800003c,
SERIAL_5E1 = 0x8000012,
SERIAL_6E1 = 0x8000016,
SERIAL_7E1 = 0x800001a,
SERIAL_8E1 = 0x800001e,
SERIAL_5E2 = 0x8000032,
SERIAL_6E2 = 0x8000036,
SERIAL_7E2 = 0x800003a,
SERIAL_8E2 = 0x800003e,
SERIAL_5O1 = 0x8000013,
SERIAL_6O1 = 0x8000017,
SERIAL_7O1 = 0x800001b,
SERIAL_8O1 = 0x800001f,
SERIAL_5O2 = 0x8000033,
SERIAL_6O2 = 0x8000037,
SERIAL_7O2 = 0x800003b,
SERIAL_8O2 = 0x800003f
};
#else
#define SERIAL_5N1 0x8000010 #define SERIAL_5N1 0x8000010
#define SERIAL_6N1 0x8000014 #define SERIAL_6N1 0x8000014
#define SERIAL_7N1 0x8000018 #define SERIAL_7N1 0x8000018
@ -49,6 +77,7 @@ extern "C" {
#define SERIAL_6O2 0x8000037 #define SERIAL_6O2 0x8000037
#define SERIAL_7O2 0x800003b #define SERIAL_7O2 0x800003b
#define SERIAL_8O2 0x800003f #define SERIAL_8O2 0x800003f
#endif // __cplusplus
// These are Hardware Flow Contol possible usage // These are Hardware Flow Contol possible usage
// equivalent to UDF enum uart_hw_flowcontrol_t from // equivalent to UDF enum uart_hw_flowcontrol_t from