Merge branch 'bugfix/fix_lcd_ll_macro_safety' into 'master'

fix(hal): Wrap LL macros with atomic env in do-while for control safety

Closes IDF-11981

See merge request espressif/esp-idf!39202
This commit is contained in:
morris
2025-05-26 19:06:11 +08:00
162 changed files with 1741 additions and 499 deletions
@@ -67,7 +67,10 @@ static inline void _lp_clkrst_ll_enable_rng_clock(bool en)
}
/// LPPERI.clk_en is a shared register, so this function must be used in an atomic way
#define lp_clkrst_ll_enable_rng_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _lp_clkrst_ll_enable_rng_clock(__VA_ARGS__)
#define lp_clkrst_ll_enable_rng_clock(...) do { \
(void)__DECLARE_RCC_ATOMIC_ENV; \
_lp_clkrst_ll_enable_rng_clock(__VA_ARGS__); \
} while(0)
#ifdef __cplusplus
}
@@ -44,7 +44,10 @@ static inline void _rtcio_ll_enable_io_clock(bool enable)
}
}
#define rtcio_ll_enable_io_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _rtcio_ll_enable_io_clock(__VA_ARGS__)
#define rtcio_ll_enable_io_clock(...) do { \
(void)__DECLARE_RCC_ATOMIC_ENV; \
_rtcio_ll_enable_io_clock(__VA_ARGS__); \
} while(0)
/**
* @brief Select the rtcio function.
@@ -50,7 +50,10 @@ static inline void systimer_ll_enable_bus_clock(bool enable)
/// use a macro to wrap the function, force the caller to use it in a critical section
/// the critical section needs to declare the __DECLARE_RCC_RC_ATOMIC_ENV variable in advance
#define systimer_ll_enable_bus_clock(...) (void)__DECLARE_RCC_RC_ATOMIC_ENV; systimer_ll_enable_bus_clock(__VA_ARGS__)
#define systimer_ll_enable_bus_clock(...) do { \
(void)__DECLARE_RCC_RC_ATOMIC_ENV; \
systimer_ll_enable_bus_clock(__VA_ARGS__); \
} while(0)
/**
* @brief Reset the systimer module
@@ -65,7 +68,10 @@ static inline void systimer_ll_reset_register(void)
/// use a macro to wrap the function, force the caller to use it in a critical section
/// the critical section needs to declare the __DECLARE_RCC_RC_ATOMIC_ENV variable in advance
#define systimer_ll_reset_register(...) (void)__DECLARE_RCC_RC_ATOMIC_ENV; systimer_ll_reset_register(__VA_ARGS__)
#define systimer_ll_reset_register(...) do { \
(void)__DECLARE_RCC_RC_ATOMIC_ENV; \
systimer_ll_reset_register(__VA_ARGS__); \
} while(0)
/********************** ETM *****************************/
@@ -65,7 +65,10 @@ static inline void _timer_ll_enable_bus_clock(int group_id, bool enable)
/// use a macro to wrap the function, force the caller to use it in a critical section
/// the critical section needs to declare the __DECLARE_RCC_RC_ATOMIC_ENV variable in advance
#define timer_ll_enable_bus_clock(...) (void)__DECLARE_RCC_RC_ATOMIC_ENV; _timer_ll_enable_bus_clock(__VA_ARGS__)
#define timer_ll_enable_bus_clock(...) do { \
(void)__DECLARE_RCC_RC_ATOMIC_ENV; \
_timer_ll_enable_bus_clock(__VA_ARGS__); \
} while(0)
/**
* @brief Reset the timer group module
@@ -87,7 +90,10 @@ static inline void _timer_ll_reset_register(int group_id)
/// use a macro to wrap the function, force the caller to use it in a critical section
/// the critical section needs to declare the __DECLARE_RCC_RC_ATOMIC_ENV variable in advance
#define timer_ll_reset_register(...) (void)__DECLARE_RCC_RC_ATOMIC_ENV; _timer_ll_reset_register(__VA_ARGS__)
#define timer_ll_reset_register(...) do { \
(void)__DECLARE_RCC_RC_ATOMIC_ENV; \
_timer_ll_reset_register(__VA_ARGS__); \
} while(0)
/**
* @brief Set clock source for timer