From 18091976ec1a3391167a82446c17204d0430449f Mon Sep 17 00:00:00 2001 From: Yuan Yu Date: Thu, 22 May 2025 14:41:19 +0800 Subject: [PATCH] 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 --- components/hal/README.md | 10 ++- components/hal/esp32/include/hal/aes_ll.h | 12 +++- components/hal/esp32/include/hal/emac_ll.h | 10 ++- components/hal/esp32/include/hal/i2s_ll.h | 17 +++-- components/hal/esp32/include/hal/ledc_ll.h | 12 +++- components/hal/esp32/include/hal/mcpwm_ll.h | 12 +++- components/hal/esp32/include/hal/mpi_ll.h | 12 +++- components/hal/esp32/include/hal/pcnt_ll.h | 12 +++- components/hal/esp32/include/hal/rmt_ll.h | 12 +++- .../hal/esp32/include/hal/sdio_slave_ll.h | 10 ++- components/hal/esp32/include/hal/sdmmc_ll.h | 10 ++- components/hal/esp32/include/hal/sha_ll.h | 12 +++- components/hal/esp32/include/hal/spi_ll.h | 22 +++++-- components/hal/esp32/include/hal/timer_ll.h | 10 ++- components/hal/esp32/include/hal/twai_ll.h | 10 ++- components/hal/esp32/include/hal/uart_ll.h | 15 ++++- components/hal/esp32/include/hal/uhci_ll.h | 12 +++- components/hal/esp32c2/include/hal/adc_ll.h | 12 +++- components/hal/esp32c2/include/hal/ecc_ll.h | 12 +++- components/hal/esp32c2/include/hal/gdma_ll.h | 12 +++- components/hal/esp32c2/include/hal/ledc_ll.h | 12 +++- components/hal/esp32c2/include/hal/sha_ll.h | 12 +++- components/hal/esp32c2/include/hal/spi_ll.h | 12 +++- .../hal/esp32c2/include/hal/systimer_ll.h | 12 +++- components/hal/esp32c2/include/hal/timer_ll.h | 10 ++- components/hal/esp32c2/include/hal/uart_ll.h | 15 ++++- components/hal/esp32c3/include/hal/adc_ll.h | 12 +++- components/hal/esp32c3/include/hal/aes_ll.h | 12 +++- components/hal/esp32c3/include/hal/ds_ll.h | 12 +++- components/hal/esp32c3/include/hal/gdma_ll.h | 12 +++- components/hal/esp32c3/include/hal/hmac_ll.h | 12 +++- components/hal/esp32c3/include/hal/i2s_ll.h | 15 ++++- components/hal/esp32c3/include/hal/ledc_ll.h | 12 +++- components/hal/esp32c3/include/hal/mpi_ll.h | 12 +++- components/hal/esp32c3/include/hal/rmt_ll.h | 10 ++- components/hal/esp32c3/include/hal/sha_ll.h | 12 +++- components/hal/esp32c3/include/hal/spi_ll.h | 12 +++- .../hal/esp32c3/include/hal/systimer_ll.h | 12 +++- components/hal/esp32c3/include/hal/timer_ll.h | 10 ++- components/hal/esp32c3/include/hal/twai_ll.h | 10 ++- components/hal/esp32c3/include/hal/uart_ll.h | 15 ++++- components/hal/esp32c3/include/hal/uhci_ll.h | 10 ++- .../esp32c3/include/hal/usb_serial_jtag_ll.h | 12 +++- components/hal/esp32c5/include/hal/i2c_ll.h | 15 ++++- .../hal/esp32c5/include/hal/key_mgr_ll.h | 17 +++-- .../hal/esp32c5/include/hal/lp_core_ll.h | 10 ++- .../hal/esp32c5/include/hal/regi2c_ctrl_ll.h | 10 ++- .../hal/esp32c5/include/hal/rtc_io_ll.h | 5 +- .../hal/esp32c5/include/hal/systimer_ll.h | 12 +++- components/hal/esp32c5/include/hal/timer_ll.h | 10 ++- components/hal/esp32c5/include/hal/uart_ll.h | 15 ++++- components/hal/esp32c6/include/hal/i2c_ll.h | 15 ++++- .../hal/esp32c6/include/hal/lp_clkrst_ll.h | 7 +- .../hal/esp32c6/include/hal/regi2c_ctrl_ll.h | 10 ++- .../hal/esp32c6/include/hal/rtc_io_ll.h | 5 +- .../hal/esp32c6/include/hal/systimer_ll.h | 12 +++- components/hal/esp32c6/include/hal/timer_ll.h | 10 ++- components/hal/esp32c6/include/hal/uart_ll.h | 15 ++++- .../hal/esp32c61/include/hal/regi2c_ctrl_ll.h | 10 ++- .../hal/esp32c61/include/hal/rtc_io_ll.h | 5 +- .../hal/esp32c61/include/hal/systimer_ll.h | 12 +++- .../hal/esp32c61/include/hal/timer_ll.h | 10 ++- .../hal/esp32h2/include/hal/lp_clkrst_ll.h | 5 +- .../hal/esp32h2/include/hal/regi2c_ctrl_ll.h | 10 ++- .../hal/esp32h2/include/hal/rtc_io_ll.h | 5 +- .../hal/esp32h2/include/hal/systimer_ll.h | 12 +++- components/hal/esp32h2/include/hal/timer_ll.h | 10 ++- .../hal/esp32h21/include/hal/lp_clkrst_ll.h | 5 +- .../hal/esp32h21/include/hal/rtc_io_ll.h | 5 +- .../hal/esp32h21/include/hal/systimer_ll.h | 10 ++- .../hal/esp32h21/include/hal/timer_ll.h | 10 ++- .../hal/esp32h4/include/hal/systimer_ll.h | 10 ++- components/hal/esp32h4/include/hal/timer_ll.h | 10 ++- components/hal/esp32p4/include/hal/adc_ll.h | 20 ++++-- components/hal/esp32p4/include/hal/aes_ll.h | 12 +++- components/hal/esp32p4/include/hal/cam_ll.h | 32 +++++++-- .../hal/esp32p4/include/hal/clk_gate_ll.h | 35 ++++++++-- components/hal/esp32p4/include/hal/dma2d_ll.h | 10 ++- components/hal/esp32p4/include/hal/ds_ll.h | 12 +++- .../hal/esp32p4/include/hal/dw_gdma_ll.h | 10 ++- components/hal/esp32p4/include/hal/ecc_ll.h | 12 +++- components/hal/esp32p4/include/hal/ecdsa_ll.h | 7 +- components/hal/esp32p4/include/hal/emac_ll.h | 40 +++++++++--- components/hal/esp32p4/include/hal/etm_ll.h | 12 +++- components/hal/esp32p4/include/hal/gdma_ll.h | 10 ++- components/hal/esp32p4/include/hal/gpio_ll.h | 5 +- components/hal/esp32p4/include/hal/hmac_ll.h | 12 +++- components/hal/esp32p4/include/hal/i2c_ll.h | 15 ++++- components/hal/esp32p4/include/hal/i2s_ll.h | 65 +++++++++++++++---- components/hal/esp32p4/include/hal/isp_ll.h | 20 ++++-- components/hal/esp32p4/include/hal/jpeg_ll.h | 12 +++- .../hal/esp32p4/include/hal/key_mgr_ll.h | 17 +++-- components/hal/esp32p4/include/hal/l2mem_ll.h | 5 +- components/hal/esp32p4/include/hal/lcd_ll.h | 27 ++++++-- components/hal/esp32p4/include/hal/ledc_ll.h | 22 +++++-- .../hal/esp32p4/include/hal/lp_core_ll.h | 10 ++- .../hal/esp32p4/include/hal/lp_i2s_ll.h | 22 +++++-- components/hal/esp32p4/include/hal/mcpwm_ll.h | 27 ++++++-- .../hal/esp32p4/include/hal/mipi_csi_ll.h | 32 +++++++-- .../hal/esp32p4/include/hal/mipi_dsi_ll.h | 42 +++++++++--- components/hal/esp32p4/include/hal/mpi_ll.h | 12 +++- components/hal/esp32p4/include/hal/mspi_ll.h | 15 ++++- .../hal/esp32p4/include/hal/parlio_ll.h | 50 +++++++++++--- components/hal/esp32p4/include/hal/pau_ll.h | 7 +- components/hal/esp32p4/include/hal/pcnt_ll.h | 12 +++- components/hal/esp32p4/include/hal/ppa_ll.h | 12 +++- .../hal/esp32p4/include/hal/psram_ctrlr_ll.h | 27 ++++++-- .../hal/esp32p4/include/hal/regi2c_ctrl_ll.h | 10 ++- components/hal/esp32p4/include/hal/rmt_ll.h | 20 ++++-- .../hal/esp32p4/include/hal/rtc_io_ll.h | 5 +- components/hal/esp32p4/include/hal/sdmmc_ll.h | 35 ++++++++-- components/hal/esp32p4/include/hal/sha_ll.h | 12 +++- components/hal/esp32p4/include/hal/spi_ll.h | 25 +++++-- .../hal/esp32p4/include/hal/spimem_flash_ll.h | 5 +- .../hal/esp32p4/include/hal/systimer_ll.h | 17 +++-- components/hal/esp32p4/include/hal/timer_ll.h | 20 ++++-- components/hal/esp32p4/include/hal/twai_ll.h | 20 ++++-- components/hal/esp32p4/include/hal/uart_ll.h | 45 ++++++++++--- components/hal/esp32p4/include/hal/uhci_ll.h | 10 ++- .../esp32p4/include/hal/usb_serial_jtag_ll.h | 12 +++- .../hal/esp32p4/include/hal/usb_utmi_ll.h | 12 +++- .../hal/esp32p4/include/hal/usb_wrap_ll.h | 12 +++- components/hal/esp32s2/include/hal/adc_ll.h | 12 +++- components/hal/esp32s2/include/hal/aes_ll.h | 10 ++- .../hal/esp32s2/include/hal/crypto_dma_ll.h | 12 +++- .../hal/esp32s2/include/hal/dedic_gpio_ll.h | 12 +++- components/hal/esp32s2/include/hal/i2s_ll.h | 17 +++-- components/hal/esp32s2/include/hal/ledc_ll.h | 12 +++- components/hal/esp32s2/include/hal/mpi_ll.h | 12 +++- components/hal/esp32s2/include/hal/pcnt_ll.h | 12 +++- components/hal/esp32s2/include/hal/rmt_ll.h | 12 +++- components/hal/esp32s2/include/hal/sha_ll.h | 10 ++- components/hal/esp32s2/include/hal/spi_ll.h | 22 +++++-- .../hal/esp32s2/include/hal/systimer_ll.h | 12 +++- components/hal/esp32s2/include/hal/timer_ll.h | 10 ++- components/hal/esp32s2/include/hal/twai_ll.h | 10 ++- components/hal/esp32s2/include/hal/uart_ll.h | 15 ++++- .../hal/esp32s2/include/hal/usb_wrap_ll.h | 12 +++- components/hal/esp32s3/include/hal/adc_ll.h | 12 +++- components/hal/esp32s3/include/hal/aes_ll.h | 12 +++- .../hal/esp32s3/include/hal/dedic_gpio_ll.h | 12 +++- components/hal/esp32s3/include/hal/ds_ll.h | 12 +++- components/hal/esp32s3/include/hal/gdma_ll.h | 12 +++- components/hal/esp32s3/include/hal/hmac_ll.h | 12 +++- components/hal/esp32s3/include/hal/i2s_ll.h | 15 ++++- components/hal/esp32s3/include/hal/lcd_ll.h | 12 +++- components/hal/esp32s3/include/hal/ledc_ll.h | 12 +++- components/hal/esp32s3/include/hal/mcpwm_ll.h | 12 +++- components/hal/esp32s3/include/hal/mpi_ll.h | 12 +++- components/hal/esp32s3/include/hal/pcnt_ll.h | 12 +++- components/hal/esp32s3/include/hal/rmt_ll.h | 10 ++- components/hal/esp32s3/include/hal/sdmmc_ll.h | 10 ++- components/hal/esp32s3/include/hal/sha_ll.h | 12 +++- components/hal/esp32s3/include/hal/spi_ll.h | 12 +++- .../hal/esp32s3/include/hal/systimer_ll.h | 12 +++- components/hal/esp32s3/include/hal/timer_ll.h | 10 ++- components/hal/esp32s3/include/hal/twai_ll.h | 10 ++- components/hal/esp32s3/include/hal/uart_ll.h | 15 ++++- components/hal/esp32s3/include/hal/uhci_ll.h | 10 ++- .../esp32s3/include/hal/usb_serial_jtag_ll.h | 12 +++- .../hal/esp32s3/include/hal/usb_wrap_ll.h | 12 +++- components/hal/include/hal/i2s_hal.h | 10 ++- 162 files changed, 1742 insertions(+), 500 deletions(-) diff --git a/components/hal/README.md b/components/hal/README.md index 3f7f0e79f3..f0e0163904 100644 --- a/components/hal/README.md +++ b/components/hal/README.md @@ -19,11 +19,17 @@ One compromise is to **highlight** the LL function which needs the caller to use ```c /// 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) /// 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_ATOMIC_ENV variable in advance -#define timer_ll_set_clock_source(...) (void)__DECLARE_RCC_ATOMIC_ENV; timer_ll_set_clock_source(__VA_ARGS__) +#define timer_ll_set_clock_source(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + timer_ll_set_clock_source(__VA_ARGS__); \ + } while(0) ``` By referencing a variable which is only declared in the critical section, the compiler will report an error if the caller forgets to use the critical section. The following macros are provided by `esp_private/periph_ctrl.h`, which contain the above *magic* variables. diff --git a/components/hal/esp32/include/hal/aes_ll.h b/components/hal/esp32/include/hal/aes_ll.h index e3e31a2e9f..aaf3467c17 100644 --- a/components/hal/esp32/include/hal/aes_ll.h +++ b/components/hal/esp32/include/hal/aes_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -43,7 +43,10 @@ static inline void aes_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_ATOMIC_ENV variable in advance -#define aes_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; aes_ll_enable_bus_clock(__VA_ARGS__) +#define aes_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + aes_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the AES peripheral module @@ -60,7 +63,10 @@ static inline void aes_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_ATOMIC_ENV variable in advance -#define aes_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; aes_ll_reset_register(__VA_ARGS__) +#define aes_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + aes_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * @brief Write the encryption/decryption key to hardware diff --git a/components/hal/esp32/include/hal/emac_ll.h b/components/hal/esp32/include/hal/emac_ll.h index 76ff9b0404..ae31a2ce4b 100644 --- a/components/hal/esp32/include/hal/emac_ll.h +++ b/components/hal/esp32/include/hal/emac_ll.h @@ -150,7 +150,10 @@ static inline void emac_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_ATOMIC_ENV variable in advance -#define emac_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; emac_ll_enable_bus_clock(__VA_ARGS__) +#define emac_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + emac_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the EMAC module @@ -166,7 +169,10 @@ static inline void emac_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_ATOMIC_ENV variable in advance -#define emac_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; emac_ll_reset_register(__VA_ARGS__) +#define emac_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + emac_ll_reset_register(__VA_ARGS__); \ + } while(0) /************** Start of mac regs operation ********************/ /* emacgmiiaddr */ diff --git a/components/hal/esp32/include/hal/i2s_ll.h b/components/hal/esp32/include/hal/i2s_ll.h index f83bd01f33..59d686f2c2 100644 --- a/components/hal/esp32/include/hal/i2s_ll.h +++ b/components/hal/esp32/include/hal/i2s_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -109,7 +109,10 @@ static inline void i2s_ll_enable_bus_clock(int i2s_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_ATOMIC_ENV variable in advance -#define i2s_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; i2s_ll_enable_bus_clock(__VA_ARGS__) +#define i2s_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + i2s_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** @@ -130,7 +133,10 @@ static inline void i2s_ll_reset_register(int i2s_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_ATOMIC_ENV variable in advance -#define i2s_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; i2s_ll_reset_register(__VA_ARGS__) +#define i2s_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + i2s_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * @brief I2S module general init, enable I2S clock. @@ -150,7 +156,10 @@ static inline void i2s_ll_enable_core_clock(i2s_dev_t *hw, 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_ATOMIC_ENV variable in advance -#define i2s_ll_enable_core_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; i2s_ll_enable_core_clock(__VA_ARGS__) +#define i2s_ll_enable_core_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + i2s_ll_enable_core_clock(__VA_ARGS__); \ + } while(0) /** * @brief I2S tx msb right enable diff --git a/components/hal/esp32/include/hal/ledc_ll.h b/components/hal/esp32/include/hal/ledc_ll.h index 0e5b1f7fa8..9f98ecc72a 100644 --- a/components/hal/esp32/include/hal/ledc_ll.h +++ b/components/hal/esp32/include/hal/ledc_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2019-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2019-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -57,7 +57,10 @@ static inline void ledc_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_ATOMIC_ENV variable in advance -#define ledc_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; ledc_ll_enable_bus_clock(__VA_ARGS__) +#define ledc_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + ledc_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset whole peripheral register to init value defined by HW design @@ -73,7 +76,10 @@ static inline void ledc_ll_enable_reset_reg(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_ATOMIC_ENV variable in advance -#define ledc_ll_enable_reset_reg(...) (void)__DECLARE_RCC_ATOMIC_ENV; ledc_ll_enable_reset_reg(__VA_ARGS__) +#define ledc_ll_enable_reset_reg(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + ledc_ll_enable_reset_reg(__VA_ARGS__); \ + } while(0) /** * @brief Enable the power for LEDC memory block diff --git a/components/hal/esp32/include/hal/mcpwm_ll.h b/components/hal/esp32/include/hal/mcpwm_ll.h index 3aef65d877..d88a2253ea 100644 --- a/components/hal/esp32/include/hal/mcpwm_ll.h +++ b/components/hal/esp32/include/hal/mcpwm_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -89,7 +89,10 @@ static inline void mcpwm_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_ATOMIC_ENV variable in advance -#define mcpwm_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; mcpwm_ll_enable_bus_clock(__VA_ARGS__) +#define mcpwm_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + mcpwm_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the MCPWM module @@ -109,7 +112,10 @@ static inline void mcpwm_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_ATOMIC_ENV variable in advance -#define mcpwm_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; mcpwm_ll_reset_register(__VA_ARGS__) +#define mcpwm_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + mcpwm_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * @brief Enable MCPWM function clock diff --git a/components/hal/esp32/include/hal/mpi_ll.h b/components/hal/esp32/include/hal/mpi_ll.h index a6b9bdfb6c..75a2515ae1 100644 --- a/components/hal/esp32/include/hal/mpi_ll.h +++ b/components/hal/esp32/include/hal/mpi_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -35,7 +35,10 @@ static inline void mpi_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_ATOMIC_ENV variable in advance -#define mpi_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; mpi_ll_enable_bus_clock(__VA_ARGS__) +#define mpi_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + mpi_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the MPI peripheral module @@ -51,7 +54,10 @@ static inline void mpi_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_ATOMIC_ENV variable in advance -#define mpi_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; mpi_ll_reset_register(__VA_ARGS__) +#define mpi_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + mpi_ll_reset_register(__VA_ARGS__); \ + } while(0) /* Round up number of words to nearest 512 bit (16 word) block count. diff --git a/components/hal/esp32/include/hal/pcnt_ll.h b/components/hal/esp32/include/hal/pcnt_ll.h index 066c3d9763..612611fa70 100644 --- a/components/hal/esp32/include/hal/pcnt_ll.h +++ b/components/hal/esp32/include/hal/pcnt_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -457,7 +457,10 @@ static inline void pcnt_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_ATOMIC_ENV variable in advance -#define pcnt_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; pcnt_ll_enable_bus_clock(__VA_ARGS__) +#define pcnt_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + pcnt_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the PCNT module @@ -471,7 +474,10 @@ static inline void pcnt_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_ATOMIC_ENV variable in advance -#define pcnt_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; pcnt_ll_reset_register(__VA_ARGS__) +#define pcnt_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + pcnt_ll_reset_register(__VA_ARGS__); \ + } while(0) #ifdef __cplusplus } diff --git a/components/hal/esp32/include/hal/rmt_ll.h b/components/hal/esp32/include/hal/rmt_ll.h index 2f86a0c21d..6edb851956 100644 --- a/components/hal/esp32/include/hal/rmt_ll.h +++ b/components/hal/esp32/include/hal/rmt_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2019-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2019-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -58,7 +58,10 @@ static inline void rmt_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_ATOMIC_ENV variable in advance -#define rmt_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; rmt_ll_enable_bus_clock(__VA_ARGS__) +#define rmt_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + rmt_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the RMT module @@ -74,7 +77,10 @@ static inline void rmt_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_ATOMIC_ENV variable in advance -#define rmt_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; rmt_ll_reset_register(__VA_ARGS__) +#define rmt_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + rmt_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * @brief Enable clock gate for register and memory diff --git a/components/hal/esp32/include/hal/sdio_slave_ll.h b/components/hal/esp32/include/hal/sdio_slave_ll.h index 0c06500b64..0b47fd8a40 100644 --- a/components/hal/esp32/include/hal/sdio_slave_ll.h +++ b/components/hal/esp32/include/hal/sdio_slave_ll.h @@ -92,7 +92,10 @@ static inline void _sdio_slave_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_ATOMIC_ENV variable in advance -#define sdio_slave_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _sdio_slave_ll_enable_bus_clock(__VA_ARGS__) +#define sdio_slave_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _sdio_slave_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the SDIO slave module @@ -105,7 +108,10 @@ static inline void _sdio_slave_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_ATOMIC_ENV variable in advance -#define sdio_slave_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; _sdio_slave_ll_reset_register(__VA_ARGS__) +#define sdio_slave_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _sdio_slave_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * Initialize the hardware. diff --git a/components/hal/esp32/include/hal/sdmmc_ll.h b/components/hal/esp32/include/hal/sdmmc_ll.h index 225d4d8a67..7c94bded11 100644 --- a/components/hal/esp32/include/hal/sdmmc_ll.h +++ b/components/hal/esp32/include/hal/sdmmc_ll.h @@ -116,7 +116,10 @@ static inline void sdmmc_ll_enable_bus_clock(int group_id, bool en) /// 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_ATOMIC_ENV variable in advance -#define sdmmc_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; sdmmc_ll_enable_bus_clock(__VA_ARGS__) +#define sdmmc_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + sdmmc_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the SDMMC module @@ -132,7 +135,10 @@ static inline void sdmmc_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_ATOMIC_ENV variable in advance -#define sdmmc_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; sdmmc_ll_reset_register(__VA_ARGS__) +#define sdmmc_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + sdmmc_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * @brief Select SDMMC clock source diff --git a/components/hal/esp32/include/hal/sha_ll.h b/components/hal/esp32/include/hal/sha_ll.h index f321c2be09..600baa1c63 100644 --- a/components/hal/esp32/include/hal/sha_ll.h +++ b/components/hal/esp32/include/hal/sha_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -34,7 +34,10 @@ static inline void sha_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_ATOMIC_ENV variable in advance -#define sha_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; sha_ll_enable_bus_clock(__VA_ARGS__) +#define sha_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + sha_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the SHA peripheral module @@ -50,7 +53,10 @@ static inline void sha_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_ATOMIC_ENV variable in advance -#define sha_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; sha_ll_reset_register(__VA_ARGS__) +#define sha_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + sha_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * @brief Returns the LOAD_REG register address for the given sha type diff --git a/components/hal/esp32/include/hal/spi_ll.h b/components/hal/esp32/include/hal/spi_ll.h index dbcbb22d69..c8cb57dcb9 100644 --- a/components/hal/esp32/include/hal/spi_ll.h +++ b/components/hal/esp32/include/hal/spi_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -99,7 +99,10 @@ static inline void spi_ll_enable_bus_clock(spi_host_device_t host_id, bool enabl /// 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_ATOMIC_ENV variable in advance -#define spi_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; spi_ll_enable_bus_clock(__VA_ARGS__) +#define spi_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + spi_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * Reset whole peripheral register to init value defined by HW design @@ -127,7 +130,10 @@ static inline void spi_ll_reset_register(spi_host_device_t host_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_ATOMIC_ENV variable in advance -#define spi_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; spi_ll_reset_register(__VA_ARGS__) +#define spi_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + spi_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * Enable functional output clock within peripheral @@ -1098,7 +1104,10 @@ static inline void spi_dma_ll_enable_bus_clock(spi_host_device_t host_id, bool e /// 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_ATOMIC_ENV variable in advance -#define spi_dma_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; spi_dma_ll_enable_bus_clock(__VA_ARGS__) +#define spi_dma_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + spi_dma_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * Reset whole peripheral register to init value defined by HW design @@ -1115,7 +1124,10 @@ static inline void spi_dma_ll_reset_register(spi_host_device_t host_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_ATOMIC_ENV variable in advance -#define spi_dma_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; spi_dma_ll_reset_register(__VA_ARGS__) +#define spi_dma_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + spi_dma_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * Reset RX DMA which stores the data received from a peripheral into RAM. diff --git a/components/hal/esp32/include/hal/timer_ll.h b/components/hal/esp32/include/hal/timer_ll.h index 29bd9fd64f..8c727da15e 100644 --- a/components/hal/esp32/include/hal/timer_ll.h +++ b/components/hal/esp32/include/hal/timer_ll.h @@ -45,7 +45,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 @@ -71,7 +74,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 diff --git a/components/hal/esp32/include/hal/twai_ll.h b/components/hal/esp32/include/hal/twai_ll.h index 092c53c8ee..26585c7995 100644 --- a/components/hal/esp32/include/hal/twai_ll.h +++ b/components/hal/esp32/include/hal/twai_ll.h @@ -177,7 +177,10 @@ static inline void twai_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_ATOMIC_ENV variable in advance -#define twai_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; twai_ll_enable_bus_clock(__VA_ARGS__) +#define twai_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + twai_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the twai module @@ -194,7 +197,10 @@ static inline void twai_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_ATOMIC_ENV variable in advance -#define twai_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; twai_ll_reset_register(__VA_ARGS__) +#define twai_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + twai_ll_reset_register(__VA_ARGS__); \ + } while(0) /* ---------------------------- Peripheral Control Register ----------------- */ diff --git a/components/hal/esp32/include/hal/uart_ll.h b/components/hal/esp32/include/hal/uart_ll.h index e7592bc5c4..75d0d781c7 100644 --- a/components/hal/esp32/include/hal/uart_ll.h +++ b/components/hal/esp32/include/hal/uart_ll.h @@ -107,7 +107,10 @@ static inline void uart_ll_enable_bus_clock(uart_port_t uart_num, bool enable) } DPORT_WRITE_PERI_REG(DPORT_PERIP_CLK_EN_REG, reg_val); } -#define uart_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; uart_ll_enable_bus_clock(__VA_ARGS__) +#define uart_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + uart_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset UART module @@ -134,7 +137,10 @@ static inline void uart_ll_reset_register(uart_port_t uart_num) } } // SYSTEM.perip_rst_enx are shared registers, so this function must be used in an atomic way -#define uart_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; uart_ll_reset_register(__VA_ARGS__) +#define uart_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + uart_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * @brief Enable the UART clock. @@ -745,7 +751,10 @@ FORCE_INLINE_ATTR void _uart_ll_enable_pad_sleep_clock(uart_dev_t *hw, bool enab (void)hw; (void)enable; } -#define uart_ll_enable_pad_sleep_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _uart_ll_enable_pad_sleep_clock(__VA_ARGS__) +#define uart_ll_enable_pad_sleep_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _uart_ll_enable_pad_sleep_clock(__VA_ARGS__); \ + } while(0) /** * @brief Configure the UART work in normal mode. diff --git a/components/hal/esp32/include/hal/uhci_ll.h b/components/hal/esp32/include/hal/uhci_ll.h index c6c1b84e10..e0678063a8 100644 --- a/components/hal/esp32/include/hal/uhci_ll.h +++ b/components/hal/esp32/include/hal/uhci_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -38,7 +38,10 @@ static inline void _uhci_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_ATOMIC_ENV variable in advance -#define uhci_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _uhci_ll_enable_bus_clock(__VA_ARGS__) +#define uhci_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _uhci_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the UHCI module @@ -58,7 +61,10 @@ static inline void _uhci_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_ATOMIC_ENV variable in advance -#define uhci_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; _uhci_ll_reset_register(__VA_ARGS__) +#define uhci_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _uhci_ll_reset_register(__VA_ARGS__); \ + } while(0) #ifdef __cplusplus } diff --git a/components/hal/esp32c2/include/hal/adc_ll.h b/components/hal/esp32c2/include/hal/adc_ll.h index 2e234d740c..765e9cfb94 100644 --- a/components/hal/esp32c2/include/hal/adc_ll.h +++ b/components/hal/esp32c2/include/hal/adc_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -297,7 +297,10 @@ static inline void adc_ll_enable_bus_clock(bool enable) SYSTEM.perip_clk_en0.apb_saradc_clk_en = enable; } // SYSTEM.perip_clk_en0 is a shared register, so this function must be used in an atomic way -#define adc_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; adc_ll_enable_bus_clock(__VA_ARGS__) +#define adc_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + adc_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset ADC module @@ -308,7 +311,10 @@ static inline void adc_ll_reset_register(void) SYSTEM.perip_rst_en0.apb_saradc_rst = 0; } // SYSTEM.perip_rst_en0 is a shared register, so this function must be used in an atomic way -#define adc_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; adc_ll_reset_register(__VA_ARGS__) +#define adc_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + adc_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * Set ADC module power management. diff --git a/components/hal/esp32c2/include/hal/ecc_ll.h b/components/hal/esp32c2/include/hal/ecc_ll.h index ca84307425..efe4285061 100644 --- a/components/hal/esp32c2/include/hal/ecc_ll.h +++ b/components/hal/esp32c2/include/hal/ecc_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -34,7 +34,10 @@ static inline void ecc_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_ATOMIC_ENV variable in advance -#define ecc_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; ecc_ll_enable_bus_clock(__VA_ARGS__) +#define ecc_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + ecc_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the ECC peripheral module @@ -47,7 +50,10 @@ static inline void ecc_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_ATOMIC_ENV variable in advance -#define ecc_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; ecc_ll_reset_register(__VA_ARGS__) +#define ecc_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + ecc_ll_reset_register(__VA_ARGS__); \ + } while(0) static inline void ecc_ll_power_up(void) {} static inline void ecc_ll_power_down(void) {} diff --git a/components/hal/esp32c2/include/hal/gdma_ll.h b/components/hal/esp32c2/include/hal/gdma_ll.h index ee877d5b3e..857502bbe6 100644 --- a/components/hal/esp32c2/include/hal/gdma_ll.h +++ b/components/hal/esp32c2/include/hal/gdma_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -63,7 +63,10 @@ static inline void _gdma_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_ATOMIC_ENV variable in advance -#define gdma_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _gdma_ll_enable_bus_clock(__VA_ARGS__) +#define gdma_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _gdma_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the DMA module @@ -77,7 +80,10 @@ static inline void _gdma_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_ATOMIC_ENV variable in advance -#define gdma_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; _gdma_ll_reset_register(__VA_ARGS__) +#define gdma_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _gdma_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * @brief Force enable register clock diff --git a/components/hal/esp32c2/include/hal/ledc_ll.h b/components/hal/esp32c2/include/hal/ledc_ll.h index 3849494743..0470664986 100644 --- a/components/hal/esp32c2/include/hal/ledc_ll.h +++ b/components/hal/esp32c2/include/hal/ledc_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -47,7 +47,10 @@ static inline void ledc_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_ATOMIC_ENV variable in advance -#define ledc_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; ledc_ll_enable_bus_clock(__VA_ARGS__) +#define ledc_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + ledc_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset whole peripheral register to init value defined by HW design @@ -59,7 +62,10 @@ static inline void ledc_ll_enable_reset_reg(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_ATOMIC_ENV variable in advance -#define ledc_ll_enable_reset_reg(...) (void)__DECLARE_RCC_ATOMIC_ENV; ledc_ll_enable_reset_reg(__VA_ARGS__) +#define ledc_ll_enable_reset_reg(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + ledc_ll_enable_reset_reg(__VA_ARGS__); \ + } while(0) /** * @brief Enable the power for LEDC memory block diff --git a/components/hal/esp32c2/include/hal/sha_ll.h b/components/hal/esp32c2/include/hal/sha_ll.h index 4877e4ba55..37d8ed0c77 100644 --- a/components/hal/esp32c2/include/hal/sha_ll.h +++ b/components/hal/esp32c2/include/hal/sha_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -27,7 +27,10 @@ static inline void sha_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_ATOMIC_ENV variable in advance -#define sha_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; sha_ll_enable_bus_clock(__VA_ARGS__) +#define sha_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + sha_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the SHA peripheral module @@ -40,7 +43,10 @@ static inline void sha_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_ATOMIC_ENV variable in advance -#define sha_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; sha_ll_reset_register(__VA_ARGS__) +#define sha_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + sha_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * @brief Start a new SHA block conversions (no initial hash in HW) diff --git a/components/hal/esp32c2/include/hal/spi_ll.h b/components/hal/esp32c2/include/hal/spi_ll.h index 68cac82ca7..cff322be05 100644 --- a/components/hal/esp32c2/include/hal/spi_ll.h +++ b/components/hal/esp32c2/include/hal/spi_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -112,7 +112,10 @@ static inline void spi_ll_enable_bus_clock(spi_host_device_t host_id, bool enabl /// 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_ATOMIC_ENV variable in advance -#define spi_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; spi_ll_enable_bus_clock(__VA_ARGS__) +#define spi_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + spi_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * Reset whole peripheral register to init value defined by HW design @@ -136,7 +139,10 @@ static inline void spi_ll_reset_register(spi_host_device_t host_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_ATOMIC_ENV variable in advance -#define spi_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; spi_ll_reset_register(__VA_ARGS__) +#define spi_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + spi_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * Enable functional output clock within peripheral diff --git a/components/hal/esp32c2/include/hal/systimer_ll.h b/components/hal/esp32c2/include/hal/systimer_ll.h index 5bcc86cdd8..138949d210 100644 --- a/components/hal/esp32c2/include/hal/systimer_ll.h +++ b/components/hal/esp32c2/include/hal/systimer_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -48,7 +48,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 @@ -63,7 +66,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) /******************* Counter *************************/ diff --git a/components/hal/esp32c2/include/hal/timer_ll.h b/components/hal/esp32c2/include/hal/timer_ll.h index c9012917fb..6e9430b95d 100644 --- a/components/hal/esp32c2/include/hal/timer_ll.h +++ b/components/hal/esp32c2/include/hal/timer_ll.h @@ -38,7 +38,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 @@ -59,7 +62,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 diff --git a/components/hal/esp32c2/include/hal/uart_ll.h b/components/hal/esp32c2/include/hal/uart_ll.h index d5c709b5ee..ed1fa16282 100644 --- a/components/hal/esp32c2/include/hal/uart_ll.h +++ b/components/hal/esp32c2/include/hal/uart_ll.h @@ -100,7 +100,10 @@ static inline void uart_ll_enable_bus_clock(uart_port_t uart_num, bool enable) } } // SYSTEM.perip_clk_en0 is a shared register, so this function must be used in an atomic way -#define uart_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; uart_ll_enable_bus_clock(__VA_ARGS__) +#define uart_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + uart_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset UART module @@ -123,7 +126,10 @@ static inline void uart_ll_reset_register(uart_port_t uart_num) } } // SYSTEM.perip_rst_en0 is a shared register, so this function must be used in an atomic way -#define uart_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; uart_ll_reset_register(__VA_ARGS__) +#define uart_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + uart_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * @brief Enable the UART clock. @@ -705,7 +711,10 @@ FORCE_INLINE_ATTR void _uart_ll_enable_pad_sleep_clock(uart_dev_t *hw, bool enab (void)hw; (void)enable; } -#define uart_ll_enable_pad_sleep_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _uart_ll_enable_pad_sleep_clock(__VA_ARGS__) +#define uart_ll_enable_pad_sleep_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _uart_ll_enable_pad_sleep_clock(__VA_ARGS__); \ + } while(0) /** * @brief Configure the UART work in normal mode. diff --git a/components/hal/esp32c3/include/hal/adc_ll.h b/components/hal/esp32c3/include/hal/adc_ll.h index 779312f4fa..5fb1142717 100644 --- a/components/hal/esp32c3/include/hal/adc_ll.h +++ b/components/hal/esp32c3/include/hal/adc_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -571,7 +571,10 @@ static inline void adc_ll_enable_bus_clock(bool enable) SYSTEM.perip_clk_en0.reg_apb_saradc_clk_en = enable; } // SYSTEM.perip_clk_en0 is a shared register, so this function must be used in an atomic way -#define adc_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; adc_ll_enable_bus_clock(__VA_ARGS__) +#define adc_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + adc_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset ADC module @@ -582,7 +585,10 @@ static inline void adc_ll_reset_register(void) SYSTEM.perip_rst_en0.reg_apb_saradc_rst = 0; } // SYSTEM.perip_rst_en0 is a shared register, so this function must be used in an atomic way -#define adc_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; adc_ll_reset_register(__VA_ARGS__) +#define adc_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + adc_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * Set ADC module power management. diff --git a/components/hal/esp32c3/include/hal/aes_ll.h b/components/hal/esp32c3/include/hal/aes_ll.h index 18c2e1df18..1ebb5ee2a7 100644 --- a/components/hal/esp32c3/include/hal/aes_ll.h +++ b/components/hal/esp32c3/include/hal/aes_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -38,7 +38,10 @@ static inline void aes_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_ATOMIC_ENV variable in advance -#define aes_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; aes_ll_enable_bus_clock(__VA_ARGS__) +#define aes_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + aes_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the AES peripheral module @@ -54,7 +57,10 @@ static inline void aes_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_ATOMIC_ENV variable in advance -#define aes_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; aes_ll_reset_register(__VA_ARGS__) +#define aes_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + aes_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * @brief Write the encryption/decryption key to hardware diff --git a/components/hal/esp32c3/include/hal/ds_ll.h b/components/hal/esp32c3/include/hal/ds_ll.h index d53e5f494f..ac12b9bee3 100644 --- a/components/hal/esp32c3/include/hal/ds_ll.h +++ b/components/hal/esp32c3/include/hal/ds_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -36,7 +36,10 @@ static inline void ds_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_ATOMIC_ENV variable in advance -#define ds_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; ds_ll_enable_bus_clock(__VA_ARGS__) +#define ds_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + ds_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the Digital Signature peripheral module @@ -49,7 +52,10 @@ static inline void ds_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_ATOMIC_ENV variable in advance -#define ds_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; ds_ll_reset_register(__VA_ARGS__) +#define ds_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + ds_ll_reset_register(__VA_ARGS__); \ + } while(0) static inline void ds_ll_start(void) { diff --git a/components/hal/esp32c3/include/hal/gdma_ll.h b/components/hal/esp32c3/include/hal/gdma_ll.h index f7b3147e4d..1db8eaa220 100644 --- a/components/hal/esp32c3/include/hal/gdma_ll.h +++ b/components/hal/esp32c3/include/hal/gdma_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -63,7 +63,10 @@ static inline void _gdma_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_ATOMIC_ENV variable in advance -#define gdma_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _gdma_ll_enable_bus_clock(__VA_ARGS__) +#define gdma_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _gdma_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the DMA module @@ -77,7 +80,10 @@ static inline void _gdma_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_ATOMIC_ENV variable in advance -#define gdma_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; _gdma_ll_reset_register(__VA_ARGS__) +#define gdma_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _gdma_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * @brief Force enable register clock diff --git a/components/hal/esp32c3/include/hal/hmac_ll.h b/components/hal/esp32c3/include/hal/hmac_ll.h index 4e7fcec171..7992d30055 100644 --- a/components/hal/esp32c3/include/hal/hmac_ll.h +++ b/components/hal/esp32c3/include/hal/hmac_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -44,7 +44,10 @@ static inline void hmac_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_ATOMIC_ENV variable in advance -#define hmac_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; hmac_ll_enable_bus_clock(__VA_ARGS__) +#define hmac_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + hmac_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the HMAC peripheral module @@ -57,7 +60,10 @@ static inline void hmac_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_ATOMIC_ENV variable in advance -#define hmac_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; hmac_ll_reset_register(__VA_ARGS__) +#define hmac_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + hmac_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * Makes the peripheral ready for use, after enabling it. diff --git a/components/hal/esp32c3/include/hal/i2s_ll.h b/components/hal/esp32c3/include/hal/i2s_ll.h index f9aade9cc1..9796935b53 100644 --- a/components/hal/esp32c3/include/hal/i2s_ll.h +++ b/components/hal/esp32c3/include/hal/i2s_ll.h @@ -53,7 +53,10 @@ static inline void i2s_ll_enable_bus_clock(int i2s_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_ATOMIC_ENV variable in advance -#define i2s_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; i2s_ll_enable_bus_clock(__VA_ARGS__) +#define i2s_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + i2s_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** @@ -70,7 +73,10 @@ static inline void i2s_ll_reset_register(int i2s_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_ATOMIC_ENV variable in advance -#define i2s_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; i2s_ll_reset_register(__VA_ARGS__) +#define i2s_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + i2s_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * @brief I2S module general init, enable I2S clock. @@ -85,7 +91,10 @@ static inline void i2s_ll_enable_core_clock(i2s_dev_t *hw, 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_ATOMIC_ENV variable in advance -#define i2s_ll_enable_core_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; i2s_ll_enable_core_clock(__VA_ARGS__) +#define i2s_ll_enable_core_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + i2s_ll_enable_core_clock(__VA_ARGS__); \ + } while(0) /** * @brief Enable I2S tx module clock diff --git a/components/hal/esp32c3/include/hal/ledc_ll.h b/components/hal/esp32c3/include/hal/ledc_ll.h index 7d6fd942c5..f96582f614 100644 --- a/components/hal/esp32c3/include/hal/ledc_ll.h +++ b/components/hal/esp32c3/include/hal/ledc_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -48,7 +48,10 @@ static inline void ledc_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_ATOMIC_ENV variable in advance -#define ledc_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; ledc_ll_enable_bus_clock(__VA_ARGS__) +#define ledc_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + ledc_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset whole peripheral register to init value defined by HW design @@ -60,7 +63,10 @@ static inline void ledc_ll_enable_reset_reg(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_ATOMIC_ENV variable in advance -#define ledc_ll_enable_reset_reg(...) (void)__DECLARE_RCC_ATOMIC_ENV; ledc_ll_enable_reset_reg(__VA_ARGS__) +#define ledc_ll_enable_reset_reg(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + ledc_ll_enable_reset_reg(__VA_ARGS__); \ + } while(0) /** * @brief Enable the power for LEDC memory block diff --git a/components/hal/esp32c3/include/hal/mpi_ll.h b/components/hal/esp32c3/include/hal/mpi_ll.h index 9b47ac30b7..faefd7496d 100644 --- a/components/hal/esp32c3/include/hal/mpi_ll.h +++ b/components/hal/esp32c3/include/hal/mpi_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -32,7 +32,10 @@ static inline void mpi_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_ATOMIC_ENV variable in advance -#define mpi_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; mpi_ll_enable_bus_clock(__VA_ARGS__) +#define mpi_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + mpi_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the MPI peripheral module @@ -48,7 +51,10 @@ static inline void mpi_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_ATOMIC_ENV variable in advance -#define mpi_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; mpi_ll_reset_register(__VA_ARGS__) +#define mpi_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + mpi_ll_reset_register(__VA_ARGS__); \ + } while(0) static inline size_t mpi_ll_calculate_hardware_words(size_t words) { diff --git a/components/hal/esp32c3/include/hal/rmt_ll.h b/components/hal/esp32c3/include/hal/rmt_ll.h index 0d829b3569..eac3113e63 100644 --- a/components/hal/esp32c3/include/hal/rmt_ll.h +++ b/components/hal/esp32c3/include/hal/rmt_ll.h @@ -61,7 +61,10 @@ static inline void rmt_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_ATOMIC_ENV variable in advance -#define rmt_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; rmt_ll_enable_bus_clock(__VA_ARGS__) +#define rmt_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + rmt_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the RMT module @@ -77,7 +80,10 @@ static inline void rmt_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_ATOMIC_ENV variable in advance -#define rmt_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; rmt_ll_reset_register(__VA_ARGS__) +#define rmt_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + rmt_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * @brief Enable clock gate for register and memory diff --git a/components/hal/esp32c3/include/hal/sha_ll.h b/components/hal/esp32c3/include/hal/sha_ll.h index 4ad996b59f..c83d74bd1c 100644 --- a/components/hal/esp32c3/include/hal/sha_ll.h +++ b/components/hal/esp32c3/include/hal/sha_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -26,7 +26,10 @@ static inline void sha_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_ATOMIC_ENV variable in advance -#define sha_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; sha_ll_enable_bus_clock(__VA_ARGS__) +#define sha_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + sha_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the SHA peripheral module @@ -43,7 +46,10 @@ static inline void sha_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_ATOMIC_ENV variable in advance -#define sha_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; sha_ll_reset_register(__VA_ARGS__) +#define sha_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + sha_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * @brief Start a new SHA block conversions (no initial hash in HW) diff --git a/components/hal/esp32c3/include/hal/spi_ll.h b/components/hal/esp32c3/include/hal/spi_ll.h index 998e19c5cf..a7fe606151 100644 --- a/components/hal/esp32c3/include/hal/spi_ll.h +++ b/components/hal/esp32c3/include/hal/spi_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -114,7 +114,10 @@ static inline void spi_ll_enable_bus_clock(spi_host_device_t host_id, bool enabl /// 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_ATOMIC_ENV variable in advance -#define spi_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; spi_ll_enable_bus_clock(__VA_ARGS__) +#define spi_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + spi_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * Reset whole peripheral register to init value defined by HW design @@ -138,7 +141,10 @@ static inline void spi_ll_reset_register(spi_host_device_t host_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_ATOMIC_ENV variable in advance -#define spi_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; spi_ll_reset_register(__VA_ARGS__) +#define spi_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + spi_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * Enable functional output clock within peripheral diff --git a/components/hal/esp32c3/include/hal/systimer_ll.h b/components/hal/esp32c3/include/hal/systimer_ll.h index c5c8efe484..f321b4d05d 100644 --- a/components/hal/esp32c3/include/hal/systimer_ll.h +++ b/components/hal/esp32c3/include/hal/systimer_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -48,7 +48,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 @@ -63,7 +66,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) /******************* Counter *************************/ diff --git a/components/hal/esp32c3/include/hal/timer_ll.h b/components/hal/esp32c3/include/hal/timer_ll.h index c7cb579aac..396538c962 100644 --- a/components/hal/esp32c3/include/hal/timer_ll.h +++ b/components/hal/esp32c3/include/hal/timer_ll.h @@ -41,7 +41,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 @@ -67,7 +70,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 diff --git a/components/hal/esp32c3/include/hal/twai_ll.h b/components/hal/esp32c3/include/hal/twai_ll.h index 855edfd4bd..da6e7c0c20 100644 --- a/components/hal/esp32c3/include/hal/twai_ll.h +++ b/components/hal/esp32c3/include/hal/twai_ll.h @@ -153,7 +153,10 @@ static inline void twai_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_ATOMIC_ENV variable in advance -#define twai_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; twai_ll_enable_bus_clock(__VA_ARGS__) +#define twai_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + twai_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the twai module @@ -169,7 +172,10 @@ static inline void twai_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_ATOMIC_ENV variable in advance -#define twai_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; twai_ll_reset_register(__VA_ARGS__) +#define twai_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + twai_ll_reset_register(__VA_ARGS__); \ + } while(0) /* ---------------------------- Peripheral Control Register ----------------- */ diff --git a/components/hal/esp32c3/include/hal/uart_ll.h b/components/hal/esp32c3/include/hal/uart_ll.h index 06bad83cdc..c142d99b58 100644 --- a/components/hal/esp32c3/include/hal/uart_ll.h +++ b/components/hal/esp32c3/include/hal/uart_ll.h @@ -100,7 +100,10 @@ static inline void uart_ll_enable_bus_clock(uart_port_t uart_num, bool enable) } } // SYSTEM.perip_clk_enx are shared registers, so this function must be used in an atomic way -#define uart_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; uart_ll_enable_bus_clock(__VA_ARGS__) +#define uart_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + uart_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset UART module @@ -130,7 +133,10 @@ static inline void uart_ll_reset_register(uart_port_t uart_num) } } // SYSTEM.perip_rst_enx are shared registers, so this function must be used in an atomic way -#define uart_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; uart_ll_reset_register(__VA_ARGS__) +#define uart_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + uart_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * @brief Enable the UART clock. @@ -710,7 +716,10 @@ FORCE_INLINE_ATTR void _uart_ll_enable_pad_sleep_clock(uart_dev_t *hw, bool enab (void)hw; (void)enable; } -#define uart_ll_enable_pad_sleep_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _uart_ll_enable_pad_sleep_clock(__VA_ARGS__) +#define uart_ll_enable_pad_sleep_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _uart_ll_enable_pad_sleep_clock(__VA_ARGS__); \ + } while(0) /** * @brief Configure the UART work in normal mode. diff --git a/components/hal/esp32c3/include/hal/uhci_ll.h b/components/hal/esp32c3/include/hal/uhci_ll.h index 1fd74f59ae..62e2e49bbe 100644 --- a/components/hal/esp32c3/include/hal/uhci_ll.h +++ b/components/hal/esp32c3/include/hal/uhci_ll.h @@ -42,7 +42,10 @@ static inline void _uhci_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_ATOMIC_ENV variable in advance -#define uhci_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _uhci_ll_enable_bus_clock(__VA_ARGS__) +#define uhci_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _uhci_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the UHCI module @@ -58,7 +61,10 @@ static inline void _uhci_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_ATOMIC_ENV variable in advance -#define uhci_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; _uhci_ll_reset_register(__VA_ARGS__) +#define uhci_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _uhci_ll_reset_register(__VA_ARGS__); \ + } while(0) static inline void uhci_ll_init(uhci_dev_t *hw) { diff --git a/components/hal/esp32c3/include/hal/usb_serial_jtag_ll.h b/components/hal/esp32c3/include/hal/usb_serial_jtag_ll.h index 7fe4142bcf..1006f9d66f 100644 --- a/components/hal/esp32c3/include/hal/usb_serial_jtag_ll.h +++ b/components/hal/esp32c3/include/hal/usb_serial_jtag_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -299,7 +299,10 @@ FORCE_INLINE_ATTR void usb_serial_jtag_ll_enable_bus_clock(bool clk_en) } // SYSTEM.perip_clk_enx are shared registers, so this function must be used in an atomic way -#define usb_serial_jtag_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; usb_serial_jtag_ll_enable_bus_clock(__VA_ARGS__) +#define usb_serial_jtag_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + usb_serial_jtag_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the USJ module @@ -311,7 +314,10 @@ FORCE_INLINE_ATTR void usb_serial_jtag_ll_reset_register(void) } // SYSTEM.perip_clk_enx are shared registers, so this function must be used in an atomic way -#define usb_serial_jtag_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; usb_serial_jtag_ll_reset_register(__VA_ARGS__) +#define usb_serial_jtag_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + usb_serial_jtag_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * Get the enable status of the USJ module diff --git a/components/hal/esp32c5/include/hal/i2c_ll.h b/components/hal/esp32c5/include/hal/i2c_ll.h index 73d8be5a36..a13d5962a2 100644 --- a/components/hal/esp32c5/include/hal/i2c_ll.h +++ b/components/hal/esp32c5/include/hal/i2c_ll.h @@ -850,7 +850,10 @@ static inline void lp_i2c_ll_set_source_clk(i2c_dev_t *hw, soc_periph_lp_i2c_clk } /// LP_CLKRST.lpperi is a shared register, so this function must be used in an atomic way -#define lp_i2c_ll_set_source_clk(...) (void)__DECLARE_RCC_ATOMIC_ENV; lp_i2c_ll_set_source_clk(__VA_ARGS__) +#define lp_i2c_ll_set_source_clk(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + lp_i2c_ll_set_source_clk(__VA_ARGS__); \ + } while(0) /** * @brief Enable bus clock for the LP I2C module @@ -865,7 +868,10 @@ static inline void _lp_i2c_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_i2c_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _lp_i2c_ll_enable_bus_clock(__VA_ARGS__) +#define lp_i2c_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _lp_i2c_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset LP I2C module @@ -880,7 +886,10 @@ static inline void lp_i2c_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_i2c_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; lp_i2c_ll_reset_register(__VA_ARGS__) +#define lp_i2c_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + lp_i2c_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * @brief Enable I2C peripheral controller clock diff --git a/components/hal/esp32c5/include/hal/key_mgr_ll.h b/components/hal/esp32c5/include/hal/key_mgr_ll.h index f46c7c2e4c..581af34e18 100644 --- a/components/hal/esp32c5/include/hal/key_mgr_ll.h +++ b/components/hal/esp32c5/include/hal/key_mgr_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -50,7 +50,10 @@ static inline void _key_mgr_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_ATOMIC_ENV variable in advance -#define key_mgr_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _key_mgr_ll_enable_bus_clock(__VA_ARGS__) +#define key_mgr_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _key_mgr_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Enable the peripheral clock for Key Manager @@ -64,7 +67,10 @@ static inline void _key_mgr_ll_enable_peripheral_clock(bool enable) ; /* Nothing to do here, Kept for compatibility with other SoC */ } -#define key_mgr_ll_enable_peripheral_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _key_mgr_ll_enable_peripheral_clock(__VA_ARGS__) +#define key_mgr_ll_enable_peripheral_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _key_mgr_ll_enable_peripheral_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the Key Manager peripheral @@ -86,7 +92,10 @@ static inline void _key_mgr_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_ATOMIC_ENV variable in advance -#define key_mgr_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; _key_mgr_ll_reset_register(__VA_ARGS__) +#define key_mgr_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _key_mgr_ll_reset_register(__VA_ARGS__); \ + } while(0) /* @brief Start the key manager at IDLE state */ static inline void key_mgr_ll_start(void) diff --git a/components/hal/esp32c5/include/hal/lp_core_ll.h b/components/hal/esp32c5/include/hal/lp_core_ll.h index 04de32308c..f73950ed8e 100644 --- a/components/hal/esp32c5/include/hal/lp_core_ll.h +++ b/components/hal/esp32c5/include/hal/lp_core_ll.h @@ -39,7 +39,10 @@ static inline void lp_core_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_ATOMIC_ENV variable in advance -#define lp_core_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; lp_core_ll_enable_bus_clock(__VA_ARGS__) +#define lp_core_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + lp_core_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the lp_core module @@ -53,7 +56,10 @@ static inline void lp_core_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_ATOMIC_ENV variable in advance -#define lp_core_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; lp_core_ll_reset_register(__VA_ARGS__) +#define lp_core_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + lp_core_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * @brief Enable fast access of LP memory diff --git a/components/hal/esp32c5/include/hal/regi2c_ctrl_ll.h b/components/hal/esp32c5/include/hal/regi2c_ctrl_ll.h index b94df77429..96ba5aa199 100644 --- a/components/hal/esp32c5/include/hal/regi2c_ctrl_ll.h +++ b/components/hal/esp32c5/include/hal/regi2c_ctrl_ll.h @@ -30,7 +30,10 @@ static inline __attribute__((always_inline)) void _regi2c_ctrl_ll_master_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 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 @@ -51,7 +54,10 @@ static inline __attribute__((always_inline)) void _regi2c_ctrl_ll_master_reset(v /// 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 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 Force enable analog I2C master clock diff --git a/components/hal/esp32c5/include/hal/rtc_io_ll.h b/components/hal/esp32c5/include/hal/rtc_io_ll.h index 8210382195..be9daf5c5c 100644 --- a/components/hal/esp32c5/include/hal/rtc_io_ll.h +++ b/components/hal/esp32c5/include/hal/rtc_io_ll.h @@ -65,7 +65,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. diff --git a/components/hal/esp32c5/include/hal/systimer_ll.h b/components/hal/esp32c5/include/hal/systimer_ll.h index ec53aebd6a..ee06ae1f19 100644 --- a/components/hal/esp32c5/include/hal/systimer_ll.h +++ b/components/hal/esp32c5/include/hal/systimer_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -51,7 +51,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 @@ -66,7 +69,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 *****************************/ diff --git a/components/hal/esp32c5/include/hal/timer_ll.h b/components/hal/esp32c5/include/hal/timer_ll.h index f8f854b967..af72dbf477 100644 --- a/components/hal/esp32c5/include/hal/timer_ll.h +++ b/components/hal/esp32c5/include/hal/timer_ll.h @@ -68,7 +68,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 @@ -94,7 +97,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 diff --git a/components/hal/esp32c5/include/hal/uart_ll.h b/components/hal/esp32c5/include/hal/uart_ll.h index 28c94dd106..f4050db9cc 100644 --- a/components/hal/esp32c5/include/hal/uart_ll.h +++ b/components/hal/esp32c5/include/hal/uart_ll.h @@ -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 ******************************************/ diff --git a/components/hal/esp32c6/include/hal/i2c_ll.h b/components/hal/esp32c6/include/hal/i2c_ll.h index 49da17be0d..571034b050 100644 --- a/components/hal/esp32c6/include/hal/i2c_ll.h +++ b/components/hal/esp32c6/include/hal/i2c_ll.h @@ -852,7 +852,10 @@ static inline void lp_i2c_ll_set_source_clk(i2c_dev_t *hw, soc_periph_lp_i2c_clk } /// LP_CLKRST.lpperi is a shared register, so this function must be used in an atomic way -#define lp_i2c_ll_set_source_clk(...) (void)__DECLARE_RCC_ATOMIC_ENV; lp_i2c_ll_set_source_clk(__VA_ARGS__) +#define lp_i2c_ll_set_source_clk(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + lp_i2c_ll_set_source_clk(__VA_ARGS__); \ + } while(0) /** * @brief Enable bus clock for the LP I2C module @@ -867,7 +870,10 @@ static inline void _lp_i2c_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_i2c_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _lp_i2c_ll_enable_bus_clock(__VA_ARGS__) +#define lp_i2c_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _lp_i2c_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset LP I2C module @@ -882,7 +888,10 @@ static inline void lp_i2c_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_i2c_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; lp_i2c_ll_reset_register(__VA_ARGS__) +#define lp_i2c_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + lp_i2c_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * @brief Enable I2C peripheral controller clock diff --git a/components/hal/esp32c6/include/hal/lp_clkrst_ll.h b/components/hal/esp32c6/include/hal/lp_clkrst_ll.h index 43b94076be..c7808525db 100644 --- a/components/hal/esp32c6/include/hal/lp_clkrst_ll.h +++ b/components/hal/esp32c6/include/hal/lp_clkrst_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -25,7 +25,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 } diff --git a/components/hal/esp32c6/include/hal/regi2c_ctrl_ll.h b/components/hal/esp32c6/include/hal/regi2c_ctrl_ll.h index c1009ca32b..ff8f88433b 100644 --- a/components/hal/esp32c6/include/hal/regi2c_ctrl_ll.h +++ b/components/hal/esp32c6/include/hal/regi2c_ctrl_ll.h @@ -29,7 +29,10 @@ static inline __attribute__((always_inline)) void _regi2c_ctrl_ll_master_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 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 @@ -50,7 +53,10 @@ static inline __attribute__((always_inline)) void _regi2c_ctrl_ll_master_reset(v /// 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 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 Force enable analog I2C master clock diff --git a/components/hal/esp32c6/include/hal/rtc_io_ll.h b/components/hal/esp32c6/include/hal/rtc_io_ll.h index 708e53108a..9b63a686e1 100644 --- a/components/hal/esp32c6/include/hal/rtc_io_ll.h +++ b/components/hal/esp32c6/include/hal/rtc_io_ll.h @@ -64,7 +64,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. diff --git a/components/hal/esp32c6/include/hal/systimer_ll.h b/components/hal/esp32c6/include/hal/systimer_ll.h index aa68091757..8f58d906c9 100644 --- a/components/hal/esp32c6/include/hal/systimer_ll.h +++ b/components/hal/esp32c6/include/hal/systimer_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -49,7 +49,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 @@ -64,7 +67,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 *****************************/ diff --git a/components/hal/esp32c6/include/hal/timer_ll.h b/components/hal/esp32c6/include/hal/timer_ll.h index 15a6d9f88b..1033b56d16 100644 --- a/components/hal/esp32c6/include/hal/timer_ll.h +++ b/components/hal/esp32c6/include/hal/timer_ll.h @@ -68,7 +68,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 @@ -94,7 +97,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 diff --git a/components/hal/esp32c6/include/hal/uart_ll.h b/components/hal/esp32c6/include/hal/uart_ll.h index c4c62999e2..a07790084d 100644 --- a/components/hal/esp32c6/include/hal/uart_ll.h +++ b/components/hal/esp32c6/include/hal/uart_ll.h @@ -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 ******************************************/ diff --git a/components/hal/esp32c61/include/hal/regi2c_ctrl_ll.h b/components/hal/esp32c61/include/hal/regi2c_ctrl_ll.h index bf29390c5b..c0d2c516eb 100644 --- a/components/hal/esp32c61/include/hal/regi2c_ctrl_ll.h +++ b/components/hal/esp32c61/include/hal/regi2c_ctrl_ll.h @@ -30,7 +30,10 @@ static inline __attribute__((always_inline)) void _regi2c_ctrl_ll_master_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 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 @@ -51,7 +54,10 @@ static inline __attribute__((always_inline)) void _regi2c_ctrl_ll_master_reset(v /// 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 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 Force enable analog I2C master clock diff --git a/components/hal/esp32c61/include/hal/rtc_io_ll.h b/components/hal/esp32c61/include/hal/rtc_io_ll.h index d5b6001513..88bd7347e9 100644 --- a/components/hal/esp32c61/include/hal/rtc_io_ll.h +++ b/components/hal/esp32c61/include/hal/rtc_io_ll.h @@ -65,7 +65,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. diff --git a/components/hal/esp32c61/include/hal/systimer_ll.h b/components/hal/esp32c61/include/hal/systimer_ll.h index 10143837e7..39efe08b12 100644 --- a/components/hal/esp32c61/include/hal/systimer_ll.h +++ b/components/hal/esp32c61/include/hal/systimer_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -49,7 +49,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 @@ -64,7 +67,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 *****************************/ diff --git a/components/hal/esp32c61/include/hal/timer_ll.h b/components/hal/esp32c61/include/hal/timer_ll.h index 158ae7db7f..3252c6c63e 100644 --- a/components/hal/esp32c61/include/hal/timer_ll.h +++ b/components/hal/esp32c61/include/hal/timer_ll.h @@ -68,7 +68,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 @@ -94,7 +97,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 diff --git a/components/hal/esp32h2/include/hal/lp_clkrst_ll.h b/components/hal/esp32h2/include/hal/lp_clkrst_ll.h index 07679f1109..68b7f3e292 100644 --- a/components/hal/esp32h2/include/hal/lp_clkrst_ll.h +++ b/components/hal/esp32h2/include/hal/lp_clkrst_ll.h @@ -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 } diff --git a/components/hal/esp32h2/include/hal/regi2c_ctrl_ll.h b/components/hal/esp32h2/include/hal/regi2c_ctrl_ll.h index cd86dd626c..342cad0811 100644 --- a/components/hal/esp32h2/include/hal/regi2c_ctrl_ll.h +++ b/components/hal/esp32h2/include/hal/regi2c_ctrl_ll.h @@ -36,7 +36,10 @@ static inline __attribute__((always_inline)) void _regi2c_ctrl_ll_master_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 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 @@ -57,7 +60,10 @@ static inline __attribute__((always_inline)) void _regi2c_ctrl_ll_master_reset(v /// 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 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 Force enable analog I2C master clock diff --git a/components/hal/esp32h2/include/hal/rtc_io_ll.h b/components/hal/esp32h2/include/hal/rtc_io_ll.h index 56f82c256d..04863e01d1 100644 --- a/components/hal/esp32h2/include/hal/rtc_io_ll.h +++ b/components/hal/esp32h2/include/hal/rtc_io_ll.h @@ -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. diff --git a/components/hal/esp32h2/include/hal/systimer_ll.h b/components/hal/esp32h2/include/hal/systimer_ll.h index aa68091757..8f58d906c9 100644 --- a/components/hal/esp32h2/include/hal/systimer_ll.h +++ b/components/hal/esp32h2/include/hal/systimer_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -49,7 +49,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 @@ -64,7 +67,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 *****************************/ diff --git a/components/hal/esp32h2/include/hal/timer_ll.h b/components/hal/esp32h2/include/hal/timer_ll.h index 32fd260d5c..12983d2902 100644 --- a/components/hal/esp32h2/include/hal/timer_ll.h +++ b/components/hal/esp32h2/include/hal/timer_ll.h @@ -68,7 +68,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 @@ -94,7 +97,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 diff --git a/components/hal/esp32h21/include/hal/lp_clkrst_ll.h b/components/hal/esp32h21/include/hal/lp_clkrst_ll.h index 68a179e6b1..818bbe2543 100644 --- a/components/hal/esp32h21/include/hal/lp_clkrst_ll.h +++ b/components/hal/esp32h21/include/hal/lp_clkrst_ll.h @@ -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 } diff --git a/components/hal/esp32h21/include/hal/rtc_io_ll.h b/components/hal/esp32h21/include/hal/rtc_io_ll.h index 71ad47d961..ea5976d9f3 100644 --- a/components/hal/esp32h21/include/hal/rtc_io_ll.h +++ b/components/hal/esp32h21/include/hal/rtc_io_ll.h @@ -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. diff --git a/components/hal/esp32h21/include/hal/systimer_ll.h b/components/hal/esp32h21/include/hal/systimer_ll.h index 7576af61ad..4fab730577 100644 --- a/components/hal/esp32h21/include/hal/systimer_ll.h +++ b/components/hal/esp32h21/include/hal/systimer_ll.h @@ -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 *****************************/ diff --git a/components/hal/esp32h21/include/hal/timer_ll.h b/components/hal/esp32h21/include/hal/timer_ll.h index 25dafaa1cf..22a7a54d9c 100644 --- a/components/hal/esp32h21/include/hal/timer_ll.h +++ b/components/hal/esp32h21/include/hal/timer_ll.h @@ -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 diff --git a/components/hal/esp32h4/include/hal/systimer_ll.h b/components/hal/esp32h4/include/hal/systimer_ll.h index cf19f7df64..5688f51f99 100644 --- a/components/hal/esp32h4/include/hal/systimer_ll.h +++ b/components/hal/esp32h4/include/hal/systimer_ll.h @@ -51,7 +51,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 @@ -66,7 +69,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 *****************************/ diff --git a/components/hal/esp32h4/include/hal/timer_ll.h b/components/hal/esp32h4/include/hal/timer_ll.h index be0e6d1868..7da96d0b0b 100644 --- a/components/hal/esp32h4/include/hal/timer_ll.h +++ b/components/hal/esp32h4/include/hal/timer_ll.h @@ -68,7 +68,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 @@ -94,7 +97,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 diff --git a/components/hal/esp32p4/include/hal/adc_ll.h b/components/hal/esp32p4/include/hal/adc_ll.h index e6bc2c3e32..95e9cd983e 100644 --- a/components/hal/esp32p4/include/hal/adc_ll.h +++ b/components/hal/esp32p4/include/hal/adc_ll.h @@ -520,7 +520,10 @@ static inline void _adc_ll_sar1_clock_force_en(bool enable) } // HP_SYS_CLKRST.clk_force_on_ctrl0 are shared registers, so this function must be used in an atomic way -#define adc_ll_sar1_clock_force_en(...) (void)__DECLARE_RCC_ATOMIC_ENV; _adc_ll_sar1_clock_force_en(__VA_ARGS__) +#define adc_ll_sar1_clock_force_en(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _adc_ll_sar1_clock_force_en(__VA_ARGS__); \ + } while(0) static inline void _adc_ll_sar2_clock_force_en(bool enable) { @@ -528,7 +531,10 @@ static inline void _adc_ll_sar2_clock_force_en(bool enable) } // HP_SYS_CLKRST.clk_force_on_ctrl0 are shared registers, so this function must be used in an atomic way -#define adc_ll_sar2_clock_force_en(...) (void)__DECLARE_RCC_ATOMIC_ENV; _adc_ll_sar2_clock_force_en(__VA_ARGS__) +#define adc_ll_sar2_clock_force_en(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _adc_ll_sar2_clock_force_en(__VA_ARGS__); \ + } while(0) /** * @brief Enable the ADC clock @@ -541,7 +547,10 @@ static inline void _adc_ll_enable_bus_clock(bool enable) HP_SYS_CLKRST.peri_clk_ctrl23.reg_adc_clk_en = enable; } // HP_SYS_CLKRST.soc_clk_ctrl2 are shared registers, so this function must be used in an atomic way -#define adc_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _adc_ll_enable_bus_clock(__VA_ARGS__) +#define adc_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _adc_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset ADC module @@ -553,7 +562,10 @@ static inline void _adc_ll_reset_register(void) HP_SYS_CLKRST.hp_rst_en2.reg_rst_en_adc = 0; } // HP_SYS_CLKRST.hp_rst_en2 is a shared register, so this function must be used in an atomic way -#define adc_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; _adc_ll_reset_register(__VA_ARGS__) +#define adc_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _adc_ll_reset_register(__VA_ARGS__); \ + } while(0) diff --git a/components/hal/esp32p4/include/hal/aes_ll.h b/components/hal/esp32p4/include/hal/aes_ll.h index 8d73c7eec2..9d583ef44c 100644 --- a/components/hal/esp32p4/include/hal/aes_ll.h +++ b/components/hal/esp32p4/include/hal/aes_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -38,7 +38,10 @@ static inline void _aes_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_ATOMIC_ENV variable in advance -#define aes_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _aes_ll_enable_bus_clock(__VA_ARGS__) +#define aes_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _aes_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the AES peripheral module @@ -55,7 +58,10 @@ static inline void aes_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_ATOMIC_ENV variable in advance -#define aes_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; aes_ll_reset_register(__VA_ARGS__) +#define aes_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + aes_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * @brief Write the encryption/decryption key to hardware diff --git a/components/hal/esp32p4/include/hal/cam_ll.h b/components/hal/esp32p4/include/hal/cam_ll.h index a48dba2dc8..c9f15c8945 100644 --- a/components/hal/esp32p4/include/hal/cam_ll.h +++ b/components/hal/esp32p4/include/hal/cam_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -35,7 +35,10 @@ static inline void cam_ll_enable_bus_clock(int group_id, bool en) /// 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 cam_ll_enable_bus_clock(...) (void)__DECLARE_RCC_RC_ATOMIC_ENV; cam_ll_enable_bus_clock(__VA_ARGS__) +#define cam_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_RC_ATOMIC_ENV; \ + cam_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the CAM module @@ -51,7 +54,10 @@ static inline void cam_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 cam_ll_reset_register(...) (void)__DECLARE_RCC_RC_ATOMIC_ENV; cam_ll_reset_register(__VA_ARGS__) +#define cam_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_RC_ATOMIC_ENV; \ + cam_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * @brief Enable clock gating @@ -66,7 +72,10 @@ static inline void cam_ll_enable_clk(int group_id, bool en) /// 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_ATOMIC_ENV variable in advance -#define cam_ll_enable_clk(...) (void)__DECLARE_RCC_ATOMIC_ENV; cam_ll_enable_clk(__VA_ARGS__) +#define cam_ll_enable_clk(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + cam_ll_enable_clk(__VA_ARGS__); \ + } while(0) /** * @brief Get the clock status for the CAM module @@ -81,7 +90,10 @@ static inline bool cam_ll_get_clk_status(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_ATOMIC_ENV variable in advance -#define cam_ll_get_clk_status(...) (void)__DECLARE_RCC_ATOMIC_ENV; cam_ll_get_clk_status(__VA_ARGS__) +#define cam_ll_get_clk_status(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + cam_ll_get_clk_status(__VA_ARGS__); \ + } while(0) /** * @brief Select clock source for CAM peripheral @@ -109,7 +121,10 @@ static inline void cam_ll_select_clk_src(int group_id, cam_clock_source_t src) /// 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_ATOMIC_ENV variable in advance -#define cam_ll_select_clk_src(...) (void)__DECLARE_RCC_ATOMIC_ENV; cam_ll_select_clk_src(__VA_ARGS__) +#define cam_ll_select_clk_src(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + cam_ll_select_clk_src(__VA_ARGS__); \ + } while(0) /** * @brief Get the CAM source clock type @@ -156,7 +171,10 @@ static inline void cam_ll_set_group_clock_coeff(int group_id, int div_num, int d /// 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_ATOMIC_ENV variable in advance -#define cam_ll_set_group_clock_coeff(...) (void)__DECLARE_RCC_ATOMIC_ENV; cam_ll_set_group_clock_coeff(__VA_ARGS__) +#define cam_ll_set_group_clock_coeff(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + cam_ll_set_group_clock_coeff(__VA_ARGS__); \ + } while(0) /** * @brief Enable stop signal for CAM peripheral diff --git a/components/hal/esp32p4/include/hal/clk_gate_ll.h b/components/hal/esp32p4/include/hal/clk_gate_ll.h index 39234dedd9..f7effecc73 100644 --- a/components/hal/esp32p4/include/hal/clk_gate_ll.h +++ b/components/hal/esp32p4/include/hal/clk_gate_ll.h @@ -26,7 +26,10 @@ FORCE_INLINE_ATTR void _clk_gate_ll_ref_20m_clk_en(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_ATOMIC_ENV variable in advance -#define clk_gate_ll_ref_20m_clk_en(...) (void)__DECLARE_RCC_ATOMIC_ENV; _clk_gate_ll_ref_20m_clk_en(__VA_ARGS__) +#define clk_gate_ll_ref_20m_clk_en(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _clk_gate_ll_ref_20m_clk_en(__VA_ARGS__); \ + } while(0) /** * Enable or disable the clock gate for ref_20m. @@ -38,7 +41,10 @@ FORCE_INLINE_ATTR void _clk_gate_ll_ref_25m_clk_en(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_ATOMIC_ENV variable in advance -#define clk_gate_ll_ref_25m_clk_en(...) (void)__DECLARE_RCC_ATOMIC_ENV; _clk_gate_ll_ref_25m_clk_en(__VA_ARGS__) +#define clk_gate_ll_ref_25m_clk_en(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _clk_gate_ll_ref_25m_clk_en(__VA_ARGS__); \ + } while(0) /** * Enable or disable the clock gate for ref_20m. @@ -50,7 +56,10 @@ FORCE_INLINE_ATTR void _clk_gate_ll_ref_80m_clk_en(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_ATOMIC_ENV variable in advance -#define clk_gate_ll_ref_80m_clk_en(...) (void)__DECLARE_RCC_ATOMIC_ENV; _clk_gate_ll_ref_80m_clk_en(__VA_ARGS__) +#define clk_gate_ll_ref_80m_clk_en(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _clk_gate_ll_ref_80m_clk_en(__VA_ARGS__); \ + } while(0) /** * Enable or disable the clock gate for ref_20m. @@ -62,7 +71,10 @@ FORCE_INLINE_ATTR void _clk_gate_ll_ref_160m_clk_en(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_ATOMIC_ENV variable in advance -#define clk_gate_ll_ref_160m_clk_en(...) (void)__DECLARE_RCC_ATOMIC_ENV; _clk_gate_ll_ref_160m_clk_en(__VA_ARGS__) +#define clk_gate_ll_ref_160m_clk_en(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _clk_gate_ll_ref_160m_clk_en(__VA_ARGS__); \ + } while(0) /** * Enable or disable the clock gate for ref_20m. @@ -74,7 +86,10 @@ FORCE_INLINE_ATTR void _clk_gate_ll_ref_240m_clk_en(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_ATOMIC_ENV variable in advance -#define clk_gate_ll_ref_240m_clk_en(...) (void)__DECLARE_RCC_ATOMIC_ENV; _clk_gate_ll_ref_240m_clk_en(__VA_ARGS__) +#define clk_gate_ll_ref_240m_clk_en(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _clk_gate_ll_ref_240m_clk_en(__VA_ARGS__); \ + } while(0) /** * Enable or disable the clock gate for xtal to lp periph @@ -86,7 +101,10 @@ FORCE_INLINE_ATTR void _clk_gate_ll_xtal_to_lp_periph_en(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_ATOMIC_ENV variable in advance -#define clk_gate_ll_xtal_to_lp_periph_en(...) (void)__DECLARE_RCC_ATOMIC_ENV; _clk_gate_ll_xtal_to_lp_periph_en(__VA_ARGS__) +#define clk_gate_ll_xtal_to_lp_periph_en(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _clk_gate_ll_xtal_to_lp_periph_en(__VA_ARGS__); \ + } while(0) /** * Enable or disable the clock gate for ref_50m. @@ -98,7 +116,10 @@ FORCE_INLINE_ATTR void _clk_gate_ll_ref_50m_clk_en(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_ATOMIC_ENV variable in advance -#define clk_gate_ll_ref_50m_clk_en(...) (void)__DECLARE_RCC_ATOMIC_ENV; _clk_gate_ll_ref_50m_clk_en(__VA_ARGS__) +#define clk_gate_ll_ref_50m_clk_en(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _clk_gate_ll_ref_50m_clk_en(__VA_ARGS__); \ + } while(0) #ifdef __cplusplus diff --git a/components/hal/esp32p4/include/hal/dma2d_ll.h b/components/hal/esp32p4/include/hal/dma2d_ll.h index f36fcdd433..9b1f1bf645 100644 --- a/components/hal/esp32p4/include/hal/dma2d_ll.h +++ b/components/hal/esp32p4/include/hal/dma2d_ll.h @@ -87,7 +87,10 @@ static inline void dma2d_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_ATOMIC_ENV variable in advance -#define dma2d_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; dma2d_ll_enable_bus_clock(__VA_ARGS__) +#define dma2d_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + dma2d_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the 2D-DMA module @@ -103,7 +106,10 @@ static inline void dma2d_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_ATOMIC_ENV variable in advance -#define dma2d_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; dma2d_ll_reset_register(__VA_ARGS__) +#define dma2d_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + dma2d_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * @brief Check if the bus clock is enabled for the DMA module diff --git a/components/hal/esp32p4/include/hal/ds_ll.h b/components/hal/esp32p4/include/hal/ds_ll.h index aa4afbbae3..1d6437a8f1 100644 --- a/components/hal/esp32p4/include/hal/ds_ll.h +++ b/components/hal/esp32p4/include/hal/ds_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -37,7 +37,10 @@ static inline void _ds_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_ATOMIC_ENV variable in advance -#define ds_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _ds_ll_enable_bus_clock(__VA_ARGS__) +#define ds_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _ds_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the DS peripheral module @@ -53,7 +56,10 @@ static inline void ds_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_ATOMIC_ENV variable in advance -#define ds_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; ds_ll_reset_register(__VA_ARGS__) +#define ds_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + ds_ll_reset_register(__VA_ARGS__); \ + } while(0) static inline void ds_ll_start(void) { diff --git a/components/hal/esp32p4/include/hal/dw_gdma_ll.h b/components/hal/esp32p4/include/hal/dw_gdma_ll.h index e206928844..60e5032dde 100644 --- a/components/hal/esp32p4/include/hal/dw_gdma_ll.h +++ b/components/hal/esp32p4/include/hal/dw_gdma_ll.h @@ -96,7 +96,10 @@ static inline void dw_gdma_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_ATOMIC_ENV variable in advance -#define dw_gdma_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; dw_gdma_ll_enable_bus_clock(__VA_ARGS__) +#define dw_gdma_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + dw_gdma_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the DMA module @@ -110,7 +113,10 @@ static inline void _dw_gdma_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_ATOMIC_ENV variable in advance -#define dw_gdma_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; _dw_gdma_ll_reset_register(__VA_ARGS__) +#define dw_gdma_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _dw_gdma_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * @brief Check if the bus clock is enabled for the DMA module diff --git a/components/hal/esp32p4/include/hal/ecc_ll.h b/components/hal/esp32p4/include/hal/ecc_ll.h index 05a7ed8fcd..d7977a83b8 100644 --- a/components/hal/esp32p4/include/hal/ecc_ll.h +++ b/components/hal/esp32p4/include/hal/ecc_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -37,7 +37,10 @@ static inline void _ecc_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_ATOMIC_ENV variable in advance -#define ecc_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _ecc_ll_enable_bus_clock(__VA_ARGS__) +#define ecc_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _ecc_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the ECC peripheral module @@ -54,7 +57,10 @@ static inline void ecc_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_ATOMIC_ENV variable in advance -#define ecc_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; ecc_ll_reset_register(__VA_ARGS__) +#define ecc_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + ecc_ll_reset_register(__VA_ARGS__); \ + } while(0) static inline void ecc_ll_power_up(void) {} static inline void ecc_ll_power_down(void) {} diff --git a/components/hal/esp32p4/include/hal/ecdsa_ll.h b/components/hal/esp32p4/include/hal/ecdsa_ll.h index f3429cf1b2..f669f36990 100644 --- a/components/hal/esp32p4/include/hal/ecdsa_ll.h +++ b/components/hal/esp32p4/include/hal/ecdsa_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -93,7 +93,10 @@ static inline void ecdsa_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_ATOMIC_ENV variable in advance -#define ecdsa_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; ecdsa_ll_enable_bus_clock(__VA_ARGS__) +#define ecdsa_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + ecdsa_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the ECDSA peripheral module diff --git a/components/hal/esp32p4/include/hal/emac_ll.h b/components/hal/esp32p4/include/hal/emac_ll.h index f2b313ca85..62704653e9 100644 --- a/components/hal/esp32p4/include/hal/emac_ll.h +++ b/components/hal/esp32p4/include/hal/emac_ll.h @@ -830,7 +830,10 @@ static inline void emac_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_ATOMIC_ENV variable in advance -#define emac_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; emac_ll_enable_bus_clock(__VA_ARGS__) +#define emac_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + emac_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) static inline void _emac_ll_clock_force_en(bool enable) { @@ -839,7 +842,10 @@ static inline void _emac_ll_clock_force_en(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_ATOMIC_ENV variable in advance -#define emac_ll_clock_force_en(...) (void)__DECLARE_RCC_ATOMIC_ENV; _emac_ll_clock_force_en(__VA_ARGS__) +#define emac_ll_clock_force_en(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _emac_ll_clock_force_en(__VA_ARGS__); \ + } while(0) /** * @brief Reset the EMAC module @@ -855,7 +861,10 @@ static inline void emac_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_ATOMIC_ENV variable in advance -#define emac_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; emac_ll_reset_register(__VA_ARGS__) +#define emac_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + emac_ll_reset_register(__VA_ARGS__); \ + } while(0) static inline eth_data_interface_t emac_ll_get_phy_intf(void *ext_regs) { @@ -887,7 +896,10 @@ static inline void emac_ll_clock_enable_mii(void *ext_regs) /// 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_ATOMIC_ENV variable in advance -#define emac_ll_clock_enable_mii(...) (void)__DECLARE_RCC_ATOMIC_ENV; emac_ll_clock_enable_mii(__VA_ARGS__) +#define emac_ll_clock_enable_mii(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + emac_ll_clock_enable_mii(__VA_ARGS__); \ + } while(0) static inline void emac_ll_clock_enable_rmii_input(void *ext_regs) { @@ -913,7 +925,10 @@ static inline void emac_ll_clock_enable_rmii_input(void *ext_regs) /// 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_ATOMIC_ENV variable in advance -#define emac_ll_clock_enable_rmii_input(...) (void)__DECLARE_RCC_ATOMIC_ENV; emac_ll_clock_enable_rmii_input(__VA_ARGS__) +#define emac_ll_clock_enable_rmii_input(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + emac_ll_clock_enable_rmii_input(__VA_ARGS__); \ + } while(0) static inline void emac_ll_clock_rmii_rx_tx_div(void *ext_regs, int div) { @@ -923,7 +938,10 @@ static inline void emac_ll_clock_rmii_rx_tx_div(void *ext_regs, int div) /// 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_ATOMIC_ENV variable in advance -#define emac_ll_clock_rmii_rx_tx_div(...) (void)__DECLARE_RCC_ATOMIC_ENV; emac_ll_clock_rmii_rx_tx_div(__VA_ARGS__) +#define emac_ll_clock_rmii_rx_tx_div(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + emac_ll_clock_rmii_rx_tx_div(__VA_ARGS__); \ + } while(0) static inline void emac_ll_clock_enable_rmii_output(void *ext_regs) { @@ -934,7 +952,10 @@ static inline void emac_ll_clock_enable_rmii_output(void *ext_regs) /// 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_ATOMIC_ENV variable in advance -#define emac_ll_clock_enable_rmii_output(...) (void)__DECLARE_RCC_ATOMIC_ENV; emac_ll_clock_enable_rmii_output(__VA_ARGS__) +#define emac_ll_clock_enable_rmii_output(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + emac_ll_clock_enable_rmii_output(__VA_ARGS__); \ + } while(0) static inline void emac_ll_clock_enable_ptp(void *ext_regs, soc_periph_emac_ptp_clk_src_t clk_src, bool enable) { @@ -958,7 +979,10 @@ static inline void emac_ll_clock_enable_ptp(void *ext_regs, soc_periph_emac_ptp_ /// 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_ATOMIC_ENV variable in advance -#define emac_ll_clock_enable_ptp(...) (void)__DECLARE_RCC_ATOMIC_ENV; emac_ll_clock_enable_ptp(__VA_ARGS__) +#define emac_ll_clock_enable_ptp(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + emac_ll_clock_enable_ptp(__VA_ARGS__); \ + } while(0) static inline void emac_ll_pause_frame_enable(void *ext_regs, bool enable) { diff --git a/components/hal/esp32p4/include/hal/etm_ll.h b/components/hal/esp32p4/include/hal/etm_ll.h index 24c25776b5..b638ac2084 100644 --- a/components/hal/esp32p4/include/hal/etm_ll.h +++ b/components/hal/esp32p4/include/hal/etm_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -35,7 +35,10 @@ static inline void _etm_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_ATOMIC_ENV variable in advance -#define etm_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _etm_ll_enable_bus_clock(__VA_ARGS__) +#define etm_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _etm_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the ETM module @@ -51,7 +54,10 @@ static inline void etm_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_ATOMIC_ENV variable in advance -#define etm_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; etm_ll_reset_register(__VA_ARGS__) +#define etm_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + etm_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * @brief Enable ETM channel diff --git a/components/hal/esp32p4/include/hal/gdma_ll.h b/components/hal/esp32p4/include/hal/gdma_ll.h index 17f1b5a15e..7bd9416927 100644 --- a/components/hal/esp32p4/include/hal/gdma_ll.h +++ b/components/hal/esp32p4/include/hal/gdma_ll.h @@ -106,7 +106,10 @@ static inline void _gdma_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_ATOMIC_ENV variable in advance -#define gdma_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _gdma_ll_enable_bus_clock(__VA_ARGS__) +#define gdma_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _gdma_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Check if the bus clock is enabled for the DMA module @@ -137,7 +140,10 @@ static inline void _gdma_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_ATOMIC_ENV variable in advance -#define gdma_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; _gdma_ll_reset_register(__VA_ARGS__) +#define gdma_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _gdma_ll_reset_register(__VA_ARGS__); \ + } while(0) #ifdef __cplusplus } diff --git a/components/hal/esp32p4/include/hal/gpio_ll.h b/components/hal/esp32p4/include/hal/gpio_ll.h index 565604d967..402fc8801b 100644 --- a/components/hal/esp32p4/include/hal/gpio_ll.h +++ b/components/hal/esp32p4/include/hal/gpio_ll.h @@ -637,7 +637,10 @@ static inline void gpio_ll_iomux_set_clk_src(soc_module_clk_t src) /// 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_ATOMIC_ENV variable in advance -#define gpio_ll_iomux_set_clk_src(...) (void)__DECLARE_RCC_ATOMIC_ENV; gpio_ll_iomux_set_clk_src(__VA_ARGS__) +#define gpio_ll_iomux_set_clk_src(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + gpio_ll_iomux_set_clk_src(__VA_ARGS__); \ + } while(0) /** * @brief Get the GPIO number that is routed to the input peripheral signal through GPIO matrix. diff --git a/components/hal/esp32p4/include/hal/hmac_ll.h b/components/hal/esp32p4/include/hal/hmac_ll.h index dd1eb55619..f9bd6a650a 100644 --- a/components/hal/esp32p4/include/hal/hmac_ll.h +++ b/components/hal/esp32p4/include/hal/hmac_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -44,7 +44,10 @@ static inline void _hmac_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_ATOMIC_ENV variable in advance -#define hmac_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _hmac_ll_enable_bus_clock(__VA_ARGS__) +#define hmac_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _hmac_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the HMAC peripheral module @@ -60,7 +63,10 @@ static inline void hmac_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_ATOMIC_ENV variable in advance -#define hmac_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; hmac_ll_reset_register(__VA_ARGS__) +#define hmac_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + hmac_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * Makes the peripheral ready for use, after enabling it. diff --git a/components/hal/esp32p4/include/hal/i2c_ll.h b/components/hal/esp32p4/include/hal/i2c_ll.h index 37fb6e1038..db62795bbb 100644 --- a/components/hal/esp32p4/include/hal/i2c_ll.h +++ b/components/hal/esp32p4/include/hal/i2c_ll.h @@ -879,7 +879,10 @@ static inline void lp_i2c_ll_set_source_clk(i2c_dev_t *hw, soc_periph_lp_i2c_clk } /// LP_AON_CLKRST.lpperi is a shared register, so this function must be used in an atomic way -#define lp_i2c_ll_set_source_clk(...) (void)__DECLARE_RCC_ATOMIC_ENV; lp_i2c_ll_set_source_clk(__VA_ARGS__) +#define lp_i2c_ll_set_source_clk(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + lp_i2c_ll_set_source_clk(__VA_ARGS__); \ + } while(0) /** * @brief Enable bus clock for the LP I2C module @@ -894,7 +897,10 @@ static inline void _lp_i2c_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_i2c_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _lp_i2c_ll_enable_bus_clock(__VA_ARGS__) +#define lp_i2c_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _lp_i2c_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset LP I2C module @@ -909,7 +915,10 @@ static inline void lp_i2c_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_i2c_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; lp_i2c_ll_reset_register(__VA_ARGS__) +#define lp_i2c_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + lp_i2c_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * @brief Enable I2C peripheral controller clock diff --git a/components/hal/esp32p4/include/hal/i2s_ll.h b/components/hal/esp32p4/include/hal/i2s_ll.h index 464557a7fd..8a77a0c84d 100644 --- a/components/hal/esp32p4/include/hal/i2s_ll.h +++ b/components/hal/esp32p4/include/hal/i2s_ll.h @@ -140,7 +140,10 @@ static inline void i2s_ll_enable_bus_clock(int i2s_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_ATOMIC_ENV variable in advance -#define i2s_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; i2s_ll_enable_bus_clock(__VA_ARGS__) +#define i2s_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + i2s_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the I2S module @@ -167,7 +170,10 @@ static inline void i2s_ll_reset_register(int i2s_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_ATOMIC_ENV variable in advance -#define i2s_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; i2s_ll_reset_register(__VA_ARGS__) +#define i2s_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + i2s_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * @brief I2S module general init, enable I2S clock. @@ -184,7 +190,10 @@ static inline void i2s_ll_enable_core_clock(i2s_dev_t *hw, 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_ATOMIC_ENV variable in advance -#define i2s_ll_enable_core_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; i2s_ll_enable_core_clock(__VA_ARGS__) +#define i2s_ll_enable_core_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + i2s_ll_enable_core_clock(__VA_ARGS__); \ + } while(0) /** * @brief Enable I2S tx module clock @@ -209,7 +218,10 @@ static inline void _i2s_ll_tx_enable_clock(i2s_dev_t *hw) /// 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_ATOMIC_ENV variable in advance -#define i2s_ll_tx_enable_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _i2s_ll_tx_enable_clock(__VA_ARGS__) +#define i2s_ll_tx_enable_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _i2s_ll_tx_enable_clock(__VA_ARGS__); \ + } while(0) /** * @brief Enable I2S rx module clock @@ -234,7 +246,10 @@ static inline void _i2s_ll_rx_enable_clock(i2s_dev_t *hw) /// 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_ATOMIC_ENV variable in advance -#define i2s_ll_rx_enable_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _i2s_ll_rx_enable_clock(__VA_ARGS__) +#define i2s_ll_rx_enable_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _i2s_ll_rx_enable_clock(__VA_ARGS__); \ + } while(0) /** * @brief Disable I2S tx module clock @@ -259,7 +274,10 @@ static inline void i2s_ll_tx_disable_clock(i2s_dev_t *hw) /// 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_ATOMIC_ENV variable in advance -#define i2s_ll_tx_disable_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; i2s_ll_tx_disable_clock(__VA_ARGS__) +#define i2s_ll_tx_disable_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + i2s_ll_tx_disable_clock(__VA_ARGS__); \ + } while(0) /** * @brief Disable I2S rx module clock @@ -284,7 +302,10 @@ static inline void i2s_ll_rx_disable_clock(i2s_dev_t *hw) /// 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_ATOMIC_ENV variable in advance -#define i2s_ll_rx_disable_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; i2s_ll_rx_disable_clock(__VA_ARGS__) +#define i2s_ll_rx_disable_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + i2s_ll_rx_disable_clock(__VA_ARGS__); \ + } while(0) /** * @brief I2S mclk use tx module clock @@ -310,7 +331,10 @@ static inline void _i2s_ll_mclk_bind_to_tx_clk(i2s_dev_t *hw) /// 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_ATOMIC_ENV variable in advance -#define i2s_ll_mclk_bind_to_tx_clk(...) (void)__DECLARE_RCC_ATOMIC_ENV; _i2s_ll_mclk_bind_to_tx_clk(__VA_ARGS__) +#define i2s_ll_mclk_bind_to_tx_clk(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _i2s_ll_mclk_bind_to_tx_clk(__VA_ARGS__); \ + } while(0) /** * @brief I2S mclk use rx module clock @@ -336,7 +360,10 @@ static inline void _i2s_ll_mclk_bind_to_rx_clk(i2s_dev_t *hw) /// 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_ATOMIC_ENV variable in advance -#define i2s_ll_mclk_bind_to_rx_clk(...) (void)__DECLARE_RCC_ATOMIC_ENV; _i2s_ll_mclk_bind_to_rx_clk(__VA_ARGS__) +#define i2s_ll_mclk_bind_to_rx_clk(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _i2s_ll_mclk_bind_to_rx_clk(__VA_ARGS__); \ + } while(0) /** * @brief Enable I2S TX slave mode @@ -445,7 +472,10 @@ static inline void _i2s_ll_tx_clk_set_src(i2s_dev_t *hw, i2s_clock_src_t src) /// 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_ATOMIC_ENV variable in advance -#define i2s_ll_tx_clk_set_src(...) (void)__DECLARE_RCC_ATOMIC_ENV; _i2s_ll_tx_clk_set_src(__VA_ARGS__) +#define i2s_ll_tx_clk_set_src(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _i2s_ll_tx_clk_set_src(__VA_ARGS__); \ + } while(0) /** * @brief Set RX source clock @@ -472,7 +502,10 @@ static inline void _i2s_ll_rx_clk_set_src(i2s_dev_t *hw, i2s_clock_src_t src) /// 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_ATOMIC_ENV variable in advance -#define i2s_ll_rx_clk_set_src(...) (void)__DECLARE_RCC_ATOMIC_ENV; _i2s_ll_rx_clk_set_src(__VA_ARGS__) +#define i2s_ll_rx_clk_set_src(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _i2s_ll_rx_clk_set_src(__VA_ARGS__); \ + } while(0) /** * @brief Set I2S tx bck div num @@ -639,7 +672,10 @@ static inline void _i2s_ll_tx_set_mclk(i2s_dev_t *hw, const hal_utils_clk_div_t /// 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_ATOMIC_ENV variable in advance -#define i2s_ll_tx_set_mclk(...) (void)__DECLARE_RCC_ATOMIC_ENV; _i2s_ll_tx_set_mclk(__VA_ARGS__) +#define i2s_ll_tx_set_mclk(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _i2s_ll_tx_set_mclk(__VA_ARGS__); \ + } while(0) /** * @brief Set I2S rx bck div num @@ -677,7 +713,10 @@ static inline void _i2s_ll_rx_set_mclk(i2s_dev_t *hw, const hal_utils_clk_div_t /// 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_ATOMIC_ENV variable in advance -#define i2s_ll_rx_set_mclk(...) (void)__DECLARE_RCC_ATOMIC_ENV; _i2s_ll_rx_set_mclk(__VA_ARGS__) +#define i2s_ll_rx_set_mclk(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _i2s_ll_rx_set_mclk(__VA_ARGS__); \ + } while(0) /** * @brief Update the TX configuration diff --git a/components/hal/esp32p4/include/hal/isp_ll.h b/components/hal/esp32p4/include/hal/isp_ll.h index 63ff39e033..0e85e666fd 100644 --- a/components/hal/esp32p4/include/hal/isp_ll.h +++ b/components/hal/esp32p4/include/hal/isp_ll.h @@ -192,7 +192,10 @@ static inline void isp_ll_enable_module_clock(isp_dev_t *hw, bool en) /// 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_ATOMIC_ENV variable in advance -#define isp_ll_enable_module_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; isp_ll_enable_module_clock(__VA_ARGS__) +#define isp_ll_enable_module_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + isp_ll_enable_module_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the ISP module @@ -207,7 +210,10 @@ static inline void isp_ll_reset_module_clock(isp_dev_t *hw) /// 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_ATOMIC_ENV variable in advance -#define isp_ll_reset_module_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; isp_ll_reset_module_clock(__VA_ARGS__) +#define isp_ll_reset_module_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + isp_ll_reset_module_clock(__VA_ARGS__); \ + } while(0) /** * @brief Select ISP clock source @@ -238,7 +244,10 @@ static inline void isp_ll_select_clk_source(isp_dev_t *hw, soc_periph_isp_clk_sr /// 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_ATOMIC_ENV variable in advance -#define isp_ll_select_clk_source(...) (void)__DECLARE_RCC_ATOMIC_ENV; isp_ll_select_clk_source(__VA_ARGS__) +#define isp_ll_select_clk_source(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + isp_ll_select_clk_source(__VA_ARGS__); \ + } while(0) /** * @brief Set ISP clock div @@ -254,7 +263,10 @@ static inline void isp_ll_set_clock_div(isp_dev_t *hw, const hal_utils_clk_div_t /// 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_ATOMIC_ENV variable in advance -#define isp_ll_set_clock_div(...) (void)__DECLARE_RCC_ATOMIC_ENV; isp_ll_set_clock_div(__VA_ARGS__) +#define isp_ll_set_clock_div(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + isp_ll_set_clock_div(__VA_ARGS__); \ + } while(0) /*--------------------------------------------------------------- Misc diff --git a/components/hal/esp32p4/include/hal/jpeg_ll.h b/components/hal/esp32p4/include/hal/jpeg_ll.h index 9285576f2e..28714c6b9d 100644 --- a/components/hal/esp32p4/include/hal/jpeg_ll.h +++ b/components/hal/esp32p4/include/hal/jpeg_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -89,7 +89,10 @@ static inline void jpeg_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_ATOMIC_ENV variable in advance -#define jpeg_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; jpeg_ll_enable_bus_clock(__VA_ARGS__) +#define jpeg_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + jpeg_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the JPEG module @@ -102,7 +105,10 @@ static inline void jpeg_ll_reset_module_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_ATOMIC_ENV variable in advance -#define jpeg_ll_reset_module_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; jpeg_ll_reset_module_register(__VA_ARGS__) +#define jpeg_ll_reset_module_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + jpeg_ll_reset_module_register(__VA_ARGS__); \ + } while(0) /** * @brief Write the numbers of 1~n codewords length sum of ac0 table and write the minimum codeword of code length diff --git a/components/hal/esp32p4/include/hal/key_mgr_ll.h b/components/hal/esp32p4/include/hal/key_mgr_ll.h index 3aa13bc363..e098b9c368 100644 --- a/components/hal/esp32p4/include/hal/key_mgr_ll.h +++ b/components/hal/esp32p4/include/hal/key_mgr_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -37,7 +37,10 @@ static inline void _key_mgr_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_ATOMIC_ENV variable in advance -#define key_mgr_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _key_mgr_ll_enable_bus_clock(__VA_ARGS__) +#define key_mgr_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _key_mgr_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Enable the peripheral clock for Key Manager @@ -51,7 +54,10 @@ static inline void _key_mgr_ll_enable_peripheral_clock(bool enable) HP_SYS_CLKRST.peri_clk_ctrl25.reg_crypto_km_clk_en = enable; } -#define key_mgr_ll_enable_peripheral_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _key_mgr_ll_enable_peripheral_clock(__VA_ARGS__) +#define key_mgr_ll_enable_peripheral_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _key_mgr_ll_enable_peripheral_clock(__VA_ARGS__); \ + } while(0) /** * @brief Read state of Key Manager @@ -82,7 +88,10 @@ static inline void _key_mgr_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_ATOMIC_ENV variable in advance -#define key_mgr_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; _key_mgr_ll_reset_register(__VA_ARGS__) +#define key_mgr_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _key_mgr_ll_reset_register(__VA_ARGS__); \ + } while(0) /* @brief Start the key manager at IDLE state */ static inline void key_mgr_ll_start(void) diff --git a/components/hal/esp32p4/include/hal/l2mem_ll.h b/components/hal/esp32p4/include/hal/l2mem_ll.h index 892d871070..2dcfba22ea 100644 --- a/components/hal/esp32p4/include/hal/l2mem_ll.h +++ b/components/hal/esp32p4/include/hal/l2mem_ll.h @@ -37,7 +37,10 @@ static inline void _l2mem_ll_clock_force_en(bool enable) } // HP_SYS_CLKRST.soc_clk_ctrl2 are shared registers, so this function must be used in an atomic way -#define l2mem_ll_clock_force_en(...) (void)__DECLARE_RCC_ATOMIC_ENV; _l2mem_ll_clock_force_en(__VA_ARGS__) +#define l2mem_ll_clock_force_en(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _l2mem_ll_clock_force_en(__VA_ARGS__); \ + } while(0) #ifdef __cplusplus } diff --git a/components/hal/esp32p4/include/hal/lcd_ll.h b/components/hal/esp32p4/include/hal/lcd_ll.h index e468e5c8ae..6fe2897e4f 100644 --- a/components/hal/esp32p4/include/hal/lcd_ll.h +++ b/components/hal/esp32p4/include/hal/lcd_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -56,7 +56,10 @@ static inline void lcd_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 lcd_ll_enable_bus_clock(...) (void)__DECLARE_RCC_RC_ATOMIC_ENV; lcd_ll_enable_bus_clock(__VA_ARGS__) +#define lcd_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_RC_ATOMIC_ENV; \ + lcd_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the LCD module @@ -72,7 +75,10 @@ static inline void _lcd_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 lcd_ll_reset_register(...) (void)__DECLARE_RCC_RC_ATOMIC_ENV; _lcd_ll_reset_register(__VA_ARGS__) +#define lcd_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_RC_ATOMIC_ENV; \ + _lcd_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * @brief Enable clock gating @@ -87,7 +93,10 @@ static inline void lcd_ll_enable_clock(lcd_cam_dev_t *dev, bool en) /// 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_ATOMIC_ENV variable in advance -#define lcd_ll_enable_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; lcd_ll_enable_clock(__VA_ARGS__) +#define lcd_ll_enable_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + lcd_ll_enable_clock(__VA_ARGS__); \ + } while(0) /** * @brief Select clock source for LCD peripheral @@ -116,7 +125,10 @@ static inline void lcd_ll_select_clk_src(lcd_cam_dev_t *dev, lcd_clock_source_t /// 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_ATOMIC_ENV variable in advance -#define lcd_ll_select_clk_src(...) (void)__DECLARE_RCC_ATOMIC_ENV; lcd_ll_select_clk_src(__VA_ARGS__) +#define lcd_ll_select_clk_src(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + lcd_ll_select_clk_src(__VA_ARGS__); \ + } while(0) /** * @brief Set clock coefficient of LCD peripheral @@ -138,7 +150,10 @@ static inline void lcd_ll_set_group_clock_coeff(lcd_cam_dev_t *dev, int div_num, /// 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_ATOMIC_ENV variable in advance -#define lcd_ll_set_group_clock_coeff(...) (void)__DECLARE_RCC_ATOMIC_ENV; lcd_ll_set_group_clock_coeff(__VA_ARGS__) +#define lcd_ll_set_group_clock_coeff(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + lcd_ll_set_group_clock_coeff(__VA_ARGS__); \ + } while(0) /** * @brief Set the PCLK clock level state when there's no transaction undergoing diff --git a/components/hal/esp32p4/include/hal/ledc_ll.h b/components/hal/esp32p4/include/hal/ledc_ll.h index 8871c64623..38c3d5358d 100644 --- a/components/hal/esp32p4/include/hal/ledc_ll.h +++ b/components/hal/esp32p4/include/hal/ledc_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -43,7 +43,10 @@ static inline void ledc_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_ATOMIC_ENV variable in advance -#define ledc_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; ledc_ll_enable_bus_clock(__VA_ARGS__) +#define ledc_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + ledc_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset whole peripheral register to init value defined by HW design @@ -55,7 +58,10 @@ static inline void ledc_ll_enable_reset_reg(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_ATOMIC_ENV variable in advance -#define ledc_ll_enable_reset_reg(...) (void)__DECLARE_RCC_ATOMIC_ENV; ledc_ll_enable_reset_reg(__VA_ARGS__) +#define ledc_ll_enable_reset_reg(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + ledc_ll_enable_reset_reg(__VA_ARGS__); \ + } while(0) /** * @brief Enable the power for LEDC memory block @@ -81,7 +87,10 @@ static inline void ledc_ll_enable_clock(ledc_dev_t *hw, bool en) /// 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_ATOMIC_ENV variable in advance -#define ledc_ll_enable_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; ledc_ll_enable_clock(__VA_ARGS__) +#define ledc_ll_enable_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + ledc_ll_enable_clock(__VA_ARGS__); \ + } while(0) /** * @brief Set LEDC low speed timer clock @@ -115,7 +124,10 @@ static inline void ledc_ll_set_slow_clk_sel(ledc_dev_t *hw, ledc_slow_clk_sel_t /// 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_ATOMIC_ENV variable in advance -#define ledc_ll_set_slow_clk_sel(...) (void)__DECLARE_RCC_ATOMIC_ENV; ledc_ll_set_slow_clk_sel(__VA_ARGS__) +#define ledc_ll_set_slow_clk_sel(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + ledc_ll_set_slow_clk_sel(__VA_ARGS__); \ + } while(0) /** * @brief Get LEDC low speed timer clock diff --git a/components/hal/esp32p4/include/hal/lp_core_ll.h b/components/hal/esp32p4/include/hal/lp_core_ll.h index f309dd9dfa..d8f8e99451 100644 --- a/components/hal/esp32p4/include/hal/lp_core_ll.h +++ b/components/hal/esp32p4/include/hal/lp_core_ll.h @@ -46,7 +46,10 @@ static inline void lp_core_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_ATOMIC_ENV variable in advance -#define lp_core_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; lp_core_ll_enable_bus_clock(__VA_ARGS__) +#define lp_core_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + lp_core_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the lp_core module @@ -60,7 +63,10 @@ static inline void lp_core_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_ATOMIC_ENV variable in advance -#define lp_core_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; lp_core_ll_reset_register(__VA_ARGS__) +#define lp_core_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + lp_core_ll_reset_register(__VA_ARGS__); \ + } while(0) /** diff --git a/components/hal/esp32p4/include/hal/lp_i2s_ll.h b/components/hal/esp32p4/include/hal/lp_i2s_ll.h index ed6851a58c..501ba27b19 100644 --- a/components/hal/esp32p4/include/hal/lp_i2s_ll.h +++ b/components/hal/esp32p4/include/hal/lp_i2s_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -133,7 +133,10 @@ static inline void lp_i2s_ll_enable_module_clock(int id, bool en) /// 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_ATOMIC_ENV variable in advance -#define lp_i2s_ll_enable_module_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; lp_i2s_ll_enable_module_clock(__VA_ARGS__) +#define lp_i2s_ll_enable_module_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + lp_i2s_ll_enable_module_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the LP I2S module @@ -148,7 +151,10 @@ static inline void lp_i2s_ll_reset_module_clock(int 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_ATOMIC_ENV variable in advance -#define lp_i2s_ll_reset_module_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; lp_i2s_ll_reset_module_clock(__VA_ARGS__) +#define lp_i2s_ll_reset_module_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + lp_i2s_ll_reset_module_clock(__VA_ARGS__); \ + } while(0) /** * @brief Enable the bus clock for LP I2S RX module @@ -163,7 +169,10 @@ static inline void lp_i2s_ll_enable_rx_module_clock(int id, bool en) /// 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_ATOMIC_ENV variable in advance -#define lp_i2s_ll_enable_rx_module_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; lp_i2s_ll_enable_rx_module_clock(__VA_ARGS__) +#define lp_i2s_ll_enable_rx_module_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + lp_i2s_ll_enable_rx_module_clock(__VA_ARGS__); \ + } while(0) /** * @brief Select ISP clock source @@ -190,7 +199,10 @@ static inline void lp_i2s_ll_select_rx_clk_source(int id, soc_periph_lp_i2s_clk_ /// 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_ATOMIC_ENV variable in advance -#define lp_i2s_ll_select_rx_clk_source(...) (void)__DECLARE_RCC_ATOMIC_ENV; lp_i2s_ll_select_rx_clk_source(__VA_ARGS__) +#define lp_i2s_ll_select_rx_clk_source(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + lp_i2s_ll_select_rx_clk_source(__VA_ARGS__); \ + } while(0) /** * @brief Set LP I2S clock source div num diff --git a/components/hal/esp32p4/include/hal/mcpwm_ll.h b/components/hal/esp32p4/include/hal/mcpwm_ll.h index 4031c06070..db8f2dd94d 100644 --- a/components/hal/esp32p4/include/hal/mcpwm_ll.h +++ b/components/hal/esp32p4/include/hal/mcpwm_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -110,7 +110,10 @@ static inline void mcpwm_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_ATOMIC_ENV variable in advance -#define mcpwm_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; mcpwm_ll_enable_bus_clock(__VA_ARGS__) +#define mcpwm_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + mcpwm_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the MCPWM module @@ -130,7 +133,10 @@ static inline void mcpwm_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_ATOMIC_ENV variable in advance -#define mcpwm_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; mcpwm_ll_reset_register(__VA_ARGS__) +#define mcpwm_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + mcpwm_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * @brief Enable MCPWM function clock @@ -149,7 +155,10 @@ static inline void mcpwm_ll_group_enable_clock(int group_id, bool en) /// 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_ATOMIC_ENV variable in advance -#define mcpwm_ll_group_enable_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; mcpwm_ll_group_enable_clock(__VA_ARGS__) +#define mcpwm_ll_group_enable_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + mcpwm_ll_group_enable_clock(__VA_ARGS__); \ + } while(0) /** * @brief Set the clock source for MCPWM @@ -183,7 +192,10 @@ static inline void mcpwm_ll_group_set_clock_source(int group_id, soc_module_clk_ /// 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_ATOMIC_ENV variable in advance -#define mcpwm_ll_group_set_clock_source(...) (void)__DECLARE_RCC_ATOMIC_ENV; mcpwm_ll_group_set_clock_source(__VA_ARGS__) +#define mcpwm_ll_group_set_clock_source(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + mcpwm_ll_group_set_clock_source(__VA_ARGS__); \ + } while(0) /** * @brief Set the MCPWM group clock prescale @@ -204,7 +216,10 @@ static inline void mcpwm_ll_group_set_clock_prescale(int group_id, int prescale) /// 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_ATOMIC_ENV variable in advance -#define mcpwm_ll_group_set_clock_prescale(...) (void)__DECLARE_RCC_ATOMIC_ENV; mcpwm_ll_group_set_clock_prescale(__VA_ARGS__) +#define mcpwm_ll_group_set_clock_prescale(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + mcpwm_ll_group_set_clock_prescale(__VA_ARGS__); \ + } while(0) /** * @brief Enable update MCPWM active registers from shadow registers diff --git a/components/hal/esp32p4/include/hal/mipi_csi_ll.h b/components/hal/esp32p4/include/hal/mipi_csi_ll.h index 57cc8c2e0f..a491767f2e 100644 --- a/components/hal/esp32p4/include/hal/mipi_csi_ll.h +++ b/components/hal/esp32p4/include/hal/mipi_csi_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -38,7 +38,10 @@ static inline void mipi_csi_ll_enable_brg_module_clock(int csi_bridge_id, bool e /// 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_ATOMIC_ENV variable in advance -#define mipi_csi_ll_enable_brg_module_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; mipi_csi_ll_enable_brg_module_clock(__VA_ARGS__) +#define mipi_csi_ll_enable_brg_module_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + mipi_csi_ll_enable_brg_module_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the CSI Bridge module @@ -53,7 +56,10 @@ static inline void mipi_csi_ll_reset_brg_module_clock(int csi_bridge_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_ATOMIC_ENV variable in advance -#define mipi_csi_ll_reset_brg_module_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; mipi_csi_ll_reset_brg_module_clock(__VA_ARGS__) +#define mipi_csi_ll_reset_brg_module_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + mipi_csi_ll_reset_brg_module_clock(__VA_ARGS__); \ + } while(0) /*--------------------------------------------------------------- CSI PHY @@ -84,7 +90,10 @@ static inline void mipi_csi_ll_set_phy_clock_source(int group_id, mipi_csi_phy_c /// 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_ATOMIC_ENV variable in advance -#define mipi_csi_ll_set_phy_clock_source(...) (void)__DECLARE_RCC_ATOMIC_ENV; mipi_csi_ll_set_phy_clock_source(__VA_ARGS__) +#define mipi_csi_ll_set_phy_clock_source(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + mipi_csi_ll_set_phy_clock_source(__VA_ARGS__); \ + } while(0) /** * @brief Enable MIPI CSI PHY configuration clock @@ -100,7 +109,10 @@ static inline void mipi_csi_ll_enable_phy_config_clock(int group_id, bool en) /// 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_ATOMIC_ENV variable in advance -#define mipi_csi_ll_enable_phy_config_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; mipi_csi_ll_enable_phy_config_clock(__VA_ARGS__) +#define mipi_csi_ll_enable_phy_config_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + mipi_csi_ll_enable_phy_config_clock(__VA_ARGS__); \ + } while(0) /*--------------------------------------------------------------- CSI Host @@ -119,7 +131,10 @@ static inline void _mipi_csi_ll_enable_host_bus_clock(int group_id, bool en) /// 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_ATOMIC_ENV variable in advance -#define mipi_csi_ll_enable_host_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _mipi_csi_ll_enable_host_bus_clock(__VA_ARGS__) +#define mipi_csi_ll_enable_host_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _mipi_csi_ll_enable_host_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the MIPI CSI host CLK @@ -135,7 +150,10 @@ static inline void mipi_csi_ll_reset_host_clock(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_ATOMIC_ENV variable in advance -#define mipi_csi_ll_reset_host_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; mipi_csi_ll_reset_host_clock(__VA_ARGS__) +#define mipi_csi_ll_reset_host_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + mipi_csi_ll_reset_host_clock(__VA_ARGS__); \ + } while(0) #ifdef __cplusplus } diff --git a/components/hal/esp32p4/include/hal/mipi_dsi_ll.h b/components/hal/esp32p4/include/hal/mipi_dsi_ll.h index 3ea1767a7c..d735a543e3 100644 --- a/components/hal/esp32p4/include/hal/mipi_dsi_ll.h +++ b/components/hal/esp32p4/include/hal/mipi_dsi_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -35,7 +35,10 @@ static inline void _mipi_dsi_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_ATOMIC_ENV variable in advance -#define mipi_dsi_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _mipi_dsi_ll_enable_bus_clock(__VA_ARGS__) +#define mipi_dsi_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _mipi_dsi_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the MIPI DSI module @@ -51,7 +54,10 @@ static inline void mipi_dsi_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_ATOMIC_ENV variable in advance -#define mipi_dsi_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; mipi_dsi_ll_reset_register(__VA_ARGS__) +#define mipi_dsi_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + mipi_dsi_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * @brief Enable MIPI DSI DPI clock @@ -67,7 +73,10 @@ static inline void mipi_dsi_ll_enable_dpi_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_ATOMIC_ENV variable in advance -#define mipi_dsi_ll_enable_dpi_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; mipi_dsi_ll_enable_dpi_clock(__VA_ARGS__) +#define mipi_dsi_ll_enable_dpi_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + mipi_dsi_ll_enable_dpi_clock(__VA_ARGS__); \ + } while(0) /** * @brief Set the clock source for the DSI DPI interface @@ -95,7 +104,10 @@ static inline void mipi_dsi_ll_set_dpi_clock_source(int group_id, mipi_dsi_dpi_c /// 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_ATOMIC_ENV variable in advance -#define mipi_dsi_ll_set_dpi_clock_source(...) (void)__DECLARE_RCC_ATOMIC_ENV; mipi_dsi_ll_set_dpi_clock_source(__VA_ARGS__) +#define mipi_dsi_ll_set_dpi_clock_source(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + mipi_dsi_ll_set_dpi_clock_source(__VA_ARGS__); \ + } while(0) /** * @brief Set the clock division factor for the DPI clock source @@ -111,7 +123,10 @@ static inline void mipi_dsi_ll_set_dpi_clock_div(int group_id, uint32_t div) /// 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_ATOMIC_ENV variable in advance -#define mipi_dsi_ll_set_dpi_clock_div(...) (void)__DECLARE_RCC_ATOMIC_ENV; mipi_dsi_ll_set_dpi_clock_div(__VA_ARGS__) +#define mipi_dsi_ll_set_dpi_clock_div(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + mipi_dsi_ll_set_dpi_clock_div(__VA_ARGS__); \ + } while(0) /** * @brief Enable MIPI DSI PHY configuration clock @@ -127,7 +142,10 @@ static inline void mipi_dsi_ll_enable_phy_config_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_ATOMIC_ENV variable in advance -#define mipi_dsi_ll_enable_phy_config_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; mipi_dsi_ll_enable_phy_config_clock(__VA_ARGS__) +#define mipi_dsi_ll_enable_phy_config_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + mipi_dsi_ll_enable_phy_config_clock(__VA_ARGS__); \ + } while(0) /** * @brief Enable MIPI DSI PHY PLL reference clock @@ -143,7 +161,10 @@ static inline void mipi_dsi_ll_enable_phy_reference_clock(int group_id, bool ena /// 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_ATOMIC_ENV variable in advance -#define mipi_dsi_ll_enable_phy_reference_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; mipi_dsi_ll_enable_phy_reference_clock(__VA_ARGS__) +#define mipi_dsi_ll_enable_phy_reference_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + mipi_dsi_ll_enable_phy_reference_clock(__VA_ARGS__); \ + } while(0) /** * @brief Set the clock source for the DSI PHY interface @@ -171,7 +192,10 @@ static inline void mipi_dsi_ll_set_phy_clock_source(int group_id, mipi_dsi_phy_c /// 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_ATOMIC_ENV variable in advance -#define mipi_dsi_ll_set_phy_clock_source(...) (void)__DECLARE_RCC_ATOMIC_ENV; mipi_dsi_ll_set_phy_clock_source(__VA_ARGS__) +#define mipi_dsi_ll_set_phy_clock_source(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + mipi_dsi_ll_set_phy_clock_source(__VA_ARGS__); \ + } while(0) #ifdef __cplusplus } diff --git a/components/hal/esp32p4/include/hal/mpi_ll.h b/components/hal/esp32p4/include/hal/mpi_ll.h index ba31a2ddbe..090862c060 100644 --- a/components/hal/esp32p4/include/hal/mpi_ll.h +++ b/components/hal/esp32p4/include/hal/mpi_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -30,7 +30,10 @@ static inline void _mpi_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_ATOMIC_ENV variable in advance -#define mpi_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _mpi_ll_enable_bus_clock(__VA_ARGS__) +#define mpi_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _mpi_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the MPI peripheral module @@ -48,7 +51,10 @@ static inline void mpi_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_ATOMIC_ENV variable in advance -#define mpi_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; mpi_ll_reset_register(__VA_ARGS__) +#define mpi_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + mpi_ll_reset_register(__VA_ARGS__); \ + } while(0) static inline size_t mpi_ll_calculate_hardware_words(size_t words) { diff --git a/components/hal/esp32p4/include/hal/mspi_ll.h b/components/hal/esp32p4/include/hal/mspi_ll.h index faadbc3ec7..2c760bd781 100644 --- a/components/hal/esp32p4/include/hal/mspi_ll.h +++ b/components/hal/esp32p4/include/hal/mspi_ll.h @@ -134,7 +134,10 @@ static inline void _mspi_timing_ll_reset_mspi(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 mspi_timing_ll_reset_mspi(...) (void)__DECLARE_RCC_RC_ATOMIC_ENV; _mspi_timing_ll_reset_mspi(__VA_ARGS__) +#define mspi_timing_ll_reset_mspi(...) do { \ + (void)__DECLARE_RCC_RC_ATOMIC_ENV; \ + _mspi_timing_ll_reset_mspi(__VA_ARGS__); \ + } while(0) /*--------------------------------------------------------------- PSRAM tuning @@ -289,7 +292,10 @@ static inline void _mspi_timing_ll_set_flash_clk_src(uint32_t mspi_id, soc_perip /// 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_ATOMIC_ENV variable in advance -#define mspi_timing_ll_set_flash_clk_src(...) (void)__DECLARE_RCC_ATOMIC_ENV; _mspi_timing_ll_set_flash_clk_src(__VA_ARGS__) +#define mspi_timing_ll_set_flash_clk_src(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _mspi_timing_ll_set_flash_clk_src(__VA_ARGS__); \ + } while(0) /** * Set MSPI Flash core clock @@ -315,7 +321,10 @@ static inline void _mspi_timing_ll_set_flash_core_clock(int spi_num, uint32_t co /// 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_ATOMIC_ENV variable in advance -#define mspi_timing_ll_set_flash_core_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _mspi_timing_ll_set_flash_core_clock(__VA_ARGS__) +#define mspi_timing_ll_set_flash_core_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _mspi_timing_ll_set_flash_core_clock(__VA_ARGS__); \ + } while(0) /** * Set MSPI Flash clock diff --git a/components/hal/esp32p4/include/hal/parlio_ll.h b/components/hal/esp32p4/include/hal/parlio_ll.h index b7c323c9bc..2e6327394f 100644 --- a/components/hal/esp32p4/include/hal/parlio_ll.h +++ b/components/hal/esp32p4/include/hal/parlio_ll.h @@ -65,7 +65,10 @@ static inline void _parlio_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_ATOMIC_ENV variable in advance -#define parlio_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _parlio_ll_enable_bus_clock(__VA_ARGS__) +#define parlio_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _parlio_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the parlio module @@ -81,7 +84,10 @@ static inline void _parlio_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_ATOMIC_ENV variable in advance -#define parlio_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; _parlio_ll_reset_register(__VA_ARGS__) +#define parlio_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _parlio_ll_reset_register(__VA_ARGS__); \ + } while(0) ///////////////////////////////////////RX Unit/////////////////////////////////////// @@ -118,7 +124,10 @@ static inline void _parlio_ll_rx_set_clock_source(parl_io_dev_t *dev, parlio_clo /// 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_ATOMIC_ENV variable in advance -#define parlio_ll_rx_set_clock_source(...) (void)__DECLARE_RCC_ATOMIC_ENV; _parlio_ll_rx_set_clock_source(__VA_ARGS__) +#define parlio_ll_rx_set_clock_source(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _parlio_ll_rx_set_clock_source(__VA_ARGS__); \ + } while(0) /** * @brief Set the clock divider for the RX unit @@ -137,7 +146,10 @@ static inline void _parlio_ll_rx_set_clock_div(parl_io_dev_t *dev, const hal_uti /// 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_ATOMIC_ENV variable in advance -#define parlio_ll_rx_set_clock_div(...) (void)__DECLARE_RCC_ATOMIC_ENV; _parlio_ll_rx_set_clock_div(__VA_ARGS__) +#define parlio_ll_rx_set_clock_div(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _parlio_ll_rx_set_clock_div(__VA_ARGS__); \ + } while(0) /** * @brief Reset the RX unit Core clock domain @@ -153,7 +165,10 @@ static inline void _parlio_ll_rx_reset_clock(parl_io_dev_t *dev) /// 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_ATOMIC_ENV variable in advance -#define parlio_ll_rx_reset_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _parlio_ll_rx_reset_clock(__VA_ARGS__) +#define parlio_ll_rx_reset_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _parlio_ll_rx_reset_clock(__VA_ARGS__); \ + } while(0) /** * @brief Enable the RX unit Core clock domain @@ -171,7 +186,10 @@ static inline void _parlio_ll_rx_enable_clock(parl_io_dev_t *dev, bool en) /// 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_ATOMIC_ENV variable in advance -#define parlio_ll_rx_enable_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _parlio_ll_rx_enable_clock(__VA_ARGS__) +#define parlio_ll_rx_enable_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _parlio_ll_rx_enable_clock(__VA_ARGS__); \ + } while(0) /** * @brief Set the condition to generate the RX EOF event @@ -455,7 +473,10 @@ static inline void _parlio_ll_tx_set_clock_source(parl_io_dev_t *dev, parlio_clo /// 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_ATOMIC_ENV variable in advance -#define parlio_ll_tx_set_clock_source(...) (void)__DECLARE_RCC_ATOMIC_ENV; _parlio_ll_tx_set_clock_source(__VA_ARGS__) +#define parlio_ll_tx_set_clock_source(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _parlio_ll_tx_set_clock_source(__VA_ARGS__); \ + } while(0) /** * @brief Set the clock divider for the TX unit @@ -474,7 +495,10 @@ static inline void _parlio_ll_tx_set_clock_div(parl_io_dev_t *dev, const hal_uti /// 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_ATOMIC_ENV variable in advance -#define parlio_ll_tx_set_clock_div(...) (void)__DECLARE_RCC_ATOMIC_ENV; _parlio_ll_tx_set_clock_div(__VA_ARGS__) +#define parlio_ll_tx_set_clock_div(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _parlio_ll_tx_set_clock_div(__VA_ARGS__); \ + } while(0) /** * @brief Reset the TX unit Core clock domain @@ -491,7 +515,10 @@ static inline void _parlio_ll_tx_reset_clock(parl_io_dev_t *dev) /// 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_ATOMIC_ENV variable in advance -#define parlio_ll_tx_reset_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _parlio_ll_tx_reset_clock(__VA_ARGS__) +#define parlio_ll_tx_reset_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _parlio_ll_tx_reset_clock(__VA_ARGS__); \ + } while(0) /** * @brief Enable the TX unit Core clock domain @@ -509,7 +536,10 @@ static inline void _parlio_ll_tx_enable_clock(parl_io_dev_t *dev, bool en) /// 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_ATOMIC_ENV variable in advance -#define parlio_ll_tx_enable_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _parlio_ll_tx_enable_clock(__VA_ARGS__) +#define parlio_ll_tx_enable_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _parlio_ll_tx_enable_clock(__VA_ARGS__); \ + } while(0) /** * @brief Set the data length to be transmitted diff --git a/components/hal/esp32p4/include/hal/pau_ll.h b/components/hal/esp32p4/include/hal/pau_ll.h index 40ef69d180..a454a64db2 100644 --- a/components/hal/esp32p4/include/hal/pau_ll.h +++ b/components/hal/esp32p4/include/hal/pau_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -35,7 +35,10 @@ static inline void _pau_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_ATOMIC_ENV variable in advance -#define pau_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _pau_ll_enable_bus_clock(__VA_ARGS__) +#define pau_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _pau_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) static inline uint32_t pau_ll_get_regdma_backup_flow_error(pau_dev_t *dev) { diff --git a/components/hal/esp32p4/include/hal/pcnt_ll.h b/components/hal/esp32p4/include/hal/pcnt_ll.h index c73b9d8fed..3a9cabcf90 100644 --- a/components/hal/esp32p4/include/hal/pcnt_ll.h +++ b/components/hal/esp32p4/include/hal/pcnt_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -493,7 +493,10 @@ static inline void pcnt_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_ATOMIC_ENV variable in advance -#define pcnt_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; pcnt_ll_enable_bus_clock(__VA_ARGS__) +#define pcnt_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + pcnt_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the PCNT module @@ -507,7 +510,10 @@ static inline void pcnt_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_ATOMIC_ENV variable in advance -#define pcnt_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; pcnt_ll_reset_register(__VA_ARGS__) +#define pcnt_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + pcnt_ll_reset_register(__VA_ARGS__); \ + } while(0) #ifdef __cplusplus } diff --git a/components/hal/esp32p4/include/hal/ppa_ll.h b/components/hal/esp32p4/include/hal/ppa_ll.h index 1d82fdce92..017e658daf 100644 --- a/components/hal/esp32p4/include/hal/ppa_ll.h +++ b/components/hal/esp32p4/include/hal/ppa_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -53,7 +53,10 @@ static inline void ppa_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_ATOMIC_ENV variable in advance -#define ppa_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; ppa_ll_enable_bus_clock(__VA_ARGS__) +#define ppa_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + ppa_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the PPA module @@ -66,7 +69,10 @@ static inline void ppa_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_ATOMIC_ENV variable in advance -#define ppa_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; ppa_ll_reset_register(__VA_ARGS__) +#define ppa_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + ppa_ll_reset_register(__VA_ARGS__); \ + } while(0) ///////////////////////// Scaling, Rotating, Mirroring (SRM) ////////////////////////////// /** diff --git a/components/hal/esp32p4/include/hal/psram_ctrlr_ll.h b/components/hal/esp32p4/include/hal/psram_ctrlr_ll.h index 7579bd674e..1f0d32da71 100644 --- a/components/hal/esp32p4/include/hal/psram_ctrlr_ll.h +++ b/components/hal/esp32p4/include/hal/psram_ctrlr_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -298,7 +298,10 @@ static inline void _psram_ctrlr_ll_enable_module_clock(uint32_t mspi_id, bool en /// 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_ATOMIC_ENV variable in advance -#define psram_ctrlr_ll_enable_module_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _psram_ctrlr_ll_enable_module_clock(__VA_ARGS__) +#define psram_ctrlr_ll_enable_module_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _psram_ctrlr_ll_enable_module_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset PSRAM module clock @@ -317,7 +320,10 @@ static inline void psram_ctrlr_ll_reset_module_clock(uint32_t mspi_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_ATOMIC_ENV variable in advance -#define psram_ctrlr_ll_reset_module_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; psram_ctrlr_ll_reset_module_clock(__VA_ARGS__) +#define psram_ctrlr_ll_reset_module_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + psram_ctrlr_ll_reset_module_clock(__VA_ARGS__); \ + } while(0) /** * @brief Select PSRAM clock source @@ -353,7 +359,10 @@ static inline void _psram_ctrlr_ll_select_clk_source(uint32_t mspi_id, soc_perip /// 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_ATOMIC_ENV variable in advance -#define psram_ctrlr_ll_select_clk_source(...) (void)__DECLARE_RCC_ATOMIC_ENV; _psram_ctrlr_ll_select_clk_source(__VA_ARGS__) +#define psram_ctrlr_ll_select_clk_source(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _psram_ctrlr_ll_select_clk_source(__VA_ARGS__); \ + } while(0) /** * @brief Set PSRAM core clock @@ -369,7 +378,10 @@ static inline void _psram_ctrlr_ll_set_core_clock_div(uint8_t spi_num, uint32_t /// 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_ATOMIC_ENV variable in advance -#define psram_ctrlr_ll_set_core_clock_div(...) (void)__DECLARE_RCC_ATOMIC_ENV; _psram_ctrlr_ll_set_core_clock_div(__VA_ARGS__) +#define psram_ctrlr_ll_set_core_clock_div(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _psram_ctrlr_ll_set_core_clock_div(__VA_ARGS__); \ + } while(0) /** * @brief Enable or disable the PSRAM core clock @@ -384,7 +396,10 @@ static inline void _psram_ctrlr_ll_enable_core_clock(uint8_t spi_num, bool en) /// 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_ATOMIC_ENV variable in advance -#define psram_ctrlr_ll_enable_core_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _psram_ctrlr_ll_enable_core_clock(__VA_ARGS__) +#define psram_ctrlr_ll_enable_core_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _psram_ctrlr_ll_enable_core_clock(__VA_ARGS__); \ + } while(0) /** * @brief Set PSRAM bus clock diff --git a/components/hal/esp32p4/include/hal/regi2c_ctrl_ll.h b/components/hal/esp32p4/include/hal/regi2c_ctrl_ll.h index a548826eb9..6d4f97b96a 100644 --- a/components/hal/esp32p4/include/hal/regi2c_ctrl_ll.h +++ b/components/hal/esp32p4/include/hal/regi2c_ctrl_ll.h @@ -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 diff --git a/components/hal/esp32p4/include/hal/rmt_ll.h b/components/hal/esp32p4/include/hal/rmt_ll.h index 59e04d3ad7..4651fb720a 100644 --- a/components/hal/esp32p4/include/hal/rmt_ll.h +++ b/components/hal/esp32p4/include/hal/rmt_ll.h @@ -61,7 +61,10 @@ static inline void rmt_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_ATOMIC_ENV variable in advance -#define rmt_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; rmt_ll_enable_bus_clock(__VA_ARGS__) +#define rmt_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + rmt_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the RMT module @@ -77,7 +80,10 @@ static inline void rmt_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_ATOMIC_ENV variable in advance -#define rmt_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; rmt_ll_reset_register(__VA_ARGS__) +#define rmt_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + rmt_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * @brief Set clock source and divider for RMT channel group @@ -117,7 +123,10 @@ static inline void rmt_ll_set_group_clock_src(rmt_dev_t *dev, uint32_t channel, /// 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_ATOMIC_ENV variable in advance -#define rmt_ll_set_group_clock_src(...) (void)__DECLARE_RCC_ATOMIC_ENV; rmt_ll_set_group_clock_src(__VA_ARGS__) +#define rmt_ll_set_group_clock_src(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + rmt_ll_set_group_clock_src(__VA_ARGS__); \ + } while(0) /** * @brief Enable RMT peripheral source clock @@ -133,7 +142,10 @@ static inline void rmt_ll_enable_group_clock(rmt_dev_t *dev, bool en) /// 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_ATOMIC_ENV variable in advance -#define rmt_ll_enable_group_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; rmt_ll_enable_group_clock(__VA_ARGS__) +#define rmt_ll_enable_group_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + rmt_ll_enable_group_clock(__VA_ARGS__); \ + } while(0) /** * @brief Enable clock gate for register and memory diff --git a/components/hal/esp32p4/include/hal/rtc_io_ll.h b/components/hal/esp32p4/include/hal/rtc_io_ll.h index e0d56fd658..3c44e8a489 100644 --- a/components/hal/esp32p4/include/hal/rtc_io_ll.h +++ b/components/hal/esp32p4/include/hal/rtc_io_ll.h @@ -102,7 +102,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 lp_gpio/hp_gpio function to control the pad. diff --git a/components/hal/esp32p4/include/hal/sdmmc_ll.h b/components/hal/esp32p4/include/hal/sdmmc_ll.h index 8ac6a8ad2b..509793e3aa 100644 --- a/components/hal/esp32p4/include/hal/sdmmc_ll.h +++ b/components/hal/esp32p4/include/hal/sdmmc_ll.h @@ -145,7 +145,10 @@ static inline void sdmmc_ll_enable_bus_clock(int group_id, bool en) /// 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_ATOMIC_ENV variable in advance -#define sdmmc_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; sdmmc_ll_enable_bus_clock(__VA_ARGS__) +#define sdmmc_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + sdmmc_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the SDMMC module @@ -161,7 +164,10 @@ static inline void sdmmc_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_ATOMIC_ENV variable in advance -#define sdmmc_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; sdmmc_ll_reset_register(__VA_ARGS__) +#define sdmmc_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + sdmmc_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * @brief Enable the bus clock for SDIO PLL @@ -192,7 +198,10 @@ static inline void sdmmc_ll_enable_sdio_pll(sdmmc_dev_t *hw, bool en) /// 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_ATOMIC_ENV variable in advance -#define sdmmc_ll_enable_sdio_pll(...) (void)__DECLARE_RCC_ATOMIC_ENV; sdmmc_ll_enable_sdio_pll(__VA_ARGS__) +#define sdmmc_ll_enable_sdio_pll(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + sdmmc_ll_enable_sdio_pll(__VA_ARGS__); \ + } while(0) /** * @brief Select SDMMC clock source @@ -221,7 +230,10 @@ static inline void sdmmc_ll_select_clk_source(sdmmc_dev_t *hw, soc_periph_sdmmc_ /// 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_ATOMIC_ENV variable in advance -#define sdmmc_ll_select_clk_source(...) (void)__DECLARE_RCC_ATOMIC_ENV; sdmmc_ll_select_clk_source(__VA_ARGS__) +#define sdmmc_ll_select_clk_source(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + sdmmc_ll_select_clk_source(__VA_ARGS__); \ + } while(0) /** * @brief Set SDMMC clock div @@ -247,7 +259,10 @@ static inline void sdmmc_ll_set_clock_div(sdmmc_dev_t *hw, uint32_t div) /// 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_ATOMIC_ENV variable in advance -#define sdmmc_ll_set_clock_div(...) (void)__DECLARE_RCC_ATOMIC_ENV; sdmmc_ll_set_clock_div(__VA_ARGS__) +#define sdmmc_ll_set_clock_div(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + sdmmc_ll_set_clock_div(__VA_ARGS__); \ + } while(0) /** * @brief Deinit clock @@ -301,7 +316,10 @@ static inline void sdmmc_ll_init_phase_delay(sdmmc_dev_t *hw) /// 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_ATOMIC_ENV variable in advance -#define sdmmc_ll_init_phase_delay(...) (void)__DECLARE_RCC_ATOMIC_ENV; sdmmc_ll_init_phase_delay(__VA_ARGS__) +#define sdmmc_ll_init_phase_delay(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + sdmmc_ll_init_phase_delay(__VA_ARGS__); \ + } while(0) /** * @brief Set SDMMC din delay phase @@ -334,7 +352,10 @@ static inline void sdmmc_ll_set_din_delay_phase(sdmmc_dev_t *hw, sdmmc_ll_delay_ /// 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_ATOMIC_ENV variable in advance -#define sdmmc_ll_set_din_delay_phase(...) (void)__DECLARE_RCC_ATOMIC_ENV; sdmmc_ll_set_din_delay_phase(__VA_ARGS__) +#define sdmmc_ll_set_din_delay_phase(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + sdmmc_ll_set_din_delay_phase(__VA_ARGS__); \ + } while(0) /** * @brief Set SDMMC dout delay phase diff --git a/components/hal/esp32p4/include/hal/sha_ll.h b/components/hal/esp32p4/include/hal/sha_ll.h index bcf0f9fa6c..05cc64b058 100644 --- a/components/hal/esp32p4/include/hal/sha_ll.h +++ b/components/hal/esp32p4/include/hal/sha_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -26,7 +26,10 @@ static inline void _sha_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_ATOMIC_ENV variable in advance -#define sha_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _sha_ll_enable_bus_clock(__VA_ARGS__) +#define sha_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _sha_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the SHA peripheral module @@ -45,7 +48,10 @@ static inline void sha_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_ATOMIC_ENV variable in advance -#define sha_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; sha_ll_reset_register(__VA_ARGS__) +#define sha_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + sha_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * @brief Start a new SHA block conversions (no initial hash in HW) diff --git a/components/hal/esp32p4/include/hal/spi_ll.h b/components/hal/esp32p4/include/hal/spi_ll.h index f2ccadf0d7..70ce05cb9d 100644 --- a/components/hal/esp32p4/include/hal/spi_ll.h +++ b/components/hal/esp32p4/include/hal/spi_ll.h @@ -115,7 +115,10 @@ static inline void _spi_ll_enable_bus_clock(spi_host_device_t host_id, bool enab /// 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_ATOMIC_ENV variable in advance -#define spi_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _spi_ll_enable_bus_clock(__VA_ARGS__) +#define spi_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _spi_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * Reset whole peripheral register to init value defined by HW design @@ -139,7 +142,10 @@ static inline void spi_ll_reset_register(spi_host_device_t host_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_ATOMIC_ENV variable in advance -#define spi_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; spi_ll_reset_register(__VA_ARGS__) +#define spi_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + spi_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * Enable functional output clock within peripheral @@ -164,7 +170,10 @@ static inline void _spi_ll_enable_clock(spi_host_device_t host_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_ATOMIC_ENV variable in advance -#define spi_ll_enable_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _spi_ll_enable_clock(__VA_ARGS__) +#define spi_ll_enable_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _spi_ll_enable_clock(__VA_ARGS__); \ + } while(0) /** * Select SPI peripheral clock source (master). @@ -199,7 +208,10 @@ static inline void spi_ll_set_clk_source(spi_dev_t *hw, spi_clock_source_t clk_s /// 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_ATOMIC_ENV variable in advance -#define spi_ll_set_clk_source(...) (void)__DECLARE_RCC_ATOMIC_ENV; spi_ll_set_clk_source(__VA_ARGS__) +#define spi_ll_set_clk_source(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + spi_ll_set_clk_source(__VA_ARGS__); \ + } while(0) /** * Config clock source integrate pre_div before it enter GPSPI peripheral @@ -225,7 +237,10 @@ static inline void spi_ll_clk_source_pre_div(spi_dev_t *hw, uint8_t hs_div, uint /// 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_ATOMIC_ENV variable in advance -#define spi_ll_clk_sour_pre_div(...) (void)__DECLARE_RCC_ATOMIC_ENV; spi_ll_clk_sour_pre_div(__VA_ARGS__) +#define spi_ll_clk_sour_pre_div(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + spi_ll_clk_sour_pre_div(__VA_ARGS__); \ + } while(0) /** * Initialize SPI peripheral (master). diff --git a/components/hal/esp32p4/include/hal/spimem_flash_ll.h b/components/hal/esp32p4/include/hal/spimem_flash_ll.h index 309568cc43..03267c5b79 100644 --- a/components/hal/esp32p4/include/hal/spimem_flash_ll.h +++ b/components/hal/esp32p4/include/hal/spimem_flash_ll.h @@ -747,7 +747,10 @@ static inline void _spimem_ctrlr_ll_unset_clock(uint8_t mspi_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_ATOMIC_ENV variable in advance -#define spimem_ctrlr_ll_unset_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _spimem_ctrlr_ll_unset_clock(__VA_ARGS__) +#define spimem_ctrlr_ll_unset_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _spimem_ctrlr_ll_unset_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset whole memory spi diff --git a/components/hal/esp32p4/include/hal/systimer_ll.h b/components/hal/esp32p4/include/hal/systimer_ll.h index e082de3e75..6e956d774c 100644 --- a/components/hal/esp32p4/include/hal/systimer_ll.h +++ b/components/hal/esp32p4/include/hal/systimer_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -34,7 +34,10 @@ static inline void systimer_ll_set_clock_source(soc_periph_systimer_clk_src_t cl /// 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_ATOMIC_ENV variable in advance -#define systimer_ll_set_clock_source(...) (void)__DECLARE_RCC_ATOMIC_ENV; systimer_ll_set_clock_source(__VA_ARGS__) +#define systimer_ll_set_clock_source(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + systimer_ll_set_clock_source(__VA_ARGS__); \ + } while(0) static inline soc_periph_systimer_clk_src_t systimer_ll_get_clock_source(void) { @@ -53,7 +56,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 @@ -68,7 +74,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 *****************************/ diff --git a/components/hal/esp32p4/include/hal/timer_ll.h b/components/hal/esp32p4/include/hal/timer_ll.h index 5d5c203b2f..b76902ab15 100644 --- a/components/hal/esp32p4/include/hal/timer_ll.h +++ b/components/hal/esp32p4/include/hal/timer_ll.h @@ -98,7 +98,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 @@ -124,7 +127,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 @@ -167,7 +173,10 @@ static inline void timer_ll_set_clock_source(int group_id, uint32_t timer_num, g /// 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_ATOMIC_ENV variable in advance -#define timer_ll_set_clock_source(...) (void)__DECLARE_RCC_ATOMIC_ENV; timer_ll_set_clock_source(__VA_ARGS__) +#define timer_ll_set_clock_source(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + timer_ll_set_clock_source(__VA_ARGS__); \ + } while(0) /** * @brief Enable Timer Group (GPTimer) module clock @@ -195,7 +204,10 @@ static inline void _timer_ll_enable_clock(int group_id, uint32_t timer_num, bool /// 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_ATOMIC_ENV variable in advance -#define timer_ll_enable_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _timer_ll_enable_clock(__VA_ARGS__) +#define timer_ll_enable_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _timer_ll_enable_clock(__VA_ARGS__); \ + } while(0) /** * @brief Enable alarm event diff --git a/components/hal/esp32p4/include/hal/twai_ll.h b/components/hal/esp32p4/include/hal/twai_ll.h index e0f2478db1..d23affc076 100644 --- a/components/hal/esp32p4/include/hal/twai_ll.h +++ b/components/hal/esp32p4/include/hal/twai_ll.h @@ -160,7 +160,10 @@ static inline void twai_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_ATOMIC_ENV variable in advance -#define twai_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; twai_ll_enable_bus_clock(__VA_ARGS__) +#define twai_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + twai_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the twai module @@ -186,7 +189,10 @@ static inline void twai_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_ATOMIC_ENV variable in advance -#define twai_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; twai_ll_reset_register(__VA_ARGS__) +#define twai_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + twai_ll_reset_register(__VA_ARGS__); \ + } while(0) /* ---------------------------- Peripheral Control Register ----------------- */ @@ -209,7 +215,10 @@ static inline void twai_ll_enable_clock(int group_id, bool en) /// 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_ATOMIC_ENV variable in advance -#define twai_ll_enable_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; twai_ll_enable_clock(__VA_ARGS__) +#define twai_ll_enable_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + twai_ll_enable_clock(__VA_ARGS__); \ + } while(0) /** * @brief Set clock source for TWAI module @@ -240,7 +249,10 @@ static inline void twai_ll_set_clock_source(int group_id, twai_clock_source_t cl /// 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_ATOMIC_ENV variable in advance -#define twai_ll_set_clock_source(...) (void)__DECLARE_RCC_ATOMIC_ENV; twai_ll_set_clock_source(__VA_ARGS__) +#define twai_ll_set_clock_source(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + twai_ll_set_clock_source(__VA_ARGS__); \ + } while(0) /* ---------------------------- Mode Register ------------------------------- */ /** diff --git a/components/hal/esp32p4/include/hal/uart_ll.h b/components/hal/esp32p4/include/hal/uart_ll.h index 38657c2b6b..0e831395a3 100644 --- a/components/hal/esp32p4/include/hal/uart_ll.h +++ b/components/hal/esp32p4/include/hal/uart_ll.h @@ -138,7 +138,10 @@ static inline void lp_uart_ll_set_source_clk(uart_dev_t *hw, soc_periph_lp_uart_ } // LPPERI.core_clk_sel 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. @@ -181,7 +184,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. @@ -220,7 +226,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 ******************************************/ @@ -312,7 +321,10 @@ static inline void _uart_ll_enable_bus_clock(uart_port_t uart_num, bool enable) } } // HP_SYS_CLKRST.soc_clk_ctrlx are shared registers, so this function must be used in an atomic way -#define uart_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _uart_ll_enable_bus_clock(__VA_ARGS__) +#define uart_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _uart_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset UART module @@ -350,7 +362,10 @@ static inline void uart_ll_reset_register(uart_port_t uart_num) } } // HP_SYS_CLKRST.hp_rst_en1 is a shared register, so this function must be used in an atomic way -#define uart_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; uart_ll_reset_register(__VA_ARGS__) +#define uart_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + uart_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * @brief Enable the UART clock. @@ -380,7 +395,10 @@ FORCE_INLINE_ATTR void _uart_ll_sclk_enable(uart_dev_t *hw) hw->clk_conf.rx_sclk_en = 1; } // HP_SYS_CLKRST.peri_clk_ctrlxxx are shared registers, so this function must be used in an atomic way -#define uart_ll_sclk_enable(...) (void)__DECLARE_RCC_ATOMIC_ENV; _uart_ll_sclk_enable(__VA_ARGS__) +#define uart_ll_sclk_enable(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _uart_ll_sclk_enable(__VA_ARGS__); \ + } while(0) /** * @brief Disable the UART clock. @@ -409,7 +427,10 @@ FORCE_INLINE_ATTR void _uart_ll_sclk_disable(uart_dev_t *hw) hw->clk_conf.rx_sclk_en = 0; } // HP_SYS_CLKRST.peri_clk_ctrlxxx are shared registers, so this function must be used in an atomic way -#define uart_ll_sclk_disable(...) (void)__DECLARE_RCC_ATOMIC_ENV; _uart_ll_sclk_disable(__VA_ARGS__) +#define uart_ll_sclk_disable(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _uart_ll_sclk_disable(__VA_ARGS__); \ + } while(0) /** * @brief Set the UART source clock. @@ -453,7 +474,10 @@ FORCE_INLINE_ATTR void uart_ll_set_sclk(uart_dev_t *hw, soc_module_clk_t source_ } } //HP_SYS_CLKRST.peri_clk_ctrlxxx are shared registers, so this function must be used in an atomic way -#define uart_ll_set_sclk(...) (void)__DECLARE_RCC_ATOMIC_ENV; uart_ll_set_sclk(__VA_ARGS__) +#define uart_ll_set_sclk(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + uart_ll_set_sclk(__VA_ARGS__); \ + } while(0) /** * @brief Get the UART source clock type. @@ -1155,7 +1179,10 @@ FORCE_INLINE_ATTR void _uart_ll_enable_pad_sleep_clock(uart_dev_t *hw, bool enab } // LP_AON_CLKRST.hp_clk_ctrl is a shared register, so this function must be used in an atomic way -#define uart_ll_enable_pad_sleep_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _uart_ll_enable_pad_sleep_clock(__VA_ARGS__) +#define uart_ll_enable_pad_sleep_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _uart_ll_enable_pad_sleep_clock(__VA_ARGS__); \ + } while(0) /** * @brief Configure the UART work in normal mode. diff --git a/components/hal/esp32p4/include/hal/uhci_ll.h b/components/hal/esp32p4/include/hal/uhci_ll.h index 70066c14ab..1cd15fddce 100644 --- a/components/hal/esp32p4/include/hal/uhci_ll.h +++ b/components/hal/esp32p4/include/hal/uhci_ll.h @@ -43,7 +43,10 @@ static inline void _uhci_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_ATOMIC_ENV variable in advance -#define uhci_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _uhci_ll_enable_bus_clock(__VA_ARGS__) +#define uhci_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _uhci_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the UHCI module @@ -59,7 +62,10 @@ static inline void _uhci_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_ATOMIC_ENV variable in advance -#define uhci_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; _uhci_ll_reset_register(__VA_ARGS__) +#define uhci_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _uhci_ll_reset_register(__VA_ARGS__); \ + } while(0) static inline void uhci_ll_init(uhci_dev_t *hw) { diff --git a/components/hal/esp32p4/include/hal/usb_serial_jtag_ll.h b/components/hal/esp32p4/include/hal/usb_serial_jtag_ll.h index 83d5fdcdc7..fbeca6737f 100644 --- a/components/hal/esp32p4/include/hal/usb_serial_jtag_ll.h +++ b/components/hal/esp32p4/include/hal/usb_serial_jtag_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -341,7 +341,10 @@ FORCE_INLINE_ATTR void _usb_serial_jtag_ll_enable_bus_clock(bool clk_en) } // HP_SYS_CLKRST.soc_clk_ctrlx and LP_AON_CLKRST.hp_usb_clkrst_ctrlx are shared registers, so this function must be used in an atomic way -#define usb_serial_jtag_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _usb_serial_jtag_ll_enable_bus_clock(__VA_ARGS__) +#define usb_serial_jtag_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _usb_serial_jtag_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the USJ module @@ -353,7 +356,10 @@ FORCE_INLINE_ATTR void usb_serial_jtag_ll_reset_register(void) } // HP_SYS_CLKRST.soc_clk_ctrlx and LP_AON_CLKRST.hp_usb_clkrst_ctrlx are shared registers, so this function must be used in an atomic way -#define usb_serial_jtag_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; usb_serial_jtag_ll_reset_register(__VA_ARGS__) +#define usb_serial_jtag_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + usb_serial_jtag_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * Get the enable status of the USJ module diff --git a/components/hal/esp32p4/include/hal/usb_utmi_ll.h b/components/hal/esp32p4/include/hal/usb_utmi_ll.h index 1e1d078eb0..f64250a66e 100644 --- a/components/hal/esp32p4/include/hal/usb_utmi_ll.h +++ b/components/hal/esp32p4/include/hal/usb_utmi_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -48,7 +48,10 @@ FORCE_INLINE_ATTR void _usb_utmi_ll_enable_bus_clock(bool clk_en) } // HP_SYS_CLKRST.soc_clk_ctrlx and LP_AON_CLKRST.hp_usb_clkrst_ctrlx are shared registers, so this function must be used in an atomic way -#define usb_utmi_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _usb_utmi_ll_enable_bus_clock(__VA_ARGS__) +#define usb_utmi_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _usb_utmi_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * Get the enable status of the USB UTMI PHY bus clock @@ -73,7 +76,10 @@ FORCE_INLINE_ATTR void _usb_utmi_ll_reset_register(void) } // P_AON_CLKRST.hp_usb_clkrst_ctrlx is shared register, so this function must be used in an atomic way -#define usb_utmi_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; _usb_utmi_ll_reset_register(__VA_ARGS__) +#define usb_utmi_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _usb_utmi_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * @brief Enable precise detection of VBUS diff --git a/components/hal/esp32p4/include/hal/usb_wrap_ll.h b/components/hal/esp32p4/include/hal/usb_wrap_ll.h index d12c91b3dd..212a7f9dae 100644 --- a/components/hal/esp32p4/include/hal/usb_wrap_ll.h +++ b/components/hal/esp32p4/include/hal/usb_wrap_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -247,7 +247,10 @@ FORCE_INLINE_ATTR void _usb_wrap_ll_enable_bus_clock(bool clk_en) } // HP_SYS_CLKRST.soc_clk_ctrlx and LP_AON_CLKRST.hp_usb_clkrst_ctrlx are shared registers, so this function must be used in an atomic way -#define usb_wrap_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _usb_wrap_ll_enable_bus_clock(__VA_ARGS__) +#define usb_wrap_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _usb_wrap_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the USB Wrap module and USB_DWC_FS controller @@ -260,7 +263,10 @@ FORCE_INLINE_ATTR void _usb_wrap_ll_reset_register(void) } // P_AON_CLKRST.hp_usb_clkrst_ctrlx are shared registers, so this function must be used in an atomic way -#define usb_wrap_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; _usb_wrap_ll_reset_register(__VA_ARGS__) +#define usb_wrap_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _usb_wrap_ll_reset_register(__VA_ARGS__); \ + } while(0) #ifdef __cplusplus } diff --git a/components/hal/esp32s2/include/hal/adc_ll.h b/components/hal/esp32s2/include/hal/adc_ll.h index add16dc3c9..1d88b5424f 100644 --- a/components/hal/esp32s2/include/hal/adc_ll.h +++ b/components/hal/esp32s2/include/hal/adc_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -932,7 +932,10 @@ static inline void adc_ll_enable_bus_clock(bool enable) WRITE_PERI_REG(DPORT_PERIP_CLK_EN0_REG, reg_val); } // SYSTEM.perip_clk_en0 is a shared register, so this function must be used in an atomic way -#define adc_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; adc_ll_enable_bus_clock(__VA_ARGS__) +#define adc_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + adc_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset ADC module @@ -943,7 +946,10 @@ static inline void adc_ll_reset_register(void) CLEAR_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_APB_SARADC_RST); } // SYSTEM.perip_rst_en0 is a shared register, so this function must be used in an atomic way -#define adc_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; adc_ll_reset_register(__VA_ARGS__) +#define adc_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + adc_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * Set ADC module power management. diff --git a/components/hal/esp32s2/include/hal/aes_ll.h b/components/hal/esp32s2/include/hal/aes_ll.h index 9e00ca787a..4b7c1caa25 100644 --- a/components/hal/esp32s2/include/hal/aes_ll.h +++ b/components/hal/esp32s2/include/hal/aes_ll.h @@ -43,7 +43,10 @@ static inline void aes_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_ATOMIC_ENV variable in advance -#define aes_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; aes_ll_enable_bus_clock(__VA_ARGS__) +#define aes_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + aes_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the AES peripheral module @@ -59,7 +62,10 @@ static inline void aes_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_ATOMIC_ENV variable in advance -#define aes_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; aes_ll_reset_register(__VA_ARGS__) +#define aes_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + aes_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * @brief Write the encryption/decryption key to hardware diff --git a/components/hal/esp32s2/include/hal/crypto_dma_ll.h b/components/hal/esp32s2/include/hal/crypto_dma_ll.h index 793aeb7364..4f8d1f36c4 100644 --- a/components/hal/esp32s2/include/hal/crypto_dma_ll.h +++ b/components/hal/esp32s2/include/hal/crypto_dma_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -41,7 +41,10 @@ static inline void crypto_dma_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_ATOMIC_ENV variable in advance -#define crypto_dma_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; crypto_dma_ll_enable_bus_clock(__VA_ARGS__) +#define crypto_dma_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + crypto_dma_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the crypto DMA peripheral module @@ -54,7 +57,10 @@ static inline void crypto_dma_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_ATOMIC_ENV variable in advance -#define crypto_dma_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; crypto_dma_ll_reset_register(__VA_ARGS__) +#define crypto_dma_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + crypto_dma_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * @brief Resets the DMA diff --git a/components/hal/esp32s2/include/hal/dedic_gpio_ll.h b/components/hal/esp32s2/include/hal/dedic_gpio_ll.h index c02b97c595..cc09619fad 100644 --- a/components/hal/esp32s2/include/hal/dedic_gpio_ll.h +++ b/components/hal/esp32s2/include/hal/dedic_gpio_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -25,7 +25,10 @@ static inline void _dedic_gpio_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_ATOMIC_ENV variable in advance -#define dedic_gpio_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _dedic_gpio_ll_enable_bus_clock(__VA_ARGS__) +#define dedic_gpio_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _dedic_gpio_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) static inline void _dedic_gpio_ll_reset_register(void) { @@ -35,7 +38,10 @@ static inline void _dedic_gpio_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_ATOMIC_ENV variable in advance -#define dedic_gpio_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; _dedic_gpio_ll_reset_register(__VA_ARGS__) +#define dedic_gpio_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _dedic_gpio_ll_reset_register(__VA_ARGS__); \ + } while(0) static inline void dedic_gpio_ll_enable_instruction_access_out(dedic_dev_t *dev, uint32_t channel_mask, bool enable) { diff --git a/components/hal/esp32s2/include/hal/i2s_ll.h b/components/hal/esp32s2/include/hal/i2s_ll.h index b082ffe6f0..525b71ecc2 100644 --- a/components/hal/esp32s2/include/hal/i2s_ll.h +++ b/components/hal/esp32s2/include/hal/i2s_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -101,7 +101,10 @@ static inline void i2s_ll_enable_bus_clock(int i2s_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_ATOMIC_ENV variable in advance -#define i2s_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; i2s_ll_enable_bus_clock(__VA_ARGS__) +#define i2s_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + i2s_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the I2S module @@ -117,7 +120,10 @@ static inline void i2s_ll_reset_register(int i2s_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_ATOMIC_ENV variable in advance -#define i2s_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; i2s_ll_reset_register(__VA_ARGS__) +#define i2s_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + i2s_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * @brief I2S module general init, enable I2S clock. @@ -138,7 +144,10 @@ static inline void i2s_ll_enable_core_clock(i2s_dev_t *hw, 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_ATOMIC_ENV variable in advance -#define i2s_ll_enable_core_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; i2s_ll_enable_core_clock(__VA_ARGS__) +#define i2s_ll_enable_core_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + i2s_ll_enable_core_clock(__VA_ARGS__); \ + } while(0) /** * @brief I2S tx msb right enable diff --git a/components/hal/esp32s2/include/hal/ledc_ll.h b/components/hal/esp32s2/include/hal/ledc_ll.h index 8a5670a428..2bc2627125 100644 --- a/components/hal/esp32s2/include/hal/ledc_ll.h +++ b/components/hal/esp32s2/include/hal/ledc_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2019-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2019-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -57,7 +57,10 @@ static inline void ledc_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_ATOMIC_ENV variable in advance -#define ledc_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; ledc_ll_enable_bus_clock(__VA_ARGS__) +#define ledc_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + ledc_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset whole peripheral register to init value defined by HW design @@ -73,7 +76,10 @@ static inline void ledc_ll_enable_reset_reg(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_ATOMIC_ENV variable in advance -#define ledc_ll_enable_reset_reg(...) (void)__DECLARE_RCC_ATOMIC_ENV; ledc_ll_enable_reset_reg(__VA_ARGS__) +#define ledc_ll_enable_reset_reg(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + ledc_ll_enable_reset_reg(__VA_ARGS__); \ + } while(0) /** * @brief Enable the power for LEDC memory block diff --git a/components/hal/esp32s2/include/hal/mpi_ll.h b/components/hal/esp32s2/include/hal/mpi_ll.h index 6f5b2803c3..f764031c70 100644 --- a/components/hal/esp32s2/include/hal/mpi_ll.h +++ b/components/hal/esp32s2/include/hal/mpi_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -35,7 +35,10 @@ static inline void mpi_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_ATOMIC_ENV variable in advance -#define mpi_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; mpi_ll_enable_bus_clock(__VA_ARGS__) +#define mpi_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + mpi_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the MPI peripheral module @@ -51,7 +54,10 @@ static inline void mpi_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_ATOMIC_ENV variable in advance -#define mpi_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; mpi_ll_reset_register(__VA_ARGS__) +#define mpi_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + mpi_ll_reset_register(__VA_ARGS__); \ + } while(0) static inline size_t mpi_ll_calculate_hardware_words(size_t words) { diff --git a/components/hal/esp32s2/include/hal/pcnt_ll.h b/components/hal/esp32s2/include/hal/pcnt_ll.h index 313f4083f5..e18757b6bc 100644 --- a/components/hal/esp32s2/include/hal/pcnt_ll.h +++ b/components/hal/esp32s2/include/hal/pcnt_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -455,7 +455,10 @@ static inline void pcnt_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_ATOMIC_ENV variable in advance -#define pcnt_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; pcnt_ll_enable_bus_clock(__VA_ARGS__) +#define pcnt_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + pcnt_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the PCNT module @@ -469,7 +472,10 @@ static inline void pcnt_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_ATOMIC_ENV variable in advance -#define pcnt_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; pcnt_ll_reset_register(__VA_ARGS__) +#define pcnt_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + pcnt_ll_reset_register(__VA_ARGS__); \ + } while(0) #ifdef __cplusplus diff --git a/components/hal/esp32s2/include/hal/rmt_ll.h b/components/hal/esp32s2/include/hal/rmt_ll.h index 729afa2a6a..4330e8e217 100644 --- a/components/hal/esp32s2/include/hal/rmt_ll.h +++ b/components/hal/esp32s2/include/hal/rmt_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2019-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2019-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -59,7 +59,10 @@ static inline void rmt_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_ATOMIC_ENV variable in advance -#define rmt_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; rmt_ll_enable_bus_clock(__VA_ARGS__) +#define rmt_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + rmt_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the RMT module @@ -75,7 +78,10 @@ static inline void rmt_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_ATOMIC_ENV variable in advance -#define rmt_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; rmt_ll_reset_register(__VA_ARGS__) +#define rmt_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + rmt_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * @brief Enable clock gate for register and memory diff --git a/components/hal/esp32s2/include/hal/sha_ll.h b/components/hal/esp32s2/include/hal/sha_ll.h index 36bfee8299..3f516e3dc2 100644 --- a/components/hal/esp32s2/include/hal/sha_ll.h +++ b/components/hal/esp32s2/include/hal/sha_ll.h @@ -32,7 +32,10 @@ static inline void sha_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_ATOMIC_ENV variable in advance -#define sha_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; sha_ll_enable_bus_clock(__VA_ARGS__) +#define sha_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + sha_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the SHA peripheral module @@ -49,7 +52,10 @@ static inline void sha_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_ATOMIC_ENV variable in advance -#define sha_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; sha_ll_reset_register(__VA_ARGS__) +#define sha_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + sha_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * @brief Start a new SHA block conversions (no initial hash in HW) diff --git a/components/hal/esp32s2/include/hal/spi_ll.h b/components/hal/esp32s2/include/hal/spi_ll.h index 68f0834f79..a6cad7772b 100644 --- a/components/hal/esp32s2/include/hal/spi_ll.h +++ b/components/hal/esp32s2/include/hal/spi_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -147,7 +147,10 @@ static inline void spi_ll_enable_bus_clock(spi_host_device_t host_id, bool enabl /// 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_ATOMIC_ENV variable in advance -#define spi_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; spi_ll_enable_bus_clock(__VA_ARGS__) +#define spi_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + spi_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * Reset whole peripheral register to init value defined by HW design @@ -175,7 +178,10 @@ static inline void spi_ll_reset_register(spi_host_device_t host_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_ATOMIC_ENV variable in advance -#define spi_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; spi_ll_reset_register(__VA_ARGS__) +#define spi_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + spi_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * Enable functional output clock within peripheral @@ -1260,7 +1266,10 @@ static inline void spi_dma_ll_enable_bus_clock(spi_host_device_t host_id, bool e /// 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 spi_dma_ll_enable_bus_clock(...) (void)__DECLARE_RCC_RC_ATOMIC_ENV; spi_dma_ll_enable_bus_clock(__VA_ARGS__) +#define spi_dma_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_RC_ATOMIC_ENV; \ + spi_dma_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * Reset whole peripheral register to init value defined by HW design @@ -1285,7 +1294,10 @@ static inline void spi_dma_ll_reset_register(spi_host_device_t host_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 spi_dma_ll_reset_register(...) (void)__DECLARE_RCC_RC_ATOMIC_ENV; spi_dma_ll_reset_register(__VA_ARGS__) +#define spi_dma_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_RC_ATOMIC_ENV; \ + spi_dma_ll_reset_register(__VA_ARGS__); \ + } while(0) //---------------------------------------------------RX-------------------------------------------------// /** diff --git a/components/hal/esp32s2/include/hal/systimer_ll.h b/components/hal/esp32s2/include/hal/systimer_ll.h index dd35801bc5..d4ca7bafcb 100644 --- a/components/hal/esp32s2/include/hal/systimer_ll.h +++ b/components/hal/esp32s2/include/hal/systimer_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -51,7 +51,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 @@ -66,7 +69,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) /******************* Counter *************************/ diff --git a/components/hal/esp32s2/include/hal/timer_ll.h b/components/hal/esp32s2/include/hal/timer_ll.h index 05ac3323f7..54c9c03a90 100644 --- a/components/hal/esp32s2/include/hal/timer_ll.h +++ b/components/hal/esp32s2/include/hal/timer_ll.h @@ -45,7 +45,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 @@ -71,7 +74,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 diff --git a/components/hal/esp32s2/include/hal/twai_ll.h b/components/hal/esp32s2/include/hal/twai_ll.h index a6a3bc4d80..6dedd5ad32 100644 --- a/components/hal/esp32s2/include/hal/twai_ll.h +++ b/components/hal/esp32s2/include/hal/twai_ll.h @@ -156,7 +156,10 @@ static inline void twai_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_ATOMIC_ENV variable in advance -#define twai_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; twai_ll_enable_bus_clock(__VA_ARGS__) +#define twai_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + twai_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the twai module @@ -172,7 +175,10 @@ static inline void twai_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_ATOMIC_ENV variable in advance -#define twai_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; twai_ll_reset_register(__VA_ARGS__) +#define twai_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + twai_ll_reset_register(__VA_ARGS__); \ + } while(0) /* ---------------------------- Peripheral Control Register ----------------- */ diff --git a/components/hal/esp32s2/include/hal/uart_ll.h b/components/hal/esp32s2/include/hal/uart_ll.h index 963706c2a7..b605413ccc 100644 --- a/components/hal/esp32s2/include/hal/uart_ll.h +++ b/components/hal/esp32s2/include/hal/uart_ll.h @@ -99,7 +99,10 @@ static inline void uart_ll_enable_bus_clock(uart_port_t uart_num, bool enable) } WRITE_PERI_REG(DPORT_PERIP_CLK_EN0_REG, reg_val); } -#define uart_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; uart_ll_enable_bus_clock(__VA_ARGS__) +#define uart_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + uart_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset UART module @@ -122,7 +125,10 @@ static inline void uart_ll_reset_register(uart_port_t uart_num) } } // SYSTEM.perip_rst_enx are shared registers, so this function must be used in an atomic way -#define uart_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; uart_ll_reset_register(__VA_ARGS__) +#define uart_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + uart_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * @brief Enable the UART clock. @@ -684,7 +690,10 @@ FORCE_INLINE_ATTR void _uart_ll_enable_pad_sleep_clock(uart_dev_t *hw, bool enab (void)hw; (void)enable; } -#define uart_ll_enable_pad_sleep_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _uart_ll_enable_pad_sleep_clock(__VA_ARGS__) +#define uart_ll_enable_pad_sleep_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _uart_ll_enable_pad_sleep_clock(__VA_ARGS__); \ + } while(0) /** * @brief Configure the UART work in normal mode. diff --git a/components/hal/esp32s2/include/hal/usb_wrap_ll.h b/components/hal/esp32s2/include/hal/usb_wrap_ll.h index bf88f7b8c3..d8dae2a747 100644 --- a/components/hal/esp32s2/include/hal/usb_wrap_ll.h +++ b/components/hal/esp32s2/include/hal/usb_wrap_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -213,7 +213,10 @@ FORCE_INLINE_ATTR void _usb_wrap_ll_enable_bus_clock(bool clk_en) } // SYSTEM.perip_clk_enx are shared registers, so this function must be used in an atomic way -#define usb_wrap_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _usb_wrap_ll_enable_bus_clock(__VA_ARGS__) +#define usb_wrap_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _usb_wrap_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the USB Wrap module @@ -225,7 +228,10 @@ FORCE_INLINE_ATTR void _usb_wrap_ll_reset_register(void) } // SYSTEM.perip_rst_enx are shared registers, so this function must be used in an atomic way -#define usb_wrap_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; _usb_wrap_ll_reset_register(__VA_ARGS__) +#define usb_wrap_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _usb_wrap_ll_reset_register(__VA_ARGS__); \ + } while(0) #ifdef __cplusplus } diff --git a/components/hal/esp32s3/include/hal/adc_ll.h b/components/hal/esp32s3/include/hal/adc_ll.h index 6911924b0d..2149a881d6 100644 --- a/components/hal/esp32s3/include/hal/adc_ll.h +++ b/components/hal/esp32s3/include/hal/adc_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -622,7 +622,10 @@ static inline void adc_ll_enable_bus_clock(bool enable) SYSTEM.perip_clk_en0.apb_saradc_clk_en = enable; } // SYSTEM.perip_clk_en0 is a shared register, so this function must be used in an atomic way -#define adc_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; adc_ll_enable_bus_clock(__VA_ARGS__) +#define adc_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + adc_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset ADC module @@ -633,7 +636,10 @@ static inline void adc_ll_reset_register(void) SYSTEM.perip_rst_en0.apb_saradc_rst = 0; } // SYSTEM.perip_rst_en0 is a shared register, so this function must be used in an atomic way -#define adc_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; adc_ll_reset_register(__VA_ARGS__) +#define adc_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + adc_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * Set ADC module power management. diff --git a/components/hal/esp32s3/include/hal/aes_ll.h b/components/hal/esp32s3/include/hal/aes_ll.h index 2dc9be0db8..2a4b978cf3 100644 --- a/components/hal/esp32s3/include/hal/aes_ll.h +++ b/components/hal/esp32s3/include/hal/aes_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -38,7 +38,10 @@ static inline void aes_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_ATOMIC_ENV variable in advance -#define aes_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; aes_ll_enable_bus_clock(__VA_ARGS__) +#define aes_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + aes_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the AES peripheral module @@ -54,7 +57,10 @@ static inline void aes_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_ATOMIC_ENV variable in advance -#define aes_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; aes_ll_reset_register(__VA_ARGS__) +#define aes_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + aes_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * @brief Write the encryption/decryption key to hardware diff --git a/components/hal/esp32s3/include/hal/dedic_gpio_ll.h b/components/hal/esp32s3/include/hal/dedic_gpio_ll.h index f6e019b686..3e98e81902 100644 --- a/components/hal/esp32s3/include/hal/dedic_gpio_ll.h +++ b/components/hal/esp32s3/include/hal/dedic_gpio_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -20,7 +20,10 @@ static inline void _dedic_gpio_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_ATOMIC_ENV variable in advance -#define dedic_gpio_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _dedic_gpio_ll_enable_bus_clock(__VA_ARGS__) +#define dedic_gpio_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _dedic_gpio_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) static inline void _dedic_gpio_ll_reset_register(void) { @@ -30,7 +33,10 @@ static inline void _dedic_gpio_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_ATOMIC_ENV variable in advance -#define dedic_gpio_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; _dedic_gpio_ll_reset_register(__VA_ARGS__) +#define dedic_gpio_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _dedic_gpio_ll_reset_register(__VA_ARGS__); \ + } while(0) #ifdef __cplusplus } diff --git a/components/hal/esp32s3/include/hal/ds_ll.h b/components/hal/esp32s3/include/hal/ds_ll.h index 053194c36f..a552670c55 100644 --- a/components/hal/esp32s3/include/hal/ds_ll.h +++ b/components/hal/esp32s3/include/hal/ds_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -31,7 +31,10 @@ static inline void ds_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_ATOMIC_ENV variable in advance -#define ds_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; ds_ll_enable_bus_clock(__VA_ARGS__) +#define ds_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + ds_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the Digital Signature peripheral module @@ -44,7 +47,10 @@ static inline void ds_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_ATOMIC_ENV variable in advance -#define ds_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; ds_ll_reset_register(__VA_ARGS__) +#define ds_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + ds_ll_reset_register(__VA_ARGS__); \ + } while(0) static inline void ds_ll_start(void) { diff --git a/components/hal/esp32s3/include/hal/gdma_ll.h b/components/hal/esp32s3/include/hal/gdma_ll.h index c232966ca5..aa04883212 100644 --- a/components/hal/esp32s3/include/hal/gdma_ll.h +++ b/components/hal/esp32s3/include/hal/gdma_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -78,7 +78,10 @@ static inline void _gdma_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_ATOMIC_ENV variable in advance -#define gdma_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _gdma_ll_enable_bus_clock(__VA_ARGS__) +#define gdma_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _gdma_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the DMA module @@ -92,7 +95,10 @@ static inline void _gdma_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_ATOMIC_ENV variable in advance -#define gdma_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; _gdma_ll_reset_register(__VA_ARGS__) +#define gdma_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _gdma_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * @brief Force enable register clock diff --git a/components/hal/esp32s3/include/hal/hmac_ll.h b/components/hal/esp32s3/include/hal/hmac_ll.h index 792d316efa..e2c6328156 100644 --- a/components/hal/esp32s3/include/hal/hmac_ll.h +++ b/components/hal/esp32s3/include/hal/hmac_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -43,7 +43,10 @@ static inline void hmac_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_ATOMIC_ENV variable in advance -#define hmac_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; hmac_ll_enable_bus_clock(__VA_ARGS__) +#define hmac_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + hmac_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the HMAC peripheral module @@ -56,7 +59,10 @@ static inline void hmac_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_ATOMIC_ENV variable in advance -#define hmac_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; hmac_ll_reset_register(__VA_ARGS__) +#define hmac_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + hmac_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * Makes the peripheral ready for use, after enabling it. diff --git a/components/hal/esp32s3/include/hal/i2s_ll.h b/components/hal/esp32s3/include/hal/i2s_ll.h index f66575ea0b..4d0c499ef4 100644 --- a/components/hal/esp32s3/include/hal/i2s_ll.h +++ b/components/hal/esp32s3/include/hal/i2s_ll.h @@ -57,7 +57,10 @@ static inline void i2s_ll_enable_bus_clock(int i2s_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_ATOMIC_ENV variable in advance -#define i2s_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; i2s_ll_enable_bus_clock(__VA_ARGS__) +#define i2s_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + i2s_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the I2S module @@ -77,7 +80,10 @@ static inline void i2s_ll_reset_register(int i2s_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_ATOMIC_ENV variable in advance -#define i2s_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; i2s_ll_reset_register(__VA_ARGS__) +#define i2s_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + i2s_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * @brief I2S module general init, enable I2S clock. @@ -92,7 +98,10 @@ static inline void i2s_ll_enable_core_clock(i2s_dev_t *hw, 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_ATOMIC_ENV variable in advance -#define i2s_ll_enable_core_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; i2s_ll_enable_core_clock(__VA_ARGS__) +#define i2s_ll_enable_core_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + i2s_ll_enable_core_clock(__VA_ARGS__); \ + } while(0) /** * @brief Enable I2S tx module clock diff --git a/components/hal/esp32s3/include/hal/lcd_ll.h b/components/hal/esp32s3/include/hal/lcd_ll.h index c58af9b8ed..77e50183f4 100644 --- a/components/hal/esp32s3/include/hal/lcd_ll.h +++ b/components/hal/esp32s3/include/hal/lcd_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -51,7 +51,10 @@ static inline void lcd_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 lcd_ll_enable_bus_clock(...) (void)__DECLARE_RCC_RC_ATOMIC_ENV; lcd_ll_enable_bus_clock(__VA_ARGS__) +#define lcd_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_RC_ATOMIC_ENV; \ + lcd_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the LCD module @@ -67,7 +70,10 @@ static inline void lcd_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 lcd_ll_reset_register(...) (void)__DECLARE_RCC_RC_ATOMIC_ENV; lcd_ll_reset_register(__VA_ARGS__) +#define lcd_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_RC_ATOMIC_ENV; \ + lcd_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * @brief Enable clock gating diff --git a/components/hal/esp32s3/include/hal/ledc_ll.h b/components/hal/esp32s3/include/hal/ledc_ll.h index 56fca02e4a..e9a8ad17fd 100644 --- a/components/hal/esp32s3/include/hal/ledc_ll.h +++ b/components/hal/esp32s3/include/hal/ledc_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -48,7 +48,10 @@ static inline void ledc_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_ATOMIC_ENV variable in advance -#define ledc_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; ledc_ll_enable_bus_clock(__VA_ARGS__) +#define ledc_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + ledc_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset whole peripheral register to init value defined by HW design @@ -60,7 +63,10 @@ static inline void ledc_ll_enable_reset_reg(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_ATOMIC_ENV variable in advance -#define ledc_ll_enable_reset_reg(...) (void)__DECLARE_RCC_ATOMIC_ENV; ledc_ll_enable_reset_reg(__VA_ARGS__) +#define ledc_ll_enable_reset_reg(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + ledc_ll_enable_reset_reg(__VA_ARGS__); \ + } while(0) /** * @brief Enable the power for LEDC memory block diff --git a/components/hal/esp32s3/include/hal/mcpwm_ll.h b/components/hal/esp32s3/include/hal/mcpwm_ll.h index bebf87589f..e99604b50e 100644 --- a/components/hal/esp32s3/include/hal/mcpwm_ll.h +++ b/components/hal/esp32s3/include/hal/mcpwm_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -85,7 +85,10 @@ static inline void mcpwm_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_ATOMIC_ENV variable in advance -#define mcpwm_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; mcpwm_ll_enable_bus_clock(__VA_ARGS__) +#define mcpwm_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + mcpwm_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the MCPWM module @@ -105,7 +108,10 @@ static inline void mcpwm_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_ATOMIC_ENV variable in advance -#define mcpwm_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; mcpwm_ll_reset_register(__VA_ARGS__) +#define mcpwm_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + mcpwm_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * @brief Enable MCPWM function clock diff --git a/components/hal/esp32s3/include/hal/mpi_ll.h b/components/hal/esp32s3/include/hal/mpi_ll.h index 2c265222c0..785e6f8711 100644 --- a/components/hal/esp32s3/include/hal/mpi_ll.h +++ b/components/hal/esp32s3/include/hal/mpi_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -32,7 +32,10 @@ static inline void mpi_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_ATOMIC_ENV variable in advance -#define mpi_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; mpi_ll_enable_bus_clock(__VA_ARGS__) +#define mpi_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + mpi_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the MPI peripheral module @@ -48,7 +51,10 @@ static inline void mpi_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_ATOMIC_ENV variable in advance -#define mpi_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; mpi_ll_reset_register(__VA_ARGS__) +#define mpi_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + mpi_ll_reset_register(__VA_ARGS__); \ + } while(0) static inline size_t mpi_ll_calculate_hardware_words(size_t words) { diff --git a/components/hal/esp32s3/include/hal/pcnt_ll.h b/components/hal/esp32s3/include/hal/pcnt_ll.h index 6fbb5b9247..b5b18cb686 100644 --- a/components/hal/esp32s3/include/hal/pcnt_ll.h +++ b/components/hal/esp32s3/include/hal/pcnt_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -450,7 +450,10 @@ static inline void pcnt_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_ATOMIC_ENV variable in advance -#define pcnt_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; pcnt_ll_enable_bus_clock(__VA_ARGS__) +#define pcnt_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + pcnt_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the PCNT module @@ -464,7 +467,10 @@ static inline void pcnt_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_ATOMIC_ENV variable in advance -#define pcnt_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; pcnt_ll_reset_register(__VA_ARGS__) +#define pcnt_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + pcnt_ll_reset_register(__VA_ARGS__); \ + } while(0) #ifdef __cplusplus } diff --git a/components/hal/esp32s3/include/hal/rmt_ll.h b/components/hal/esp32s3/include/hal/rmt_ll.h index 5923dbef81..1ffd11bd31 100644 --- a/components/hal/esp32s3/include/hal/rmt_ll.h +++ b/components/hal/esp32s3/include/hal/rmt_ll.h @@ -61,7 +61,10 @@ static inline void rmt_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_ATOMIC_ENV variable in advance -#define rmt_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; rmt_ll_enable_bus_clock(__VA_ARGS__) +#define rmt_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + rmt_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the RMT module @@ -77,7 +80,10 @@ static inline void rmt_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_ATOMIC_ENV variable in advance -#define rmt_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; rmt_ll_reset_register(__VA_ARGS__) +#define rmt_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + rmt_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * @brief Enable clock gate for register and memory diff --git a/components/hal/esp32s3/include/hal/sdmmc_ll.h b/components/hal/esp32s3/include/hal/sdmmc_ll.h index e5eaa5d412..544000890c 100644 --- a/components/hal/esp32s3/include/hal/sdmmc_ll.h +++ b/components/hal/esp32s3/include/hal/sdmmc_ll.h @@ -124,7 +124,10 @@ static inline void sdmmc_ll_enable_bus_clock(int group_id, bool en) /// 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_ATOMIC_ENV variable in advance -#define sdmmc_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; sdmmc_ll_enable_bus_clock(__VA_ARGS__) +#define sdmmc_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + sdmmc_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the SDMMC module @@ -140,7 +143,10 @@ static inline void sdmmc_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_ATOMIC_ENV variable in advance -#define sdmmc_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; sdmmc_ll_reset_register(__VA_ARGS__) +#define sdmmc_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + sdmmc_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * @brief Select SDMMC clock source diff --git a/components/hal/esp32s3/include/hal/sha_ll.h b/components/hal/esp32s3/include/hal/sha_ll.h index 9a7b9ed8f3..3b799db984 100644 --- a/components/hal/esp32s3/include/hal/sha_ll.h +++ b/components/hal/esp32s3/include/hal/sha_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -27,7 +27,10 @@ static inline void sha_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_ATOMIC_ENV variable in advance -#define sha_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; sha_ll_enable_bus_clock(__VA_ARGS__) +#define sha_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + sha_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the SHA peripheral module @@ -44,7 +47,10 @@ static inline void sha_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_ATOMIC_ENV variable in advance -#define sha_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; sha_ll_reset_register(__VA_ARGS__) +#define sha_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + sha_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * @brief Start a new SHA block conversions (no initial hash in HW) diff --git a/components/hal/esp32s3/include/hal/spi_ll.h b/components/hal/esp32s3/include/hal/spi_ll.h index c3db5cbd26..b23c74eae6 100644 --- a/components/hal/esp32s3/include/hal/spi_ll.h +++ b/components/hal/esp32s3/include/hal/spi_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -117,7 +117,10 @@ static inline void spi_ll_enable_bus_clock(spi_host_device_t host_id, bool enabl /// 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_ATOMIC_ENV variable in advance -#define spi_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; spi_ll_enable_bus_clock(__VA_ARGS__) +#define spi_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + spi_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * Reset whole peripheral register to init value defined by HW design @@ -145,7 +148,10 @@ static inline void spi_ll_reset_register(spi_host_device_t host_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_ATOMIC_ENV variable in advance -#define spi_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; spi_ll_reset_register(__VA_ARGS__) +#define spi_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + spi_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * Enable functional output clock within peripheral diff --git a/components/hal/esp32s3/include/hal/systimer_ll.h b/components/hal/esp32s3/include/hal/systimer_ll.h index 36fe0fa117..da6c5710d4 100644 --- a/components/hal/esp32s3/include/hal/systimer_ll.h +++ b/components/hal/esp32s3/include/hal/systimer_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -48,7 +48,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 @@ -63,7 +66,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) /******************* Counter *************************/ diff --git a/components/hal/esp32s3/include/hal/timer_ll.h b/components/hal/esp32s3/include/hal/timer_ll.h index 7bdaad2eca..e838fa011a 100644 --- a/components/hal/esp32s3/include/hal/timer_ll.h +++ b/components/hal/esp32s3/include/hal/timer_ll.h @@ -41,7 +41,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 @@ -67,7 +70,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 diff --git a/components/hal/esp32s3/include/hal/twai_ll.h b/components/hal/esp32s3/include/hal/twai_ll.h index 61aa723727..a89f1eb570 100644 --- a/components/hal/esp32s3/include/hal/twai_ll.h +++ b/components/hal/esp32s3/include/hal/twai_ll.h @@ -153,7 +153,10 @@ static inline void twai_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_ATOMIC_ENV variable in advance -#define twai_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; twai_ll_enable_bus_clock(__VA_ARGS__) +#define twai_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + twai_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the twai module @@ -169,7 +172,10 @@ static inline void twai_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_ATOMIC_ENV variable in advance -#define twai_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; twai_ll_reset_register(__VA_ARGS__) +#define twai_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + twai_ll_reset_register(__VA_ARGS__); \ + } while(0) /* ---------------------------- Peripheral Control Register ----------------- */ diff --git a/components/hal/esp32s3/include/hal/uart_ll.h b/components/hal/esp32s3/include/hal/uart_ll.h index 816e8103fe..e7a3de1200 100644 --- a/components/hal/esp32s3/include/hal/uart_ll.h +++ b/components/hal/esp32s3/include/hal/uart_ll.h @@ -105,7 +105,10 @@ static inline void uart_ll_enable_bus_clock(uart_port_t uart_num, bool enable) } } // SYSTEM.perip_clk_enx are shared registers, so this function must be used in an atomic way -#define uart_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; uart_ll_enable_bus_clock(__VA_ARGS__) +#define uart_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + uart_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset UART module @@ -142,7 +145,10 @@ static inline void uart_ll_reset_register(uart_port_t uart_num) } } // SYSTEM.perip_rst_enx are shared registers, so this function must be used in an atomic way -#define uart_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; uart_ll_reset_register(__VA_ARGS__) +#define uart_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + uart_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * @brief Enable the UART clock. @@ -714,7 +720,10 @@ FORCE_INLINE_ATTR void _uart_ll_enable_pad_sleep_clock(uart_dev_t *hw, bool enab (void)hw; (void)enable; } -#define uart_ll_enable_pad_sleep_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _uart_ll_enable_pad_sleep_clock(__VA_ARGS__) +#define uart_ll_enable_pad_sleep_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _uart_ll_enable_pad_sleep_clock(__VA_ARGS__); \ + } while(0) /** * @brief Configure the UART work in normal mode. diff --git a/components/hal/esp32s3/include/hal/uhci_ll.h b/components/hal/esp32s3/include/hal/uhci_ll.h index fb164b601a..af112ac303 100644 --- a/components/hal/esp32s3/include/hal/uhci_ll.h +++ b/components/hal/esp32s3/include/hal/uhci_ll.h @@ -42,7 +42,10 @@ static inline void _uhci_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_ATOMIC_ENV variable in advance -#define uhci_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _uhci_ll_enable_bus_clock(__VA_ARGS__) +#define uhci_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _uhci_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the UHCI module @@ -58,7 +61,10 @@ static inline void _uhci_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_ATOMIC_ENV variable in advance -#define uhci_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; _uhci_ll_reset_register(__VA_ARGS__) +#define uhci_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _uhci_ll_reset_register(__VA_ARGS__); \ + } while(0) static inline void uhci_ll_init(uhci_dev_t *hw) { diff --git a/components/hal/esp32s3/include/hal/usb_serial_jtag_ll.h b/components/hal/esp32s3/include/hal/usb_serial_jtag_ll.h index c81a6ae493..2b0c51a3ce 100644 --- a/components/hal/esp32s3/include/hal/usb_serial_jtag_ll.h +++ b/components/hal/esp32s3/include/hal/usb_serial_jtag_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -327,7 +327,10 @@ FORCE_INLINE_ATTR void usb_serial_jtag_ll_enable_bus_clock(bool clk_en) } // SYSTEM.perip_clk_enx are shared registers, so this function must be used in an atomic way -#define usb_serial_jtag_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; usb_serial_jtag_ll_enable_bus_clock(__VA_ARGS__) +#define usb_serial_jtag_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + usb_serial_jtag_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the USJ module @@ -339,7 +342,10 @@ FORCE_INLINE_ATTR void usb_serial_jtag_ll_reset_register(void) } // SYSTEM.perip_clk_enx are shared registers, so this function must be used in an atomic way -#define usb_serial_jtag_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; usb_serial_jtag_ll_reset_register(__VA_ARGS__) +#define usb_serial_jtag_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + usb_serial_jtag_ll_reset_register(__VA_ARGS__); \ + } while(0) /** * Get the enable status of the USJ module diff --git a/components/hal/esp32s3/include/hal/usb_wrap_ll.h b/components/hal/esp32s3/include/hal/usb_wrap_ll.h index b11743baf8..409e751ca2 100644 --- a/components/hal/esp32s3/include/hal/usb_wrap_ll.h +++ b/components/hal/esp32s3/include/hal/usb_wrap_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -222,7 +222,10 @@ FORCE_INLINE_ATTR void _usb_wrap_ll_enable_bus_clock(bool clk_en) } // SYSTEM.perip_clk_enx are shared registers, so this function must be used in an atomic way -#define usb_wrap_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _usb_wrap_ll_enable_bus_clock(__VA_ARGS__) +#define usb_wrap_ll_enable_bus_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _usb_wrap_ll_enable_bus_clock(__VA_ARGS__); \ + } while(0) /** * @brief Reset the USB Wrap module @@ -234,7 +237,10 @@ FORCE_INLINE_ATTR void _usb_wrap_ll_reset_register(void) } // SYSTEM.perip_rst_enx are shared registers, so this function must be used in an atomic way -#define usb_wrap_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; _usb_wrap_ll_reset_register(__VA_ARGS__) +#define usb_wrap_ll_reset_register(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _usb_wrap_ll_reset_register(__VA_ARGS__); \ + } while(0) #ifdef __cplusplus } diff --git a/components/hal/include/hal/i2s_hal.h b/components/hal/include/hal/i2s_hal.h index 0c92672256..88ab092330 100644 --- a/components/hal/include/hal/i2s_hal.h +++ b/components/hal/include/hal/i2s_hal.h @@ -162,7 +162,10 @@ void i2s_hal_calc_mclk_precise_division(uint32_t sclk, uint32_t mclk, hal_utils_ void _i2s_hal_set_tx_clock(i2s_hal_context_t *hal, const i2s_hal_clock_info_t *clk_info, i2s_clock_src_t clk_src, hal_utils_clk_div_t *ret_mclk_div); /// 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_ATOMIC_ENV variable in advance -#define i2s_hal_set_tx_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _i2s_hal_set_tx_clock(__VA_ARGS__) +#define i2s_hal_set_tx_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _i2s_hal_set_tx_clock(__VA_ARGS__); \ + } while(0) #else /** * @brief Set tx channel clock @@ -188,7 +191,10 @@ void _i2s_hal_set_rx_clock(i2s_hal_context_t *hal, const i2s_hal_clock_info_t *c #if SOC_PERIPH_CLK_CTRL_SHARED /// 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_ATOMIC_ENV variable in advance -#define i2s_hal_set_rx_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _i2s_hal_set_rx_clock(__VA_ARGS__) +#define i2s_hal_set_rx_clock(...) do { \ + (void)__DECLARE_RCC_ATOMIC_ENV; \ + _i2s_hal_set_rx_clock(__VA_ARGS__); \ + } while(0) #else #define i2s_hal_set_rx_clock(...) _i2s_hal_set_rx_clock(__VA_ARGS__) #endif