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:
Yuan Yu
2025-05-22 14:41:19 +08:00
parent 5133b89183
commit 18091976ec
162 changed files with 1742 additions and 500 deletions

View File

@@ -29,7 +29,10 @@ static inline __attribute__((always_inline)) void _regi2c_ctrl_ll_master_enable_
}
// LPPERI.clk_en is a shared register, so this function must be used in an atomic way
#define regi2c_ctrl_ll_master_enable_clock(...) (void)__DECLARE_RCC_RC_ATOMIC_ENV; _regi2c_ctrl_ll_master_enable_clock(__VA_ARGS__)
#define regi2c_ctrl_ll_master_enable_clock(...) do { \
(void)__DECLARE_RCC_RC_ATOMIC_ENV; \
_regi2c_ctrl_ll_master_enable_clock(__VA_ARGS__); \
} while(0)
/**
* @brief Check whether analog I2C master clock is enabled
@@ -49,7 +52,10 @@ static inline __attribute__((always_inline)) void _regi2c_ctrl_ll_master_reset(v
}
// LPPERI.reset_en is a shared register, so this function must be used in an atomic way
#define regi2c_ctrl_ll_master_reset(...) (void)__DECLARE_RCC_RC_ATOMIC_ENV; _regi2c_ctrl_ll_master_reset(__VA_ARGS__)
#define regi2c_ctrl_ll_master_reset(...) do { \
(void)__DECLARE_RCC_RC_ATOMIC_ENV; \
_regi2c_ctrl_ll_master_reset(__VA_ARGS__); \
} while(0)
/**
* @brief Configure analog I2C master clock