Merge branch 'contrib/github_pr_15144_v5.4' into 'release/v5.4'

fix(twai): TWAI_GENERAL_CONFIG_DEFAULT_V2 initialize general_flags (GitHub PR) (v5.4)

See merge request espressif/esp-idf!36323
This commit is contained in:
morris
2025-01-15 12:26:58 +08:00
3 changed files with 21 additions and 1 deletions

View File

@@ -33,7 +33,7 @@ extern "C" {
.clkout_io = TWAI_IO_UNUSED, .bus_off_io = TWAI_IO_UNUSED, \
.tx_queue_len = 5, .rx_queue_len = 5, \
.alerts_enabled = TWAI_ALERT_NONE, .clkout_divider = 0, \
.intr_flags = ESP_INTR_FLAG_LEVEL1}
.intr_flags = ESP_INTR_FLAG_LEVEL1, .general_flags = {0}}
/**
* @brief Initializer macro for general configuration structure.
@@ -119,6 +119,7 @@ typedef struct {
By this approach, the system can power off TWAI's power domain.
This can save power, but at the expense of more RAM being consumed. */
} general_flags; /**< General flags */
// Ensure TWAI_GENERAL_CONFIG_DEFAULT_V2 is updated and in order if new fields are added
} twai_general_config_t;
/**

View File

@@ -7,6 +7,10 @@ if(CONFIG_SOC_I2C_SUPPORTED)
list(APPEND srcs test_i2c_lcd.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_lcd

View File

@@ -0,0 +1,15 @@
/*
* 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();
}