diff --git a/components/ulp/test_apps/lp_core/CMakeLists.txt b/components/ulp/test_apps/lp_core/CMakeLists.txt index f4ad6a09d6..2a29e3574d 100644 --- a/components/ulp/test_apps/lp_core/CMakeLists.txt +++ b/components/ulp/test_apps/lp_core/CMakeLists.txt @@ -3,5 +3,9 @@ cmake_minimum_required(VERSION 3.16) list(PREPEND SDKCONFIG_DEFAULTS "$ENV{IDF_PATH}/tools/test_apps/configs/sdkconfig.debug_helpers" "sdkconfig.defaults") +set(EXTRA_COMPONENT_DIRS + "$ENV{IDF_PATH}/tools/unit-test-app/components" +) + include($ENV{IDF_PATH}/tools/cmake/project.cmake) project(lp_core_test) diff --git a/components/ulp/test_apps/lp_core/main/CMakeLists.txt b/components/ulp/test_apps/lp_core/main/CMakeLists.txt index 807681199e..7920347468 100644 --- a/components/ulp/test_apps/lp_core/main/CMakeLists.txt +++ b/components/ulp/test_apps/lp_core/main/CMakeLists.txt @@ -1,16 +1,20 @@ -set(app_sources "test_app_main.c" "test_lp_core.c") +set(app_sources "test_app_main.c" "test_lp_core.c" "test_lp_core_i2c.c") + set(lp_core_sources "lp_core/test_main.c") set(lp_core_sources_counter "lp_core/test_main_counter.c") set(lp_core_sources_set_timer_wakeup "lp_core/test_main_set_timer_wakeup.c") set(lp_core_sources_gpio "lp_core/test_main_gpio.c") +set(lp_core_sources_i2c "lp_core/test_main_i2c.c") idf_component_register(SRCS ${app_sources} INCLUDE_DIRS "lp_core" - REQUIRES ulp unity esp_timer + REQUIRES ulp unity esp_timer test_utils WHOLE_ARCHIVE) set(lp_core_exp_dep_srcs ${app_sources}) + ulp_embed_binary(lp_core_test_app "${lp_core_sources}" "${lp_core_exp_dep_srcs}") ulp_embed_binary(lp_core_test_app_counter "${lp_core_sources_counter}" "${lp_core_exp_dep_srcs}") ulp_embed_binary(lp_core_test_app_set_timer_wakeup "${lp_core_sources_set_timer_wakeup}" "${lp_core_exp_dep_srcs}") ulp_embed_binary(lp_core_test_app_gpio "${lp_core_sources_gpio}" "${lp_core_exp_dep_srcs}") +ulp_embed_binary(lp_core_test_app_i2c "${lp_core_sources_i2c}" "${lp_core_exp_dep_srcs}") diff --git a/components/ulp/test_apps/lp_core/main/lp_core/test_main_i2c.c b/components/ulp/test_apps/lp_core/main/lp_core/test_main_i2c.c new file mode 100644 index 0000000000..d110ce29cd --- /dev/null +++ b/components/ulp/test_apps/lp_core/main/lp_core/test_main_i2c.c @@ -0,0 +1,35 @@ +/* + * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include "test_shared.h" +#include "ulp_lp_core_utils.h" +#include "ulp_lp_core_i2c.h" + +#define LP_I2C_TRANS_WAIT_FOREVER -1 + +volatile lp_core_test_command_reply_t read_test_reply = LP_CORE_COMMAND_INVALID; +volatile lp_core_test_command_reply_t write_test_cmd = LP_CORE_COMMAND_INVALID; + +uint8_t data_rd[DATA_LENGTH] = {}; +uint8_t data_wr[DATA_LENGTH] = {}; + +int main (void) +{ + lp_core_i2c_master_read_from_device(LP_I2C_NUM_0, I2C_SLAVE_ADDRESS, data_rd, RW_TEST_LENGTH, LP_I2C_TRANS_WAIT_FOREVER); + read_test_reply = LP_CORE_COMMAND_OK; + + /* Wait for write command from main CPU */ + while(write_test_cmd != LP_CORE_COMMAND_OK) { + } + + lp_core_i2c_master_write_to_device(LP_I2C_NUM_0, I2C_SLAVE_ADDRESS, data_wr, RW_TEST_LENGTH, LP_I2C_TRANS_WAIT_FOREVER); + + write_test_cmd = LP_CORE_COMMAND_NOK; + + while(1) { + } +} diff --git a/components/ulp/test_apps/lp_core/main/lp_core/test_shared.h b/components/ulp/test_apps/lp_core/main/lp_core/test_shared.h index fa61107ca5..5541045ccf 100644 --- a/components/ulp/test_apps/lp_core/main/lp_core/test_shared.h +++ b/components/ulp/test_apps/lp_core/main/lp_core/test_shared.h @@ -7,6 +7,11 @@ #define XOR_MASK 0xDEADBEEF +/* I2C test params */ +#define I2C_SLAVE_ADDRESS 0x28 +#define DATA_LENGTH 200 +#define RW_TEST_LENGTH 129 /*! +#include +#include "lp_core_test_app_i2c.h" +#include "ulp_lp_core.h" +#include "lp_core_i2c.h" + +#include "test_shared.h" +#include "unity.h" +#include "test_utils.h" +#include "esp_log.h" + +#include "driver/i2c.h" + +extern const uint8_t lp_core_main_i2c_bin_start[] asm("_binary_lp_core_test_app_i2c_bin_start"); +extern const uint8_t lp_core_main_i2c_bin_end[] asm("_binary_lp_core_test_app_i2c_bin_end"); + +static const char* TAG = "lp_core_i2c_test"; + +static void load_and_start_lp_core_firmware(ulp_lp_core_cfg_t* cfg, const uint8_t* firmware_start, const uint8_t* firmware_end) +{ + TEST_ASSERT(ulp_lp_core_load_binary(firmware_start, + (firmware_end - firmware_start)) == ESP_OK); + + TEST_ASSERT(ulp_lp_core_run(cfg) == ESP_OK); + +} + + +#define I2C_SCL_IO 7 /*! None: dut.run_all_single_board_cases() + + +@pytest.mark.esp32c6 +@pytest.mark.generic_multi_device +@pytest.mark.parametrize( + 'count, config', + [ + (2, 'defaults',), + ], + indirect=True +) +def test_lp_core_multi_device(case_tester) -> None: # type: ignore + for case in case_tester.test_menu: + if case.attributes.get('test_env', 'generic_multi_device') == 'generic_multi_device': + case_tester.run_multi_dev_case(case=case, reset=True) diff --git a/components/ulp/test_apps/lp_core/sdkconfig.ci.defaults b/components/ulp/test_apps/lp_core/sdkconfig.ci.defaults new file mode 100644 index 0000000000..e69de29bb2