mirror of
https://github.com/espressif/esp-idf.git
synced 2025-10-02 18:10:57 +02:00
refactor(driver): remove redundant driver dependencies
now the driver component only contains legacy code for i2c, twai and touch sensor
This commit is contained in:
@@ -231,7 +231,6 @@
|
||||
/tools/test_apps/components/test_utils/ @esp-idf-codeowners/peripherals @esp-idf-codeowners/system
|
||||
/tools/test_apps/configs/ @esp-idf-codeowners/system
|
||||
/tools/test_apps/linux_compatible/ @esp-idf-codeowners/system
|
||||
/tools/test_apps/peripherals/ @esp-idf-codeowners/peripherals
|
||||
/tools/test_apps/phy/ @esp-idf-codeowners/bluetooth @esp-idf-codeowners/wifi @esp-idf-codeowners/ieee802154
|
||||
/tools/test_apps/protocols/ @esp-idf-codeowners/network @esp-idf-codeowners/app-utilities
|
||||
/tools/test_apps/security/ @esp-idf-codeowners/security
|
||||
|
@@ -7,7 +7,7 @@ idf_component_register(
|
||||
app_update
|
||||
bootloader_support
|
||||
nvs_flash
|
||||
driver
|
||||
esp_driver_gpio
|
||||
spi_flash
|
||||
esp_psram
|
||||
efuse
|
||||
|
@@ -1,2 +1,2 @@
|
||||
idf_component_register(SRCS "test_exception.cpp"
|
||||
PRIV_REQUIRES unity driver)
|
||||
PRIV_REQUIRES unity)
|
||||
|
@@ -1,2 +1,2 @@
|
||||
idf_component_register(SRCS "test_exception_no_except.cpp"
|
||||
PRIV_REQUIRES unity driver)
|
||||
PRIV_REQUIRES unity)
|
||||
|
@@ -1,2 +1,2 @@
|
||||
idf_component_register(SRCS "test_cxx_general.cpp"
|
||||
PRIV_REQUIRES unity driver esp_timer)
|
||||
PRIV_REQUIRES unity esp_timer)
|
||||
|
@@ -1,2 +1,2 @@
|
||||
idf_component_register(SRCS "test_rtti.cpp"
|
||||
PRIV_REQUIRES unity driver)
|
||||
PRIV_REQUIRES unity)
|
||||
|
@@ -8,8 +8,7 @@ endif()
|
||||
set(srcs)
|
||||
|
||||
# Always included headers
|
||||
set(includes "deprecated"
|
||||
"i2c/include"
|
||||
set(includes "i2c/include"
|
||||
"touch_sensor/include"
|
||||
"twai/include")
|
||||
|
||||
@@ -45,15 +44,8 @@ else()
|
||||
# (REQUIRES cannot hide soc headers, since many arguments in the driver headers are chip-dependent)
|
||||
idf_component_register(SRCS "${srcs}"
|
||||
INCLUDE_DIRS ${includes}
|
||||
PRIV_REQUIRES efuse esp_timer esp_mm
|
||||
REQUIRES esp_pm esp_ringbuf freertos soc hal esp_hw_support
|
||||
# for backward compatibility, the driver component needs to
|
||||
# have a public dependency on other "esp_driver_foo" components
|
||||
esp_driver_gpio esp_driver_pcnt esp_driver_gptimer esp_driver_spi esp_driver_mcpwm
|
||||
esp_driver_ana_cmpr esp_driver_i2s esp_driver_sdmmc esp_driver_sdspi esp_driver_sdio
|
||||
esp_driver_dac esp_driver_rmt esp_driver_tsens esp_driver_sdm esp_driver_i2c
|
||||
esp_driver_uart esp_driver_ledc esp_driver_parlio esp_driver_usb_serial_jtag
|
||||
esp_driver_twai
|
||||
PRIV_REQUIRES esp_timer esp_mm esp_driver_gpio esp_ringbuf esp_pm
|
||||
REQUIRES freertos soc hal esp_hw_support esp_hal_i2c
|
||||
LDFRAGMENTS ${ldfragments}
|
||||
)
|
||||
endif()
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,6 @@
|
||||
idf_component_register(
|
||||
SRCS test_spi_utils.c param_test.c test_dualboard_utils.c
|
||||
INCLUDE_DIRS include
|
||||
REQUIRES driver unity
|
||||
REQUIRES driver unity esp_ringbuf esp_driver_spi
|
||||
PRIV_REQUIRES esp_driver_gpio
|
||||
)
|
||||
|
@@ -3,5 +3,5 @@ set(srcs "test_app_main.c"
|
||||
)
|
||||
|
||||
idf_component_register(SRCS ${srcs}
|
||||
PRIV_REQUIRES unity test_utils driver
|
||||
PRIV_REQUIRES unity test_utils driver esp_driver_gpio
|
||||
WHOLE_ARCHIVE)
|
||||
|
@@ -1,9 +1,9 @@
|
||||
set(srcs "test_app_main.c"
|
||||
"test_twai_loop_back.c"
|
||||
"test_twai_interactive.c")
|
||||
set(srcs "test_app_main.cpp"
|
||||
"test_twai_loop_back.cpp"
|
||||
"test_twai_interactive.cpp")
|
||||
|
||||
# In order for the cases defined by `TEST_CASE` to be linked into the final elf,
|
||||
# the component can be registered as WHOLE_ARCHIVE
|
||||
idf_component_register(SRCS ${srcs}
|
||||
PRIV_REQUIRES unity driver
|
||||
PRIV_REQUIRES unity driver esp_driver_gpio esp_hw_support
|
||||
WHOLE_ARCHIVE)
|
||||
|
@@ -23,7 +23,7 @@ void tearDown(void)
|
||||
unity_utils_evaluate_leaks_direct(TEST_MEMORY_LEAK_THRESHOLD);
|
||||
}
|
||||
|
||||
void app_main(void)
|
||||
extern "C" void app_main(void)
|
||||
{
|
||||
// _______ ___ ___ _____ _
|
||||
// |_ _\ \ / / \ |_ _| |_ _|__ ___| |_
|
@@ -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
|
||||
*/
|
||||
@@ -16,10 +16,10 @@
|
||||
#include "soc/soc_caps.h"
|
||||
#include "esp_log.h"
|
||||
|
||||
#define TEST_TWAI_TX_PIN 4
|
||||
#define TEST_TWAI_RX_PIN 5
|
||||
#define TEST_TWAI_TX_PIN GPIO_NUM_4
|
||||
#define TEST_TWAI_RX_PIN GPIO_NUM_5
|
||||
|
||||
#if CONFIG_TWAI_ISR_IN_IRAM
|
||||
#if CONFIG_TWAI_ISR_IN_IRAM_LEGACY || CONFIG_TWAI_ISR_IN_IRAM
|
||||
static void IRAM_ATTR test_delay_post_cache_disable(void *args)
|
||||
{
|
||||
esp_rom_delay_us(1000);
|
||||
@@ -31,7 +31,7 @@ TEST_CASE("twai_listen_only", "[twai]")
|
||||
twai_timing_config_t t_config = TWAI_TIMING_CONFIG_250KBITS();
|
||||
twai_filter_config_t f_config = TWAI_FILTER_CONFIG_ACCEPT_ALL();
|
||||
twai_general_config_t g_config = TWAI_GENERAL_CONFIG_DEFAULT(TEST_TWAI_TX_PIN, TEST_TWAI_RX_PIN, TWAI_MODE_LISTEN_ONLY);
|
||||
#if CONFIG_TWAI_ISR_IN_IRAM
|
||||
#if CONFIG_TWAI_ISR_IN_IRAM_LEGACY || CONFIG_TWAI_ISR_IN_IRAM
|
||||
g_config.intr_flags |= ESP_INTR_FLAG_IRAM;
|
||||
#endif
|
||||
// listen only mode doesn't need a tx queue
|
||||
@@ -39,7 +39,7 @@ TEST_CASE("twai_listen_only", "[twai]")
|
||||
TEST_ESP_OK(twai_driver_install(&g_config, &t_config, &f_config));
|
||||
TEST_ESP_OK(twai_start());
|
||||
|
||||
#if CONFIG_TWAI_ISR_IN_IRAM
|
||||
#if CONFIG_TWAI_ISR_IN_IRAM_LEGACY || CONFIG_TWAI_ISR_IN_IRAM
|
||||
printf("disable flash cache and check if we can still receive the frame\n");
|
||||
for (int i = 0; i < 100; i++) {
|
||||
unity_utils_run_cache_disable_stub(test_delay_post_cache_disable, NULL);
|
||||
@@ -70,12 +70,12 @@ TEST_CASE("twai_remote_request", "[twai]")
|
||||
TEST_ESP_OK(twai_driver_install_v2(&g_config, &t_config, &f_config, &bus_handle));
|
||||
TEST_ESP_OK(twai_start_v2(bus_handle));
|
||||
|
||||
twai_message_t req_msg = {
|
||||
.identifier = 0x6688,
|
||||
.data_length_code = 8,
|
||||
.rtr = true, // remote request
|
||||
.extd = true,// extended ID
|
||||
};
|
||||
twai_message_t req_msg{};
|
||||
req_msg.identifier = 0x6688;
|
||||
req_msg.data_length_code = 8;
|
||||
req_msg.rtr = true; // remote request
|
||||
req_msg.extd = true; // extended ID
|
||||
|
||||
TEST_ESP_OK(twai_transmit_v2(bus_handle, &req_msg, portMAX_DELAY));
|
||||
ESP_LOGI("TWAI", "send remote frame");
|
||||
|
@@ -4,6 +4,7 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "sdkconfig.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
@@ -20,7 +21,7 @@ TEST_CASE("driver_life_cycle", "[twai-loop-back]")
|
||||
{
|
||||
twai_timing_config_t t_config = TWAI_TIMING_CONFIG_100KBITS();
|
||||
twai_filter_config_t f_config = TWAI_FILTER_CONFIG_ACCEPT_ALL();
|
||||
twai_general_config_t g_config = TWAI_GENERAL_CONFIG_DEFAULT(0, 0, TWAI_MODE_NO_ACK);
|
||||
twai_general_config_t g_config = TWAI_GENERAL_CONFIG_DEFAULT(GPIO_NUM_0, GPIO_NUM_0, TWAI_MODE_NO_ACK);
|
||||
printf("install driver\r\n");
|
||||
TEST_ESP_OK(twai_driver_install(&g_config, &t_config, &f_config));
|
||||
// can't install the driver multiple times
|
||||
@@ -42,13 +43,13 @@ TEST_CASE("driver_life_cycle", "[twai-loop-back]")
|
||||
TEST_CASE("twai_bit_timing", "[twai-loop-back]")
|
||||
{
|
||||
twai_filter_config_t f_config = TWAI_FILTER_CONFIG_ACCEPT_ALL();
|
||||
twai_general_config_t g_config = TWAI_GENERAL_CONFIG_DEFAULT(0, 0, TWAI_MODE_NO_ACK);
|
||||
twai_timing_config_t t_config = {
|
||||
.quanta_resolution_hz = 33333, // invalid resolution
|
||||
.tseg_1 = 15,
|
||||
.tseg_2 = 4,
|
||||
.sjw = 1,
|
||||
};
|
||||
twai_general_config_t g_config = TWAI_GENERAL_CONFIG_DEFAULT(GPIO_NUM_0, GPIO_NUM_0, TWAI_MODE_NO_ACK);
|
||||
twai_timing_config_t t_config{};
|
||||
t_config.quanta_resolution_hz = 33333; // invalid resolution
|
||||
t_config.tseg_1 = 15;
|
||||
t_config.tseg_2 = 4;
|
||||
t_config.sjw = 1;
|
||||
|
||||
TEST_ESP_ERR(ESP_ERR_INVALID_ARG, twai_driver_install(&g_config, &t_config, &f_config));
|
||||
|
||||
t_config.quanta_resolution_hz = 2000000;
|
||||
@@ -61,16 +62,17 @@ TEST_CASE("twai_mode_std_no_ack_25kbps", "[twai-loop-back]")
|
||||
twai_timing_config_t t_config = TWAI_TIMING_CONFIG_25KBITS();
|
||||
twai_filter_config_t f_config = TWAI_FILTER_CONFIG_ACCEPT_ALL();
|
||||
// bind the TX and RX to the same GPIO to act like a loopback
|
||||
twai_general_config_t g_config = TWAI_GENERAL_CONFIG_DEFAULT(0, 0, TWAI_MODE_NO_ACK);
|
||||
twai_general_config_t g_config = TWAI_GENERAL_CONFIG_DEFAULT(GPIO_NUM_0, GPIO_NUM_0, TWAI_MODE_NO_ACK);
|
||||
printf("install twai driver\r\n");
|
||||
TEST_ESP_OK(twai_driver_install(&g_config, &t_config, &f_config));
|
||||
TEST_ESP_OK(twai_start());
|
||||
|
||||
twai_message_t tx_msg = {
|
||||
.identifier = 0x123,
|
||||
.data = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88},
|
||||
.self = true, // Transmitted message will also received by the same node
|
||||
};
|
||||
twai_message_t tx_msg{};
|
||||
tx_msg.identifier = 0x123;
|
||||
uint8_t data[] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88};
|
||||
memcpy(tx_msg.data, data, sizeof(data));
|
||||
tx_msg.self = true; // Transmitted message will also received by the same node
|
||||
|
||||
for (int len = 0; len <= 8; len++) {
|
||||
tx_msg.data_length_code = len;
|
||||
printf("TX id %lx len %d\r\n", tx_msg.identifier, tx_msg.data_length_code);
|
||||
@@ -95,19 +97,19 @@ TEST_CASE("twai_mode_ext_no_ack_250kbps", "[twai-loop-back]")
|
||||
twai_timing_config_t t_config = TWAI_TIMING_CONFIG_250KBITS();
|
||||
twai_filter_config_t f_config = TWAI_FILTER_CONFIG_ACCEPT_ALL();
|
||||
// bind the TX and RX to the same GPIO to act like a loopback
|
||||
twai_general_config_t g_config = TWAI_GENERAL_CONFIG_DEFAULT(0, 0, TWAI_MODE_NO_ACK);
|
||||
twai_message_t tx_msg = {
|
||||
.identifier = 0x12345,
|
||||
.data_length_code = 6,
|
||||
.data = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66},
|
||||
.self = true, // Transmitted message will also received by the same node
|
||||
.extd = true, // Extended Frame Format (29bit ID)
|
||||
};
|
||||
twai_general_config_t g_config = TWAI_GENERAL_CONFIG_DEFAULT(GPIO_NUM_0, GPIO_NUM_0, TWAI_MODE_NO_ACK);
|
||||
twai_message_t tx_msg{};
|
||||
tx_msg.identifier = 0x12345;
|
||||
tx_msg.data_length_code = 6;
|
||||
uint8_t data[] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66};
|
||||
memcpy(tx_msg.data, data, sizeof(data));
|
||||
tx_msg.self = true; // Transmitted message will also received by the same node
|
||||
tx_msg.extd = true; // Extended Frame Format (29bit ID)
|
||||
|
||||
for (int i = 0; i < SOC_TWAI_CONTROLLER_NUM; i++) {
|
||||
g_config.controller_id = i;
|
||||
g_config.tx_io = i;
|
||||
g_config.rx_io = i;
|
||||
g_config.tx_io = static_cast<gpio_num_t>(i);
|
||||
g_config.rx_io = static_cast<gpio_num_t>(i);
|
||||
printf("install twai driver %d\r\n", g_config.controller_id);
|
||||
TEST_ESP_OK(twai_driver_install_v2(&g_config, &t_config, &f_config, &twai_buses[i]));
|
||||
TEST_ESP_OK(twai_start_v2(twai_buses[i]));
|
||||
@@ -151,20 +153,20 @@ static void s_test_sleep_retention(bool allow_pd)
|
||||
twai_timing_config_t t_config = TWAI_TIMING_CONFIG_250KBITS();
|
||||
twai_filter_config_t f_config = TWAI_FILTER_CONFIG_ACCEPT_ALL();
|
||||
// bind the TX and RX to the same GPIO to act like a loopback
|
||||
twai_general_config_t g_config = TWAI_GENERAL_CONFIG_DEFAULT(0, 0, TWAI_MODE_NO_ACK);
|
||||
twai_general_config_t g_config = TWAI_GENERAL_CONFIG_DEFAULT(GPIO_NUM_0, GPIO_NUM_0, TWAI_MODE_NO_ACK);
|
||||
g_config.general_flags.sleep_allow_pd = allow_pd;
|
||||
twai_message_t tx_msg = {
|
||||
.identifier = 0x12345,
|
||||
.data_length_code = 6,
|
||||
.data = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66},
|
||||
.self = true, // Transmitted message will also received by the same node
|
||||
.extd = true, // Extended Frame Format (29bit ID)
|
||||
};
|
||||
twai_message_t tx_msg{};
|
||||
tx_msg.identifier = 0x12345;
|
||||
tx_msg.data_length_code = 6;
|
||||
uint8_t data[] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66};
|
||||
memcpy(tx_msg.data, data, sizeof(data));
|
||||
tx_msg.self = true; // Transmitted message will also received by the same node
|
||||
tx_msg.extd = true; // Extended Frame Format (29bit ID)
|
||||
|
||||
for (int i = 0; i < SOC_TWAI_CONTROLLER_NUM; i++) {
|
||||
g_config.controller_id = i;
|
||||
g_config.tx_io = i;
|
||||
g_config.rx_io = i;
|
||||
g_config.tx_io = static_cast<gpio_num_t>(i);
|
||||
g_config.rx_io = static_cast<gpio_num_t>(i);
|
||||
printf("install twai driver %d\r\n", g_config.controller_id);
|
||||
TEST_ESP_OK(twai_driver_install_v2(&g_config, &t_config, &f_config, &twai_buses[i]));
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
CONFIG_COMPILER_DUMP_RTL_FILES=y
|
||||
CONFIG_TWAI_ISR_IN_IRAM=y
|
||||
CONFIG_TWAI_ISR_IN_IRAM_LEGACY=y
|
||||
CONFIG_COMPILER_OPTIMIZATION_NONE=y
|
||||
|
||||
# silent the error check, as the error string are stored in rodata, causing RTL check failure
|
||||
|
@@ -1,4 +1,4 @@
|
||||
idf_component_register(SRCS "test_app_main.c" "test_touch_v1.c"
|
||||
PRIV_REQUIRES unity driver
|
||||
PRIV_REQUIRES unity driver esp_pm
|
||||
WHOLE_ARCHIVE
|
||||
)
|
||||
|
@@ -1,4 +1,4 @@
|
||||
idf_component_register(SRCS "test_app_main.c" "test_touch_v2.c" "touch_scope.c"
|
||||
PRIV_REQUIRES unity driver
|
||||
PRIV_REQUIRES unity driver esp_driver_gpio esp_driver_uart
|
||||
WHOLE_ARCHIVE
|
||||
)
|
||||
|
@@ -1,6 +1,12 @@
|
||||
menu "Legacy TWAI Driver Configurations"
|
||||
depends on SOC_TWAI_SUPPORTED
|
||||
|
||||
config TWAI_ISR_IN_IRAM_LEGACY
|
||||
bool "Place TWAI ISR function in IRAM"
|
||||
default n
|
||||
help
|
||||
Place the TWAI ISR in to IRAM to reduce latency and increase performance
|
||||
|
||||
config TWAI_SKIP_LEGACY_CONFLICT_CHECK
|
||||
bool "Skip legacy driver conflict check"
|
||||
default n
|
||||
|
@@ -73,7 +73,7 @@ extern "C" {
|
||||
#define TWAI_ALERT_PERIPH_RESET 0x00010000 /**< Alert(65536): The TWAI controller was reset */
|
||||
#define TWAI_ALERT_ALL 0x0001FFFF /**< Bit mask to enable all alerts during configuration */
|
||||
#define TWAI_ALERT_NONE 0x00000000 /**< Bit mask to disable all alerts during configuration */
|
||||
#define TWAI_ALERT_AND_LOG 0x00020000 /**< Bit mask to enable alerts to also be logged when they occur. Note that logging from the ISR is disabled if CONFIG_TWAI_ISR_IN_IRAM is enabled (see docs). */
|
||||
#define TWAI_ALERT_AND_LOG 0x00020000 /**< Bit mask to enable alerts to also be logged when they occur */
|
||||
|
||||
/** @endcond */
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
[mapping:twai_driver]
|
||||
archive: libdriver.a
|
||||
entries:
|
||||
if TWAI_ISR_IN_IRAM = y:
|
||||
if TWAI_ISR_IN_IRAM = y || TWAI_ISR_IN_IRAM_LEGACY = y:
|
||||
twai: twai_alert_handler (noflash)
|
||||
twai: twai_handle_rx_buffer_frames (noflash)
|
||||
twai: twai_handle_tx_buffer_frame (noflash)
|
||||
@@ -10,7 +10,7 @@ entries:
|
||||
[mapping:twai_hal_legacy]
|
||||
archive: libhal.a
|
||||
entries:
|
||||
if TWAI_ISR_IN_IRAM = y:
|
||||
if TWAI_ISR_IN_IRAM = y || TWAI_ISR_IN_IRAM_LEGACY = y:
|
||||
twai_hal_v1: twai_hal_decode_interrupt (noflash)
|
||||
twai_hal_v1: twai_hal_get_events (noflash)
|
||||
twai_hal_v1: twai_hal_format_frame (noflash)
|
||||
@@ -19,6 +19,9 @@ entries:
|
||||
twai_hal_v1: twai_hal_get_rx_msg_count (noflash)
|
||||
twai_hal_v1: twai_hal_read_rx_fifo (noflash)
|
||||
twai_hal_v1: twai_hal_check_state_flags (noflash)
|
||||
twai_hal_v1: twai_hal_read_rx_fifo (noflash)
|
||||
twai_hal_v1: twai_hal_check_state_flags (noflash)
|
||||
twai_hal_v1: twai_hal_clear_rx_fifo_overrun (noflash)
|
||||
|
||||
if TWAI_ERRATA_FIX_RX_FRAME_INVALID = y || TWAI_ERRATA_FIX_RX_FIFO_CORRUPT = y:
|
||||
twai_hal_v1: twai_hal_prepare_for_reset (noflash)
|
||||
|
@@ -47,11 +47,11 @@
|
||||
#define TWAI_SET_FLAG(var, mask) ((var) |= (mask))
|
||||
#define TWAI_RESET_FLAG(var, mask) ((var) &= ~(mask))
|
||||
|
||||
#ifdef CONFIG_TWAI_ISR_IN_IRAM
|
||||
#if defined(CONFIG_TWAI_ISR_IN_IRAM) || defined(CONFIG_TWAI_ISR_IN_IRAM_LEGACY)
|
||||
#define TWAI_MALLOC_CAPS (MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT)
|
||||
#else
|
||||
#define TWAI_MALLOC_CAPS MALLOC_CAP_DEFAULT
|
||||
#endif //CONFIG_TWAI_ISR_IN_IRAM
|
||||
#endif // CONFIG_TWAI_ISR_IN_IRAM || CONFIG_TWAI_ISR_IN_IRAM_LEGACY
|
||||
|
||||
#define DRIVER_DEFAULT_INTERRUPTS 0xE7 //Exclude data overrun (bit[3]) and brp_div (bit[4])
|
||||
|
||||
@@ -123,7 +123,7 @@ static void twai_alert_handler(twai_obj_t *p_twai_obj, uint32_t alert_code, int
|
||||
//Signify alert has occurred
|
||||
TWAI_SET_FLAG(p_twai_obj->alerts_triggered, alert_code);
|
||||
*alert_req = 1;
|
||||
#ifndef CONFIG_TWAI_ISR_IN_IRAM //Only log if ISR is not in IRAM
|
||||
#if !defined(CONFIG_TWAI_ISR_IN_IRAM) && !defined(CONFIG_TWAI_ISR_IN_IRAM_LEGACY) //Only log if ISR is not in IRAM
|
||||
if (p_twai_obj->alerts_enabled & TWAI_ALERT_AND_LOG) {
|
||||
if (alert_code >= ALERT_LOG_LEVEL_ERROR) {
|
||||
ESP_EARLY_LOGE(TWAI_TAG, "Alert %" PRIu32, alert_code);
|
||||
@@ -133,7 +133,7 @@ static void twai_alert_handler(twai_obj_t *p_twai_obj, uint32_t alert_code, int
|
||||
ESP_EARLY_LOGI(TWAI_TAG, "Alert %" PRIu32, alert_code);
|
||||
}
|
||||
}
|
||||
#endif //CONFIG_TWAI_ISR_IN_IRAM
|
||||
#endif // !CONFIG_TWAI_ISR_IN_IRAM && !CONFIG_TWAI_ISR_IN_IRAM_LEGACY
|
||||
}
|
||||
}
|
||||
|
||||
@@ -486,7 +486,7 @@ esp_err_t twai_driver_install_v2(const twai_general_config_t *g_config, const tw
|
||||
// assert the GPIO number is not a negative number (shift operation on a negative number is undefined)
|
||||
TWAI_CHECK(GPIO_IS_VALID_OUTPUT_GPIO(g_config->tx_io), ESP_ERR_INVALID_ARG);
|
||||
TWAI_CHECK(GPIO_IS_VALID_GPIO(g_config->rx_io), ESP_ERR_INVALID_ARG);
|
||||
#ifndef CONFIG_TWAI_ISR_IN_IRAM
|
||||
#if !defined(CONFIG_TWAI_ISR_IN_IRAM) && !defined(CONFIG_TWAI_ISR_IN_IRAM_LEGACY)
|
||||
TWAI_CHECK(!(g_config->intr_flags & ESP_INTR_FLAG_IRAM), ESP_ERR_INVALID_ARG);
|
||||
#endif
|
||||
int controller_id = g_config->controller_id;
|
||||
|
@@ -11,6 +11,7 @@ set(priv_requires
|
||||
unity
|
||||
esp_driver_cam
|
||||
esp_psram
|
||||
esp_driver_ledc
|
||||
)
|
||||
|
||||
idf_component_register(SRCS ${srcs}
|
||||
|
@@ -76,7 +76,7 @@ static esp_err_t gptimer_register_to_group(gptimer_t *timer)
|
||||
.depends = RETENTION_MODULE_BITMAP_INIT(CLOCK_SYSTEM)
|
||||
};
|
||||
if (sleep_retention_module_init(module, &init_param) != ESP_OK) {
|
||||
// even though the sleep retention module init failed, RMT driver should still work, so just warning here
|
||||
// even though the sleep retention module init failed, gptimer driver should still work, so just warning here
|
||||
ESP_LOGW(TAG, "init sleep retention failed on TimerGroup%d Timer%d, power domain may be turned off during sleep", group->group_id, timer_id);
|
||||
}
|
||||
#endif // GPTIMER_USE_RETENTION_LINK
|
||||
|
@@ -1,5 +1,5 @@
|
||||
idf_component_register(SRCS "test_app_main.c" "test_i2s_multi_dev.c"
|
||||
PRIV_REQUIRES unity driver test_utils
|
||||
PRIV_REQUIRES unity test_utils esp_driver_gpio esp_driver_i2s
|
||||
INCLUDE_DIRS "."
|
||||
WHOLE_ARCHIVE
|
||||
)
|
||||
|
@@ -2,5 +2,5 @@ set(srcs "test_app_main.c"
|
||||
"test_sdio_sdhost.c")
|
||||
|
||||
idf_component_register(SRCS ${srcs}
|
||||
PRIV_REQUIRES unity test_driver_utils driver esp_serial_slave_link sdmmc test_utils esp_timer
|
||||
PRIV_REQUIRES unity esp_serial_slave_link test_utils esp_timer esp_driver_sdmmc
|
||||
WHOLE_ARCHIVE)
|
||||
|
@@ -1,3 +1,5 @@
|
||||
dependencies:
|
||||
ccomp_timer: "^1.0.0"
|
||||
espressif/esp_serial_slave_link: "^1.1.0"
|
||||
test_driver_utils:
|
||||
path: ${IDF_PATH}/components/driver/test_apps/components/test_driver_utils
|
||||
|
@@ -2,5 +2,5 @@ set(srcs "test_app_main.c"
|
||||
"test_sdio_slave.c")
|
||||
|
||||
idf_component_register(SRCS ${srcs}
|
||||
PRIV_REQUIRES test_driver_utils driver esp_hw_support
|
||||
PRIV_REQUIRES test_driver_utils esp_hw_support esp_driver_sdio
|
||||
WHOLE_ARCHIVE)
|
||||
|
@@ -16,6 +16,6 @@ endif()
|
||||
# the component can be registered as WHOLE_ARCHIVE
|
||||
idf_component_register(
|
||||
SRCS ${srcs}
|
||||
PRIV_REQUIRES esp_driver_spi spi_flash esp_timer
|
||||
PRIV_REQUIRES esp_driver_spi spi_flash esp_timer esp_driver_gpio
|
||||
WHOLE_ARCHIVE
|
||||
)
|
||||
|
@@ -10,6 +10,6 @@ set(srcs
|
||||
# the component can be registered as WHOLE_ARCHIVE
|
||||
idf_component_register(
|
||||
SRCS ${srcs}
|
||||
PRIV_REQUIRES esp_driver_spi spi_flash
|
||||
PRIV_REQUIRES esp_driver_spi spi_flash esp_driver_gpio
|
||||
WHOLE_ARCHIVE
|
||||
)
|
||||
|
@@ -2,6 +2,6 @@
|
||||
# the component can be registered as WHOLE_ARCHIVE
|
||||
idf_component_register(
|
||||
SRCS "test_app_main.c" "test_usb_serial_jtag.c"
|
||||
REQUIRES driver unity vfs esp_timer
|
||||
REQUIRES unity vfs esp_timer esp_driver_usb_serial_jtag
|
||||
WHOLE_ARCHIVE
|
||||
)
|
||||
|
@@ -8,7 +8,7 @@ if(NOT ${target} STREQUAL "linux")
|
||||
"test_event_target.c")
|
||||
|
||||
list(APPEND priv_requires
|
||||
"driver"
|
||||
"esp_driver_gptimer"
|
||||
"esp_timer"
|
||||
"test_utils")
|
||||
endif()
|
||||
|
@@ -4,5 +4,5 @@ set(srcs "test_app_main.c"
|
||||
# In order for the cases defined by `TEST_CASE` to be linked into the final elf,
|
||||
# the component can be registered as WHOLE_ARCHIVE
|
||||
idf_component_register(SRCS ${srcs}
|
||||
PRIV_REQUIRES unity esp_driver_uart driver
|
||||
PRIV_REQUIRES unity esp_driver_uart esp_driver_ledc
|
||||
WHOLE_ARCHIVE)
|
||||
|
@@ -4,5 +4,5 @@ set(srcs "test_app_main.c"
|
||||
# In order for the cases defined by `TEST_CASE` to be linked into the final elf,
|
||||
# the component can be registered as WHOLE_ARCHIVE
|
||||
idf_component_register(SRCS ${srcs}
|
||||
PRIV_REQUIRES esp_lcd unity driver esp_driver_i2s
|
||||
PRIV_REQUIRES esp_lcd unity esp_driver_i2s
|
||||
WHOLE_ARCHIVE)
|
||||
|
@@ -4,5 +4,5 @@ set(srcs "test_app_main.c"
|
||||
# In order for the cases defined by `TEST_CASE` to be linked into the final elf,
|
||||
# the component can be registered as WHOLE_ARCHIVE
|
||||
idf_component_register(SRCS ${srcs}
|
||||
PRIV_REQUIRES esp_lcd unity driver esp_driver_parlio
|
||||
PRIV_REQUIRES esp_lcd unity esp_driver_parlio
|
||||
WHOLE_ARCHIVE)
|
||||
|
@@ -8,5 +8,5 @@ endif()
|
||||
# In order for the cases defined by `TEST_CASE` to be linked into the final elf,
|
||||
# the component can be registered as WHOLE_ARCHIVE
|
||||
idf_component_register(SRCS ${srcs}
|
||||
PRIV_REQUIRES esp_lcd unity driver esp_timer spi_flash
|
||||
PRIV_REQUIRES esp_lcd unity esp_timer spi_flash
|
||||
WHOLE_ARCHIVE)
|
||||
|
@@ -22,5 +22,5 @@ if(CONFIG_LIBC_OPTIMIZED_MISALIGNED_ACCESS)
|
||||
endif()
|
||||
|
||||
idf_component_register(SRCS "${srcs}"
|
||||
PRIV_REQUIRES unity vfs cmock driver esp_timer spi_flash test_utils pthread esp_psram
|
||||
PRIV_REQUIRES unity vfs cmock esp_timer spi_flash test_utils pthread esp_psram
|
||||
WHOLE_ARCHIVE)
|
||||
|
@@ -13,5 +13,5 @@ endif()
|
||||
# In order for the cases defined by `TEST_CASE` to be linked into the final elf,
|
||||
# the component can be registered as WHOLE_ARCHIVE
|
||||
idf_component_register(SRCS ${srcs}
|
||||
PRIV_REQUIRES unity esp_partition spi_flash esp_mm driver esp_timer test_mm_utils test_utils
|
||||
PRIV_REQUIRES unity esp_partition spi_flash esp_mm esp_timer test_mm_utils test_utils
|
||||
WHOLE_ARCHIVE)
|
||||
|
@@ -1,3 +1,3 @@
|
||||
idf_component_register(SRC_DIRS "."
|
||||
PRIV_INCLUDE_DIRS "."
|
||||
PRIV_REQUIRES cmock test_utils esp_netif driver esp_eth)
|
||||
PRIV_REQUIRES cmock test_utils esp_netif esp_eth esp_driver_gpio)
|
||||
|
@@ -5,5 +5,5 @@ set(sources "test_app_main.c"
|
||||
# the component must be registered as a WHOLE_ARCHIVE
|
||||
idf_component_register(SRCS ${sources}
|
||||
INCLUDE_DIRS "."
|
||||
PRIV_REQUIRES unity esp_pm ulp driver esp_timer esp_psram
|
||||
PRIV_REQUIRES unity esp_pm ulp esp_timer esp_psram esp_driver_gptimer
|
||||
WHOLE_ARCHIVE)
|
||||
|
@@ -15,5 +15,5 @@ endif()
|
||||
# In order for the cases defined by `TEST_CASE` to be linked into the final elf,
|
||||
# the component can be registered as WHOLE_ARCHIVE
|
||||
idf_component_register(SRCS ${srcs}
|
||||
PRIV_REQUIRES unity esp_psram spi_flash driver esp_partition
|
||||
PRIV_REQUIRES unity esp_psram spi_flash esp_partition esp_driver_spi esp_driver_gptimer
|
||||
WHOLE_ARCHIVE)
|
||||
|
@@ -1,6 +1,6 @@
|
||||
idf_component_register(SRCS "test_fatfs_sdcard_main.c" "test_fatfs_sdspi.c"
|
||||
INCLUDE_DIRS "."
|
||||
PRIV_REQUIRES unity fatfs vfs sdmmc driver test_fatfs_common esp_timer
|
||||
PRIV_REQUIRES unity fatfs vfs sdmmc test_fatfs_common esp_timer
|
||||
WHOLE_ARCHIVE)
|
||||
|
||||
if(CONFIG_SOC_SDMMC_HOST_SUPPORTED)
|
||||
|
@@ -19,5 +19,5 @@ set(priv_include_dirs
|
||||
# the final elf, the component can be registered as WHOLE_ARCHIVE
|
||||
idf_component_register(SRC_DIRS ${src_dirs}
|
||||
PRIV_INCLUDE_DIRS ${priv_include_dirs}
|
||||
PRIV_REQUIRES test_utils driver
|
||||
PRIV_REQUIRES test_utils esp_driver_gptimer
|
||||
WHOLE_ARCHIVE)
|
||||
|
@@ -22,6 +22,7 @@ idf_component_register(SRCS "${srcs}"
|
||||
INCLUDE_DIRS "include" "priv_include"
|
||||
PRIV_INCLUDE_DIRS "priv_include/${target}"
|
||||
REQUIRES ulp unity
|
||||
PRIV_REQUIRES esp_hal_timg
|
||||
LDFRAGMENTS linker.lf)
|
||||
|
||||
if(CONFIG_ULP_COPROC_ENABLED)
|
||||
|
@@ -277,7 +277,7 @@ idf_component_register(SRC_DIRS "${src_dirs}"
|
||||
EXCLUDE_SRCS "${exclude_srcs}"
|
||||
INCLUDE_DIRS "${public_include_dirs}"
|
||||
PRIV_INCLUDE_DIRS "${private_include_dirs}"
|
||||
REQUIRES esp_netif lwip esp_driver_uart driver
|
||||
REQUIRES esp_netif lwip esp_driver_uart esp_driver_gpio esp_driver_spi esp_driver_usb_serial_jtag
|
||||
LDFRAGMENTS linker.lf
|
||||
PRIV_REQUIRES console esp_coex esp_event esp_partition esp_timer
|
||||
ieee802154 mbedtls nvs_flash)
|
||||
|
@@ -5,5 +5,6 @@ set(srcs "test_app_main.c"
|
||||
# In order for the cases defined by `TEST_CASE` to be linked into the final elf,
|
||||
# the component can be registered as WHOLE_ARCHIVE
|
||||
idf_component_register(SRCS ${srcs}
|
||||
PRIV_REQUIRES unity test_utils spi_flash esp_timer driver bootloader_support
|
||||
PRIV_REQUIRES unity test_utils spi_flash esp_timer esp_driver_gpio esp_driver_spi
|
||||
bootloader_support
|
||||
WHOLE_ARCHIVE)
|
||||
|
@@ -4,5 +4,5 @@ set(srcs "test_app_main.c"
|
||||
# In order for the cases defined by `TEST_CASE` to be linked into the final elf,
|
||||
# the component can be registered as WHOLE_ARCHIVE
|
||||
idf_component_register(SRCS ${srcs}
|
||||
PRIV_REQUIRES unity test_utils spi_flash driver esp_partition esp_driver_i2c esp_driver_gptimer
|
||||
PRIV_REQUIRES unity test_utils spi_flash esp_partition esp_driver_i2c esp_driver_gptimer
|
||||
WHOLE_ARCHIVE)
|
||||
|
@@ -4,5 +4,5 @@ set(srcs "test_out_of_bounds_write.c"
|
||||
"test_app_main.c")
|
||||
|
||||
idf_component_register(SRCS ${srcs}
|
||||
PRIV_REQUIRES unity spi_flash driver esp_partition bootloader_support app_update
|
||||
PRIV_REQUIRES unity spi_flash esp_partition bootloader_support app_update esp_hal_timg
|
||||
WHOLE_ARCHIVE)
|
||||
|
@@ -96,4 +96,4 @@ endif()
|
||||
|
||||
idf_component_register(SRCS ${srcs}
|
||||
INCLUDE_DIRS ${includes}
|
||||
REQUIRES driver esp_adc)
|
||||
REQUIRES esp_adc esp_driver_gpio esp_driver_uart esp_driver_i2s esp_hal_i2c)
|
||||
|
@@ -61,6 +61,7 @@ endif()
|
||||
idf_component_register(SRCS ${app_sources}
|
||||
INCLUDE_DIRS "lp_core"
|
||||
REQUIRES ulp unity esp_timer test_utils
|
||||
PRIV_REQUIRES driver esp_driver_gptimer esp_driver_tsens
|
||||
WHOLE_ARCHIVE
|
||||
EMBED_FILES "test_vad_8k.pcm")
|
||||
|
||||
|
@@ -6,7 +6,7 @@ set(ulp_sources4 "ulp/test_main_i2c.c")
|
||||
|
||||
idf_component_register(SRCS ${app_sources}
|
||||
INCLUDE_DIRS "ulp"
|
||||
REQUIRES ulp unity test_utils
|
||||
REQUIRES ulp unity test_utils driver
|
||||
WHOLE_ARCHIVE)
|
||||
|
||||
set(ulp_app_name ulp_test_app)
|
||||
|
@@ -6,6 +6,37 @@ Peripherals
|
||||
Common Changes
|
||||
--------------
|
||||
|
||||
Legacy Driver Dependencies Removal
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The legacy driver component :component:`driver` has been deprecated and no longer contains public dependencies on the following driver components:
|
||||
|
||||
.. list::
|
||||
:class: no-bullet
|
||||
|
||||
- :component:`esp_driver_ana_cmpr`
|
||||
- :component:`esp_driver_dac`
|
||||
- :component:`esp_driver_gptimer`
|
||||
- :component:`esp_driver_i2s`
|
||||
- :component:`esp_driver_ledc`
|
||||
- :component:`esp_driver_mcpwm`
|
||||
- :component:`esp_driver_parlio`
|
||||
- :component:`esp_driver_pcnt`
|
||||
- :component:`esp_driver_rmt`
|
||||
- :component:`esp_driver_sdio`
|
||||
- :component:`esp_driver_sdm`
|
||||
- :component:`esp_driver_sdmmc`
|
||||
- :component:`esp_driver_sdspi`
|
||||
- :component:`esp_driver_spi`
|
||||
- :component:`esp_driver_tsens`
|
||||
- :component:`esp_driver_twai`
|
||||
- :component:`esp_driver_uart`
|
||||
- :component:`esp_driver_usb_serial_jtag`
|
||||
|
||||
If your project uses legacy :component:`driver` component, it is strongly recommended to remove :component:`driver` component dependencies, and add new driver component (usually ``esp_driver_xxx``) dependencies to your project.
|
||||
|
||||
If you still need to keep legacy :component:`driver` component (e.g. your project depends on the legacy ``i2c`` driver), please keep the :component:`driver` component remaining in the dependency list of your project (usually ``<project_root>/main/CMakeLists.txt``), and manually add component dependencies that are no longer included in :component:`driver` as needed.
|
||||
|
||||
All drivers' ``io_loop_back`` configuration have been removed
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
迁移构建系统至 ESP-IDF v5.0
|
||||
构建系统
|
||||
===================================
|
||||
|
||||
从 GNU Make 构建系统迁移至 ESP-IDF v5.0
|
||||
|
@@ -1,4 +1,4 @@
|
||||
迁移构建系统至 ESP-IDF v6.0
|
||||
构建系统
|
||||
===================================
|
||||
|
||||
:link_to_translation:`en:[English]`
|
||||
|
@@ -6,6 +6,37 @@
|
||||
公共变化
|
||||
--------
|
||||
|
||||
旧版驱动依赖移除
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
||||
旧版驱动组件 :component:`driver` 已被弃用,不再包含对以下驱动组件的公共依赖:
|
||||
|
||||
.. list::
|
||||
:class: no-bullet
|
||||
|
||||
- :component:`esp_driver_ana_cmpr`
|
||||
- :component:`esp_driver_dac`
|
||||
- :component:`esp_driver_gptimer`
|
||||
- :component:`esp_driver_i2s`
|
||||
- :component:`esp_driver_ledc`
|
||||
- :component:`esp_driver_mcpwm`
|
||||
- :component:`esp_driver_parlio`
|
||||
- :component:`esp_driver_pcnt`
|
||||
- :component:`esp_driver_rmt`
|
||||
- :component:`esp_driver_sdio`
|
||||
- :component:`esp_driver_sdm`
|
||||
- :component:`esp_driver_sdmmc`
|
||||
- :component:`esp_driver_sdspi`
|
||||
- :component:`esp_driver_spi`
|
||||
- :component:`esp_driver_tsens`
|
||||
- :component:`esp_driver_twai`
|
||||
- :component:`esp_driver_uart`
|
||||
- :component:`esp_driver_usb_serial_jtag`
|
||||
|
||||
如果您的项目使用了老旧的 :component:`driver` 驱动组件,强烈建议移除对 :component:`driver` 驱动组件的依赖,并为项目添加新驱动组件(通常是 ``esp_driver_xxx``)的依赖。
|
||||
|
||||
如仍需保留老旧的 :component:`driver` 驱动组件(例如您的项目依赖旧版 ``i2c`` 驱动),请将 :component:`driver` 组件保留在项目的组件依赖列表文件中(通常是 ``<project_root>/main/CMakeLists.txt`` ),并根据项目需要手动添加 :component:`driver` 中不再包含的驱动组件依赖。
|
||||
|
||||
所有驱动的 ``io_loop_back`` 配置已被移除
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
@@ -1,4 +1,3 @@
|
||||
idf_component_register(SRCS "cte_config.c"
|
||||
INCLUDE_DIRS .
|
||||
PRIV_REQUIRES driver bt
|
||||
)
|
||||
INCLUDE_DIRS .
|
||||
PRIV_REQUIRES bt esp_driver_gpio)
|
||||
|
@@ -1,4 +1,5 @@
|
||||
idf_component_register(SRCS "dvp_spi_lcd_main.c"
|
||||
INCLUDE_DIRS "."
|
||||
REQUIRES esp_mm esp_driver_cam esp_driver_i2c esp_lcd sensor_init
|
||||
REQUIRES esp_mm esp_driver_cam esp_driver_i2c esp_lcd
|
||||
PRIV_REQUIRES esp_driver_ledc
|
||||
)
|
||||
|
@@ -1,5 +1,5 @@
|
||||
## IDF Component Manager Manifest File
|
||||
dependencies:
|
||||
espressif/esp_codec_dev: ">=1.4.0,<1.5.0"
|
||||
espressif/esp_codec_dev: ">=1.5.0"
|
||||
i2s_examples_common:
|
||||
path: ${IDF_PATH}/examples/peripherals/i2s/i2s_examples_common
|
||||
|
@@ -1,3 +1,3 @@
|
||||
dependencies:
|
||||
pid_ctrl: "^0.1.1"
|
||||
bdc_motor: "^0.1.0"
|
||||
bdc_motor: "^0.2.0"
|
||||
|
@@ -1,7 +1,7 @@
|
||||
# Set usual component variables
|
||||
set(COMPONENT_SRCS "lp_core_gpio_wake_up_example_main.c")
|
||||
set(COMPONENT_ADD_INCLUDEDIRS "")
|
||||
set(COMPONENT_REQUIRES ulp driver)
|
||||
set(COMPONENT_REQUIRES ulp)
|
||||
|
||||
register_component()
|
||||
|
||||
|
@@ -1,6 +1,7 @@
|
||||
# Register the component
|
||||
idf_component_register(SRCS "ulp_riscv_touch_example_main.c"
|
||||
INCLUDE_DIRS ""
|
||||
PRIV_REQUIRES driver
|
||||
REQUIRES ulp)
|
||||
|
||||
#
|
||||
|
@@ -2,7 +2,7 @@
|
||||
dependencies:
|
||||
espressif/esp-zboss-lib: "~1.6.0"
|
||||
espressif/esp-zigbee-lib: "~1.6.0"
|
||||
espressif/led_strip: "~2.0.0"
|
||||
espressif/led_strip: "~3.0.0"
|
||||
## Required IDF version
|
||||
idf:
|
||||
version: ">=5.0.0"
|
||||
|
@@ -945,7 +945,6 @@ tools/ldgen/test/data/linker_script.ld
|
||||
tools/test_apps/build_system/embed_test/main/test_main.c
|
||||
tools/test_apps/build_system/ldgen_test/main/src1.c
|
||||
tools/test_apps/build_system/ldgen_test/main/src2.c
|
||||
tools/test_apps/peripherals/i2c_wifi/main/i2c_wifi_main.c
|
||||
tools/test_apps/protocols/esp_netif/build_config/main/init_macro.h
|
||||
tools/test_apps/protocols/esp_netif/build_config/main/main.cpp
|
||||
tools/test_apps/protocols/esp_netif/build_config/main/netif_init_c99.c
|
||||
|
@@ -1,8 +0,0 @@
|
||||
# Documentation: .gitlab/ci/README.md#manifest-file-to-control-the-buildtest-apps
|
||||
|
||||
tools/test_apps/peripherals/i2c_wifi:
|
||||
disable:
|
||||
- if: SOC_I2C_SUPPORTED != 1 or SOC_WIFI_SUPPORTED != 1
|
||||
disable_test:
|
||||
- if: IDF_TARGET == "esp32c61"
|
||||
reason: lack of runner
|
@@ -1,6 +0,0 @@
|
||||
# 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.22)
|
||||
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
project(i2c_wifi_main)
|
@@ -1,161 +0,0 @@
|
||||
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C5 | ESP32-C6 | ESP32-C61 | ESP32-S2 | ESP32-S3 |
|
||||
| ----------------- | ----- | -------- | -------- | -------- | -------- | --------- | -------- | -------- |
|
||||
|
||||
# I2C-WIFI Test
|
||||
|
||||
## Overview
|
||||
|
||||
This test demonstrates basic usage of I2C driver with wifi softAP.
|
||||
|
||||
### I2C MASTER
|
||||
|
||||
1. Switch on wifi softAP, and connect to your personal device, like your mobile phone.
|
||||
2. Send data to slave board.
|
||||
|
||||
### I2C SLAVE
|
||||
|
||||
1. Receive data from master board.
|
||||
|
||||
## How to use test
|
||||
|
||||
### Hardware Required
|
||||
|
||||
To run this test, you should have at least one ESP development board for master. But to make this test convenient, we also use a ESP development board for slave. (You can change your slave device, but don't forget to change code as well if necessary.)
|
||||
|
||||
#### Pin Assignment
|
||||
|
||||
**Note:** The following pin assignments are used by default, you can change these in the `menuconfig` .
|
||||
|
||||
| | SDA | SCL |
|
||||
| ------------------ | ------ | ------ |
|
||||
| ESP32/ESP32-S2 I2C | GPIO18 | GPIO19 |
|
||||
| ESP32-S3 I2C | GPIO1 | GPIO2 |
|
||||
| ESP32-C3 I2C | GPIO5 | GPIO9 |
|
||||
|
||||
**Note:** It is recommended to add external pull-up resistors for SDA/SCL pins to make the communication more stable, though the driver will enable internal pull-up resistors.
|
||||
|
||||
### Configure the project
|
||||
|
||||
Open the project configuration menu (`idf.py menuconfig`). Then go into `Test Configuration` menu.
|
||||
|
||||
#### I2C MASTER configuration
|
||||
|
||||
- In the `I2C working mode select` menu, you can set the working mode of i2c, choose `i2c master mode`.
|
||||
- In the `I2C Configuration` menu, you can set the pin number of SDA/SCL. Also you can modify the I2C port number and frequency of the master. And you can set the slave address here as well.
|
||||
- Enable `WIFI AP` if you need it.
|
||||
- In the `WIFI softAP Configuration` menu, you can set the wifi information here.
|
||||
|
||||
#### I2C SLAVE configuration
|
||||
|
||||
- In the `I2C working mode select` menu, you can set the working mode of i2c, choose `i2c slave mode`.
|
||||
- In the `I2C Configuration` menu, you can set the pin number of SDA/SCL. Also you can modify the I2C port number and address of the slave.
|
||||
|
||||
### Build and Flash
|
||||
|
||||
Enter `idf.py -p PORT flash monitor` to build, flash and monitor the project.
|
||||
|
||||
(To exit the serial monitor, type ``Ctrl-]``.)
|
||||
|
||||
See the [Getting Started Guide](https://docs.espressif.com/projects/esp-idf/en/latest/get-started/index.html) for full steps to configure and use ESP-IDF to build projects.
|
||||
|
||||
## Test Output
|
||||
|
||||
### MASTER
|
||||
|
||||
```bash
|
||||
I (339) cpu_start: Starting scheduler.
|
||||
I (359) I2C-wifi test: ESP_WIFI_MODE_AP
|
||||
I (359) pp: pp rom version: 9387209
|
||||
I (359) net80211: net80211 rom version: 9387209
|
||||
I (369) wifi:wifi driver task: 3fc9def0, prio:23, stack:6656, core=0
|
||||
I (369) system_api: Base MAC address is not set
|
||||
I (379) system_api: read default base MAC address from EFUSE
|
||||
I (379) wifi:wifi firmware version: d062fdb
|
||||
I (389) wifi:wifi certification version: v7.0
|
||||
I (389) wifi:config NVS flash: enabled
|
||||
I (389) wifi:config nano formatting: disabled
|
||||
I (399) wifi:Init data frame dynamic rx buffer num: 32
|
||||
I (399) wifi:Init management frame dynamic rx buffer num: 32
|
||||
I (409) wifi:Init management short buffer num: 32
|
||||
I (409) wifi:Init dynamic tx buffer num: 32
|
||||
I (419) wifi:Init static tx FG buffer num: 2
|
||||
I (419) wifi:Init static rx buffer size: 1600
|
||||
I (419) wifi:Init static rx buffer num: 10
|
||||
I (429) wifi:Init dynamic rx buffer num: 32
|
||||
I (429) wifi_init: rx ba win: 6
|
||||
I (439) wifi_init: tcpip mbox: 32
|
||||
I (439) wifi_init: udp mbox: 6
|
||||
I (439) wifi_init: tcp mbox: 6
|
||||
I (449) wifi_init: tcp tx win: 5744
|
||||
I (449) wifi_init: tcp rx win: 5744
|
||||
I (459) wifi_init: tcp mss: 1440
|
||||
I (459) wifi_init: WiFi IRAM OP enabled
|
||||
I (459) wifi_init: WiFi RX IRAM OP enabled
|
||||
I (469) phy_init: phy_version 500,985899c,Apr 19 2021,16:05:08
|
||||
I (589) wifi:set rx active PTI: 0, rx ack PTI: 0, and default PTI: 0
|
||||
I (599) wifi:mode : softAP (7c:df:a1:86:d8:a9)
|
||||
I (599) wifi:Total power save buffer number: 16
|
||||
I (599) wifi:Init max length of beacon: 752/752
|
||||
I (599) wifi:Init max length of beacon: 752/752
|
||||
I (609) I2C-wifi test: wifi_init_softap finished. SSID:myssid password:mypassword channel:1
|
||||
```
|
||||
|
||||
### SLAVE
|
||||
|
||||
```bash
|
||||
I (277) cpu_start: Starting scheduler.
|
||||
the clk config is 0, speed is 0
|
||||
slave mode.read thread start...
|
||||
I (23609) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27
|
||||
I (23619) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27
|
||||
I (23629) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27
|
||||
I (23639) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27
|
||||
I (23649) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27
|
||||
I (23659) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27
|
||||
I (23669) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27
|
||||
I (23679) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27
|
||||
I (23689) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27
|
||||
I (23699) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27
|
||||
I (23709) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27
|
||||
I (23719) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27
|
||||
I (23729) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27
|
||||
I (23739) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27
|
||||
I (23749) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27
|
||||
I (23759) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27
|
||||
I (23769) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27
|
||||
I (23779) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27
|
||||
I (23789) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27
|
||||
I (23799) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27
|
||||
I (23809) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27
|
||||
I (23819) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27
|
||||
I (23829) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27
|
||||
I (23839) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27
|
||||
I (23849) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27
|
||||
I (23859) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27
|
||||
I (23869) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27
|
||||
I (23879) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27
|
||||
I (23889) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27
|
||||
I (23899) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27
|
||||
I (23909) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27
|
||||
I (23919) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27
|
||||
I (23929) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27
|
||||
I (23939) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27
|
||||
I (23949) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27
|
||||
I (23959) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27
|
||||
I (23969) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27
|
||||
I (23979) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27
|
||||
I (23989) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27
|
||||
I (23999) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27
|
||||
I (24009) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27
|
||||
I (24019) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27
|
||||
I (24029) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27
|
||||
I (24039) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27
|
||||
I (24049) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27
|
||||
I (24059) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27
|
||||
I (24069) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27
|
||||
I (24079) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27
|
||||
I (24089) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27
|
||||
I (24099) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27
|
||||
I (24109) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27
|
||||
I (24119) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27
|
||||
```
|
@@ -1,2 +0,0 @@
|
||||
idf_component_register(SRCS "i2c_wifi_main.c"
|
||||
INCLUDE_DIRS "")
|
@@ -1,89 +0,0 @@
|
||||
menu "Test Configuration"
|
||||
|
||||
choice TEST_I2C_WORK_MODE
|
||||
prompt "I2C working mode select"
|
||||
default TEST_I2C_MASTER_MODE
|
||||
|
||||
config TEST_I2C_MASTER_MODE
|
||||
bool "i2c master mode"
|
||||
config TEST_I2C_SLAVE_MODE
|
||||
bool "I2C slave mode"
|
||||
endchoice
|
||||
|
||||
menu "I2C Configuration"
|
||||
|
||||
orsource "$IDF_PATH/examples/common_components/env_caps/$IDF_TARGET/Kconfig.env_caps"
|
||||
|
||||
config TEST_I2C_SCL_NUM
|
||||
int "SCL GPIO Num"
|
||||
range ENV_GPIO_RANGE_MIN ENV_GPIO_OUT_RANGE_MAX
|
||||
default 2 if IDF_TARGET_ESP32S3
|
||||
default 19 if IDF_TARGET_ESP32 || IDF_TARGET_ESP32S2
|
||||
default 9
|
||||
help
|
||||
GPIO number for I2C Master clock line.
|
||||
|
||||
config TEST_I2C_SDA_NUM
|
||||
int "SDA GPIO Num"
|
||||
range ENV_GPIO_RANGE_MIN ENV_GPIO_OUT_RANGE_MAX
|
||||
default 1 if IDF_TARGET_ESP32S3
|
||||
default 18 if IDF_TARGET_ESP32 || IDF_TARGET_ESP32S2
|
||||
default 5
|
||||
help
|
||||
GPIO number for I2C Master data line.
|
||||
|
||||
config TEST_I2C_PORT_NUM
|
||||
int "Port Number"
|
||||
default 0
|
||||
help
|
||||
Port number for I2C Master device.
|
||||
|
||||
config TEST_I2C_MASTER_FREQUENCY
|
||||
int "Master Frequency"
|
||||
default 400000
|
||||
depends on TEST_I2C_MASTER_MODE
|
||||
help
|
||||
I2C Speed of Master device.
|
||||
|
||||
config TEST_I2C_SLAVE_ADDR
|
||||
hex "ESP Slave Address"
|
||||
default 0x58
|
||||
help
|
||||
Hardware Address of I2C Slave Port.
|
||||
endmenu
|
||||
|
||||
config TEST_I2C_WIFI_AP_ENABLE
|
||||
bool "Enable WIFI AP"
|
||||
default y
|
||||
# C6 has not supported WIFI yet.
|
||||
depends on TEST_I2C_MASTER_MODE && !IDF_TARGET_ESP32C6
|
||||
|
||||
menu "WiFi softAP Configuration"
|
||||
depends on TEST_I2C_WIFI_AP_ENABLE
|
||||
|
||||
config TEST_WIFI_SSID
|
||||
string "WiFi SSID"
|
||||
default "myssid"
|
||||
help
|
||||
SSID (network name) for the test to connect to.
|
||||
|
||||
config TEST_WIFI_PASSWORD
|
||||
string "WiFi Password"
|
||||
default "mypassword"
|
||||
help
|
||||
WiFi password (WPA or WPA2) for the test to use.
|
||||
config TEST_WIFI_CHANNEL
|
||||
int "WiFi Channel"
|
||||
range 1 13
|
||||
default 1
|
||||
help
|
||||
WiFi channel (network channel) for the test to use.
|
||||
|
||||
config TEST_MAX_STA_CONN
|
||||
int "Maximal STA connections"
|
||||
default 4
|
||||
help
|
||||
Max number of the STA connects to AP.
|
||||
endmenu
|
||||
|
||||
endmenu
|
@@ -1,247 +0,0 @@
|
||||
/* I2C-WIFI - Test*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "esp_mac.h"
|
||||
#include "esp_wifi.h"
|
||||
#include "esp_event.h"
|
||||
#include "esp_log.h"
|
||||
#include "nvs_flash.h"
|
||||
|
||||
#include "esp_timer.h"
|
||||
#include "driver/i2c.h"
|
||||
|
||||
#define WAIT_TIMER_PERIOD (1 * 1000)
|
||||
|
||||
#define I2C_SDA_GPIO CONFIG_TEST_I2C_SDA_NUM
|
||||
#define I2C_SCL_GPIO CONFIG_TEST_I2C_SCL_NUM
|
||||
#define I2C_SLAVE_ADDR CONFIG_TEST_I2C_SLAVE_ADDR
|
||||
|
||||
#if CONFIG_TEST_I2C_MASTER_MODE
|
||||
#define I2C_TEST_WIFI_AP_ENABLE CONFIG_TEST_I2C_WIFI_AP_ENABLE
|
||||
#define I2C_CLK_FREQUENCY CONFIG_TEST_I2C_MASTER_FREQUENCY
|
||||
#define I2C_MASTER_NUM_PORT CONFIG_TEST_I2C_PORT_NUM
|
||||
#define I2C_MASTER_TX_BUF_DISABLE 0
|
||||
#define I2C_MASTER_RX_BUF_DISABLE 0
|
||||
#define I2C_ACK_CHECK_EN 0x1
|
||||
#define I2C_ACK_CHECK_DIS 0x0
|
||||
#else
|
||||
#define I2C_SLAVE_NUM_PORT CONFIG_TEST_I2C_PORT_NUM
|
||||
#define I2C_SLAVE_TX_BUF_LEN 256
|
||||
#define I2C_SLAVE_RX_BUF_LEN 256
|
||||
#endif
|
||||
|
||||
/* The tests use WiFi configuration that you can set via project configuration menu.
|
||||
|
||||
If you'd rather not, just change the below entries to strings with
|
||||
the config you want - ie #define TEST_WIFI_SSID "mywifissid"
|
||||
*/
|
||||
static const char* TAG = "I2C-wifi test";
|
||||
|
||||
#if I2C_TEST_WIFI_AP_ENABLE
|
||||
#define TEST_ESP_WIFI_SSID CONFIG_TEST_WIFI_SSID
|
||||
#define TEST_ESP_WIFI_PASS CONFIG_TEST_WIFI_PASSWORD
|
||||
#define TEST_ESP_WIFI_CHANNEL CONFIG_TEST_WIFI_CHANNEL
|
||||
#define TEST_MAX_STA_CONN CONFIG_TEST_MAX_STA_CONN
|
||||
|
||||
|
||||
static void wifi_event_handler(void *arg, esp_event_base_t event_base,
|
||||
int32_t event_id, void *event_data)
|
||||
{
|
||||
if (event_id == WIFI_EVENT_AP_STACONNECTED) {
|
||||
wifi_event_ap_staconnected_t *event = (wifi_event_ap_staconnected_t *) event_data;
|
||||
ESP_LOGI(TAG, "station "MACSTR" join, AID=%d", MAC2STR(event->mac), event->aid);
|
||||
} else if (event_id == WIFI_EVENT_AP_STADISCONNECTED) {
|
||||
wifi_event_ap_stadisconnected_t *event = (wifi_event_ap_stadisconnected_t *) event_data;
|
||||
ESP_LOGI(TAG, "station "MACSTR" leave, AID=%d, reason=%d", MAC2STR(event->mac), event->aid, event->reason);
|
||||
}
|
||||
}
|
||||
|
||||
void wifi_init_softap(void)
|
||||
{
|
||||
ESP_ERROR_CHECK(esp_netif_init());
|
||||
ESP_ERROR_CHECK(esp_event_loop_create_default());
|
||||
esp_netif_create_default_wifi_ap();
|
||||
|
||||
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
|
||||
ESP_ERROR_CHECK(esp_wifi_init(&cfg));
|
||||
|
||||
ESP_ERROR_CHECK(esp_event_handler_instance_register(WIFI_EVENT, ESP_EVENT_ANY_ID, &wifi_event_handler, NULL, NULL));
|
||||
|
||||
wifi_config_t wifi_config = {
|
||||
.ap = {
|
||||
.ssid = TEST_ESP_WIFI_SSID,
|
||||
.ssid_len = strlen(TEST_ESP_WIFI_SSID),
|
||||
.channel = TEST_ESP_WIFI_CHANNEL,
|
||||
.password = TEST_ESP_WIFI_PASS,
|
||||
.max_connection = TEST_MAX_STA_CONN,
|
||||
.authmode = WIFI_AUTH_WPA_WPA2_PSK
|
||||
},
|
||||
};
|
||||
if (strlen(TEST_ESP_WIFI_PASS) == 0) {
|
||||
wifi_config.ap.authmode = WIFI_AUTH_OPEN;
|
||||
}
|
||||
|
||||
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_AP));
|
||||
ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_AP, &wifi_config));
|
||||
ESP_ERROR_CHECK(esp_wifi_start());
|
||||
|
||||
ESP_LOGI(TAG, "wifi_init_softap finished. SSID:%s password:%s channel:%d", TEST_ESP_WIFI_SSID, TEST_ESP_WIFI_PASS, TEST_ESP_WIFI_CHANNEL);
|
||||
}
|
||||
|
||||
#endif //I2C_TEST_WIFI_AP_ENABLE
|
||||
|
||||
#if CONFIG_TEST_I2C_MASTER_MODE
|
||||
|
||||
static esp_timer_handle_t wait_timer;
|
||||
static uint32_t timer_count = 1000 * 1000;
|
||||
|
||||
static esp_err_t i2c_master_init(void)
|
||||
{
|
||||
i2c_port_t i2c_master_port = I2C_MASTER_NUM_PORT;
|
||||
|
||||
i2c_config_t conf_master = {
|
||||
.mode = I2C_MODE_MASTER,
|
||||
.sda_io_num = I2C_SDA_GPIO,
|
||||
.sda_pullup_en = true,
|
||||
.scl_io_num = I2C_SCL_GPIO,
|
||||
.scl_pullup_en = true,
|
||||
.master.clk_speed = I2C_CLK_FREQUENCY,
|
||||
};
|
||||
|
||||
esp_err_t err = i2c_param_config(i2c_master_port, &conf_master);
|
||||
if (err != ESP_OK) {
|
||||
return err;
|
||||
}
|
||||
|
||||
return i2c_driver_install(i2c_master_port, conf_master.mode, I2C_MASTER_RX_BUF_DISABLE, I2C_MASTER_TX_BUF_DISABLE, 0);
|
||||
}
|
||||
|
||||
// i2c master write
|
||||
static esp_err_t i2c_master_write_to_slave(uint8_t *data, uint32_t size)
|
||||
{
|
||||
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
|
||||
i2c_master_start(cmd);
|
||||
i2c_master_write_byte(cmd, (I2C_SLAVE_ADDR << 1) | I2C_MASTER_WRITE, I2C_ACK_CHECK_DIS);
|
||||
i2c_master_write(cmd, data, size, I2C_ACK_CHECK_DIS);
|
||||
|
||||
i2c_master_stop(cmd);
|
||||
esp_err_t ret = i2c_master_cmd_begin(I2C_MASTER_NUM_PORT, cmd, 1000 / portTICK_PERIOD_MS);
|
||||
i2c_cmd_link_delete(cmd);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static esp_err_t i2c_data_write(void)
|
||||
{
|
||||
uint8_t data[] = {0x6a, 0x1b, 0x05, 0x1f, 0x1f, 0x08, 0x01, 0x20, 0x19, 0x03, 0x27};
|
||||
|
||||
esp_err_t ret = i2c_master_write_to_slave(data, sizeof(data));
|
||||
if(ret != ESP_OK) {
|
||||
ESP_LOGW(TAG,"I2C timeout");
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void wait_timer_callback(void *arg)
|
||||
{
|
||||
// i2c write
|
||||
i2c_data_write();
|
||||
/* For local test, please remove this part and give long time testing. */
|
||||
timer_count--;
|
||||
if (timer_count == 0) {
|
||||
esp_timer_stop(wait_timer);
|
||||
return;
|
||||
}
|
||||
|
||||
// restart timer
|
||||
esp_timer_start_once(wait_timer, WAIT_TIMER_PERIOD);
|
||||
}
|
||||
|
||||
static const esp_timer_create_args_t wait_timer_args = {
|
||||
.callback = &wait_timer_callback,
|
||||
.arg = NULL,
|
||||
.name = "wait_timer",
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
static esp_err_t i2c_slave_init(void)
|
||||
{
|
||||
i2c_port_t i2c_slave_port = I2C_SLAVE_NUM_PORT;
|
||||
|
||||
i2c_config_t conf_slave = {
|
||||
.mode = I2C_MODE_SLAVE,
|
||||
.sda_io_num = I2C_SDA_GPIO,
|
||||
.sda_pullup_en = GPIO_PULLUP_ENABLE,
|
||||
.scl_io_num = I2C_SCL_GPIO,
|
||||
.scl_pullup_en = GPIO_PULLUP_ENABLE,
|
||||
.slave.addr_10bit_en = 0,
|
||||
.slave.slave_addr = I2C_SLAVE_ADDR,
|
||||
|
||||
};
|
||||
|
||||
i2c_param_config(i2c_slave_port, &conf_slave);
|
||||
return i2c_driver_install(i2c_slave_port, conf_slave.mode, I2C_SLAVE_RX_BUF_LEN, I2C_SLAVE_TX_BUF_LEN, 0);
|
||||
}
|
||||
|
||||
static void i2c_data_read(void *arg)
|
||||
{
|
||||
printf("slave mode.read thread start...\r\n");
|
||||
while (1) {
|
||||
uint8_t data[11] = {0};
|
||||
i2c_slave_read_buffer(I2C_SLAVE_NUM_PORT, data, sizeof(data), 1000 / portTICK_PERIOD_MS);
|
||||
ESP_LOG_BUFFER_HEX(TAG, data, sizeof(data));
|
||||
vTaskDelay(1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// i2c init function
|
||||
static esp_err_t i2c_init(void)
|
||||
{
|
||||
esp_err_t err = ESP_OK;
|
||||
#if CONFIG_TEST_I2C_MASTER_MODE
|
||||
err = i2c_master_init();
|
||||
#else
|
||||
err = i2c_slave_init();
|
||||
#endif
|
||||
return err;
|
||||
}
|
||||
|
||||
void app_main(void)
|
||||
{
|
||||
esp_err_t ret = i2c_init();
|
||||
|
||||
#if I2C_TEST_WIFI_AP_ENABLE
|
||||
//Initialize NVS
|
||||
ret = nvs_flash_init();
|
||||
if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
|
||||
ESP_ERROR_CHECK(nvs_flash_erase());
|
||||
ret = nvs_flash_init();
|
||||
}
|
||||
ESP_ERROR_CHECK(ret);
|
||||
|
||||
ESP_LOGI(TAG, "ESP_WIFI_MODE_AP");
|
||||
wifi_init_softap();
|
||||
#endif
|
||||
|
||||
#if CONFIG_TEST_I2C_MASTER_MODE
|
||||
ret = esp_timer_create(&wait_timer_args, &wait_timer);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(TAG, "esp_timer_create fail!");
|
||||
}
|
||||
|
||||
ret = esp_timer_start_once(wait_timer, WAIT_TIMER_PERIOD);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(TAG, "esp_timer_start_once fail!");
|
||||
}
|
||||
#else
|
||||
xTaskCreatePinnedToCore(i2c_data_read, "i2c_data_read", (3 * 1024), NULL, 1, NULL, 1);
|
||||
#endif
|
||||
ESP_ERROR_CHECK(ret);
|
||||
printf("I2C-WIFI test success\n");
|
||||
}
|
@@ -1,13 +0,0 @@
|
||||
# SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
import pytest
|
||||
from pytest_embedded_idf.dut import IdfDut
|
||||
from pytest_embedded_idf.utils import idf_parametrize
|
||||
|
||||
|
||||
@pytest.mark.generic
|
||||
@idf_parametrize(
|
||||
'target', ['esp32', 'esp32c2', 'esp32c3', 'esp32c6', 'esp32s2', 'esp32s3', 'esp32c5'], indirect=['target']
|
||||
)
|
||||
def test_i2c_wifi_startup(dut: IdfDut) -> None:
|
||||
dut.expect_exact('I2C-WIFI test success')
|
@@ -7,10 +7,6 @@ if(CONFIG_SOC_I2S_SUPPORTED)
|
||||
list(APPEND srcs test_i2s.cpp)
|
||||
endif()
|
||||
|
||||
if(CONFIG_SOC_TWAI_SUPPORTED)
|
||||
list(APPEND srcs test_twai.cpp)
|
||||
endif()
|
||||
|
||||
idf_component_register(SRCS "${srcs}"
|
||||
INCLUDE_DIRS "."
|
||||
PRIV_REQUIRES driver esp_driver_i2s)
|
||||
PRIV_REQUIRES esp_driver_i2s esp_driver_mcpwm esp_driver_sdmmc esp_driver_sdspi)
|
||||
|
@@ -1,15 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||
*/
|
||||
#include "driver/twai.h"
|
||||
|
||||
void test_twai_apis(void)
|
||||
{
|
||||
twai_filter_config_t f_config = TWAI_FILTER_CONFIG_ACCEPT_ALL();
|
||||
twai_general_config_t g_config = TWAI_GENERAL_CONFIG_DEFAULT(GPIO_NUM_0, GPIO_NUM_1, TWAI_MODE_NO_ACK);
|
||||
twai_timing_config_t t_config = TWAI_TIMING_CONFIG_100KBITS();
|
||||
twai_driver_install(&g_config, &t_config, &f_config);
|
||||
twai_driver_uninstall();
|
||||
}
|
Reference in New Issue
Block a user