mirror of
https://github.com/espressif/esp-idf.git
synced 2025-11-18 10:31:09 +00:00
fix(hal): Wrap LL macros with atomic env in do-while for control safety
- Standardize all LL macros using atomic env variables with `do { ... } while (0)`
- Prevent potential macro misuse in control flow constructs (e.g., if/else)
- Affected targets: esp32, esp32c2, esp32c5, esp32s3, esp32p4, etc.
- Affected modules include: LCD, I2S, TIMER, and others
This commit is contained in:
@@ -149,7 +149,10 @@ static inline void lp_uart_ll_set_source_clk(uart_dev_t *hw, soc_periph_lp_uart_
|
||||
}
|
||||
|
||||
/// LP_CLKRST.lpperi is a shared register, so this function must be used in an atomic way
|
||||
#define lp_uart_ll_set_source_clk(...) (void)__DECLARE_RCC_ATOMIC_ENV; lp_uart_ll_set_source_clk(__VA_ARGS__)
|
||||
#define lp_uart_ll_set_source_clk(...) do { \
|
||||
(void)__DECLARE_RCC_ATOMIC_ENV; \
|
||||
lp_uart_ll_set_source_clk(__VA_ARGS__); \
|
||||
} while(0)
|
||||
|
||||
/**
|
||||
* @brief Configure the lp uart baud-rate.
|
||||
@@ -192,7 +195,10 @@ static inline void lp_uart_ll_enable_bus_clock(int hw_id, bool enable)
|
||||
}
|
||||
|
||||
/// LPPERI.clk_en is a shared register, so this function must be used in an atomic way
|
||||
#define lp_uart_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; lp_uart_ll_enable_bus_clock(__VA_ARGS__)
|
||||
#define lp_uart_ll_enable_bus_clock(...) do { \
|
||||
(void)__DECLARE_RCC_ATOMIC_ENV; \
|
||||
lp_uart_ll_enable_bus_clock(__VA_ARGS__); \
|
||||
} while(0)
|
||||
|
||||
/**
|
||||
* @brief Enable the UART clock.
|
||||
@@ -231,7 +237,10 @@ static inline void lp_uart_ll_reset_register(int hw_id)
|
||||
}
|
||||
|
||||
/// LPPERI.reset_en is a shared register, so this function must be used in an atomic way
|
||||
#define lp_uart_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; lp_uart_ll_reset_register(__VA_ARGS__)
|
||||
#define lp_uart_ll_reset_register(...) do { \
|
||||
(void)__DECLARE_RCC_ATOMIC_ENV; \
|
||||
lp_uart_ll_reset_register(__VA_ARGS__); \
|
||||
} while(0)
|
||||
|
||||
/*************************************** General LL functions ******************************************/
|
||||
|
||||
|
||||
Reference in New Issue
Block a user