diff --git a/tools/mocks/driver/CMakeLists.txt b/tools/mocks/driver/CMakeLists.txt index c818e71dee..17926ca751 100644 --- a/tools/mocks/driver/CMakeLists.txt +++ b/tools/mocks/driver/CMakeLists.txt @@ -10,9 +10,11 @@ set(include_dirs "${original_driver_dir}/i2c/include/driver" "${original_driver_dir}/spi/include/driver" "${original_driver_dir}/gpio/include/driver" + "${original_driver_dir}/rmt/include/driver" "${original_driver_dir}/i2c/include" "${original_driver_dir}/spi/include" "${original_driver_dir}/gpio/include" + "${original_driver_dir}/rmt/include" "${CMAKE_CURRENT_SOURCE_DIR}/../hal/include") idf_component_mock(INCLUDE_DIRS ${include_dirs} @@ -21,6 +23,10 @@ idf_component_mock(INCLUDE_DIRS ${include_dirs} ${original_driver_dir}/spi/include/driver/spi_master.h ${original_driver_dir}/spi/include/driver/spi_common.h ${original_driver_dir}/i2c/include/driver/i2c.h - ${original_driver_dir}/gpio/include/driver/gpio.h) + ${original_driver_dir}/gpio/include/driver/gpio.h + ${original_driver_dir}/rmt/include/driver/rmt_rx.h + ${original_driver_dir}/rmt/include/driver/rmt_tx.h + ${original_driver_dir}/rmt/include/driver/rmt_common.h + ${original_driver_dir}/rmt/include/driver/rmt_encoder.h) target_compile_definitions(${COMPONENT_LIB} PUBLIC SOC_I2C_NUM=2) diff --git a/tools/mocks/hal/include/hal/rmt_types.h b/tools/mocks/hal/include/hal/rmt_types.h new file mode 100644 index 0000000000..12df5fa1c8 --- /dev/null +++ b/tools/mocks/hal/include/hal/rmt_types.h @@ -0,0 +1,31 @@ +/* + * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/** + * NOTE: this is not the original header file from the hal component. It is a stripped-down copy to support mocking. + */ + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +typedef int rmt_clock_source_t; + +typedef union { + struct { + unsigned int duration0 : 15; /*!< Duration of level0 */ + unsigned int level0 : 1; /*!< Level of the first part */ + unsigned int duration1 : 15; /*!< Duration of level1 */ + unsigned int level1 : 1; /*!< Level of the second part */ + }; + unsigned int val; /*!< Equivalent unsigned value for the RMT symbol */ +} rmt_symbol_word_t; + +#ifdef __cplusplus +} +#endif diff --git a/tools/test_apps/.build-test-rules.yml b/tools/test_apps/.build-test-rules.yml index 789f6682fb..304bd93afc 100644 --- a/tools/test_apps/.build-test-rules.yml +++ b/tools/test_apps/.build-test-rules.yml @@ -19,6 +19,10 @@ tools/test_apps/linux_compatible/hello_world_linux_compatible: enable: - if: INCLUDE_DEFAULT == 1 or IDF_TARGET == "linux" +tools/test_apps/linux_compatible/rmt_mock_build_test: + enable: + - if: IDF_TARGET == "linux" + tools/test_apps/peripherals/i2c_wifi: disable: - if: SOC_I2C_SUPPORTED != 1 or SOC_WIFI_SUPPORTED != 1 diff --git a/tools/test_apps/linux_compatible/rmt_mock_build_test/CMakeLists.txt b/tools/test_apps/linux_compatible/rmt_mock_build_test/CMakeLists.txt new file mode 100644 index 0000000000..950402826c --- /dev/null +++ b/tools/test_apps/linux_compatible/rmt_mock_build_test/CMakeLists.txt @@ -0,0 +1,8 @@ +# The following lines of boilerplate have to be in your project's +# CMakeLists in this exact order for cmake to work correctly +cmake_minimum_required(VERSION 3.16) + +include($ENV{IDF_PATH}/tools/cmake/project.cmake) +set(COMPONENTS main) +list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/mocks/driver/") +project(rmt_mock_build_test) diff --git a/tools/test_apps/linux_compatible/rmt_mock_build_test/README.md b/tools/test_apps/linux_compatible/rmt_mock_build_test/README.md new file mode 100644 index 0000000000..37c142df16 --- /dev/null +++ b/tools/test_apps/linux_compatible/rmt_mock_build_test/README.md @@ -0,0 +1,2 @@ +| Supported Targets | Linux | +| ----------------- | ----- | diff --git a/tools/test_apps/linux_compatible/rmt_mock_build_test/main/CMakeLists.txt b/tools/test_apps/linux_compatible/rmt_mock_build_test/main/CMakeLists.txt new file mode 100644 index 0000000000..3dee6aea15 --- /dev/null +++ b/tools/test_apps/linux_compatible/rmt_mock_build_test/main/CMakeLists.txt @@ -0,0 +1,2 @@ +idf_component_register(SRCS "main.c" + PRIV_REQUIRES "driver") diff --git a/tools/test_apps/linux_compatible/rmt_mock_build_test/main/main.c b/tools/test_apps/linux_compatible/rmt_mock_build_test/main/main.c new file mode 100644 index 0000000000..4dbcdf91c8 --- /dev/null +++ b/tools/test_apps/linux_compatible/rmt_mock_build_test/main/main.c @@ -0,0 +1,22 @@ +/* + * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: CC0-1.0 + */ + +#include +#include "Mockrmt_encoder.h" +#include "Mockrmt_common.h" +#include "Mockrmt_tx.h" +#include "Mockrmt_rx.h" + +void app_main(void) +{ + rmt_channel_handle_t channel = 0; + + /*Test that mock functions exist*/ + rmt_new_bytes_encoder(NULL, NULL); + rmt_new_rx_channel(NULL, NULL); + rmt_del_channel(channel); + rmt_new_tx_channel(NULL, NULL); +} diff --git a/tools/test_apps/linux_compatible/rmt_mock_build_test/sdkconfig.defaults b/tools/test_apps/linux_compatible/rmt_mock_build_test/sdkconfig.defaults new file mode 100644 index 0000000000..9b39f10b99 --- /dev/null +++ b/tools/test_apps/linux_compatible/rmt_mock_build_test/sdkconfig.defaults @@ -0,0 +1 @@ +CONFIG_IDF_TARGET="linux"