mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-01 18:50:34 +03:00
fix(ulp): make LP peripheral default config macros C++ compatible
Use dual-path macros: C keeps fragment-style designated initializers; C++ uses GNU statement expressions (ESP_LOG_CONFIG_INIT pattern). Add compile-only C++ regression tests for LP UART/I2C and ULP RISC-V I2C. Closes https://github.com/espressif/esp-idf/issues/18369 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -26,6 +26,7 @@ if(CONFIG_SOC_LP_VAD_SUPPORTED)
|
||||
endif()
|
||||
|
||||
list(APPEND app_sources "test_lp_core_prefix.c")
|
||||
list(APPEND app_sources "test_lp_periph_config_cpp.cpp")
|
||||
|
||||
set(lp_core_sources "lp_core/test_main.c")
|
||||
set(lp_core_sources_counter "lp_core/test_main_counter.c")
|
||||
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||
*/
|
||||
|
||||
// Compile LP peripheral default-config macros as C++ to catch incompatibilities.
|
||||
#include "sdkconfig.h"
|
||||
#include "soc/soc_caps.h"
|
||||
|
||||
#if SOC_ULP_LP_UART_SUPPORTED
|
||||
#include "lp_core_uart.h"
|
||||
|
||||
static void test_lp_uart_default_config_cpp(void) __attribute__((unused));
|
||||
static void test_lp_uart_default_config_cpp(void)
|
||||
{
|
||||
lp_core_uart_cfg_t cfg = LP_CORE_UART_DEFAULT_CONFIG();
|
||||
lp_core_uart_pin_cfg_t pin_cfg = LP_UART_DEFAULT_GPIO_CONFIG();
|
||||
lp_core_uart_proto_cfg_t proto_cfg = LP_UART_DEFAULT_PROTO_CONFIG();
|
||||
(void)cfg;
|
||||
(void)pin_cfg;
|
||||
(void)proto_cfg;
|
||||
(void)LP_UART_DEFAULT_CLOCK_CONFIG();
|
||||
}
|
||||
#endif /* SOC_ULP_LP_UART_SUPPORTED */
|
||||
|
||||
#if SOC_LP_CORE_SUPPORT_I2C
|
||||
#include "lp_core_i2c.h"
|
||||
|
||||
static void test_lp_i2c_default_config_cpp(void) __attribute__((unused));
|
||||
static void test_lp_i2c_default_config_cpp(void)
|
||||
{
|
||||
lp_core_i2c_cfg_t cfg = LP_CORE_I2C_DEFAULT_CONFIG();
|
||||
lp_core_i2c_pin_cfg_t pin_cfg = LP_I2C_DEFAULT_GPIO_CONFIG();
|
||||
lp_core_i2c_timing_cfg_t fast_cfg = LP_I2C_FAST_MODE_CONFIG();
|
||||
lp_core_i2c_timing_cfg_t std_cfg = LP_I2C_STANDARD_MODE_CONFIG();
|
||||
(void)cfg;
|
||||
(void)pin_cfg;
|
||||
(void)fast_cfg;
|
||||
(void)std_cfg;
|
||||
(void)LP_I2C_DEFAULT_SRC_CLK();
|
||||
}
|
||||
#endif /* SOC_LP_CORE_SUPPORT_I2C */
|
||||
@@ -1,4 +1,4 @@
|
||||
set(app_sources "test_app_main.c" "test_ulp_riscv.c" "test_ulp_riscv_i2c.c")
|
||||
set(app_sources "test_app_main.c" "test_ulp_riscv.c" "test_ulp_riscv_i2c.c" "test_ulp_riscv_i2c_config_cpp.cpp")
|
||||
set(ulp_sources "ulp/test_main.c")
|
||||
set(ulp_sources2 "ulp/test_main_second_cocpu_firmware.c")
|
||||
set(ulp_sources3 "ulp/test_main_cocpu_crash.c")
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||
*/
|
||||
|
||||
// Compile ULP RISC-V I2C default-config macros as C++ to catch incompatibilities.
|
||||
#include "ulp_riscv_i2c.h"
|
||||
|
||||
static void test_ulp_riscv_i2c_default_config_cpp(void) __attribute__((unused));
|
||||
static void test_ulp_riscv_i2c_default_config_cpp(void)
|
||||
{
|
||||
ulp_riscv_i2c_cfg_t cfg = ULP_RISCV_I2C_DEFAULT_CONFIG();
|
||||
ulp_riscv_i2c_pin_cfg_t pin_cfg = ULP_RISCV_I2C_DEFAULT_GPIO_CONFIG();
|
||||
ulp_riscv_i2c_timing_cfg_t fast_cfg = ULP_RISCV_I2C_FAST_MODE_CONFIG();
|
||||
ulp_riscv_i2c_timing_cfg_t std_cfg = ULP_RISCV_I2C_STANDARD_MODE_CONFIG();
|
||||
(void)cfg;
|
||||
(void)pin_cfg;
|
||||
(void)fast_cfg;
|
||||
(void)std_cfg;
|
||||
}
|
||||
Reference in New Issue
Block a user