mirror of
https://github.com/esphome/esphome.git
synced 2026-10-04 18:11:29 +00:00
[uart] Fix RTL87xx compilation failure due to SUCCESS macro collision
The Realtek SDK defines `#define SUCCESS 0` in basic_types.h which collides with the FlushResult::SUCCESS enum value, breaking compilation on RTL87xx devices when api/wifi components pull in the SDK headers. Add `#undef SUCCESS` before the enum definition, following the same pattern used elsewhere in the codebase for vendor SDK macro collisions. Also add RTL87xx UART compilation test.
This commit is contained in:
@@ -30,12 +30,17 @@ enum UARTDirection {
|
|||||||
const LogString *parity_to_str(UARTParityOptions parity);
|
const LogString *parity_to_str(UARTParityOptions parity);
|
||||||
|
|
||||||
/// Result of a flush() call.
|
/// Result of a flush() call.
|
||||||
|
// Some vendor SDKs (e.g., Realtek) define SUCCESS as a macro.
|
||||||
|
// Save and restore around the enum to avoid collisions with our scoped enum value.
|
||||||
|
#pragma push_macro("SUCCESS")
|
||||||
|
#undef SUCCESS
|
||||||
enum class FlushResult {
|
enum class FlushResult {
|
||||||
SUCCESS, ///< Confirmed: all bytes left the TX FIFO.
|
SUCCESS, ///< Confirmed: all bytes left the TX FIFO.
|
||||||
TIMEOUT, ///< Confirmed: timed out before TX completed.
|
TIMEOUT, ///< Confirmed: timed out before TX completed.
|
||||||
FAILED, ///< Confirmed: driver or hardware error.
|
FAILED, ///< Confirmed: driver or hardware error.
|
||||||
ASSUMED_SUCCESS, ///< Platform cannot report result; success is assumed.
|
ASSUMED_SUCCESS, ///< Platform cannot report result; success is assumed.
|
||||||
};
|
};
|
||||||
|
#pragma pop_macro("SUCCESS")
|
||||||
|
|
||||||
class UARTComponent {
|
class UARTComponent {
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
uart:
|
||||||
|
- id: uart_id
|
||||||
|
tx_pin: PA23
|
||||||
|
rx_pin: PA18
|
||||||
|
baud_rate: 9600
|
||||||
|
data_bits: 8
|
||||||
|
parity: NONE
|
||||||
|
stop_bits: 1
|
||||||
|
|
||||||
|
switch:
|
||||||
|
- platform: uart
|
||||||
|
name: "UART Switch"
|
||||||
|
uart_id: uart_id
|
||||||
|
data: [0x01, 0x02, 0x03]
|
||||||
Reference in New Issue
Block a user