Skip to content

Commit bd5c6b0

Browse files
committed
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
2 parents 3b41c1a + 6af9dc6 commit bd5c6b0

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

components/driver/twai/include/driver/twai.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ extern "C" {
3333
.clkout_io = TWAI_IO_UNUSED, .bus_off_io = TWAI_IO_UNUSED, \
3434
.tx_queue_len = 5, .rx_queue_len = 5, \
3535
.alerts_enabled = TWAI_ALERT_NONE, .clkout_divider = 0, \
36-
.intr_flags = ESP_INTR_FLAG_LEVEL1}
36+
.intr_flags = ESP_INTR_FLAG_LEVEL1, .general_flags = {0}}
3737

3838
/**
3939
* @brief Initializer macro for general configuration structure.
@@ -119,6 +119,7 @@ typedef struct {
119119
By this approach, the system can power off TWAI's power domain.
120120
This can save power, but at the expense of more RAM being consumed. */
121121
} general_flags; /**< General flags */
122+
// Ensure TWAI_GENERAL_CONFIG_DEFAULT_V2 is updated and in order if new fields are added
122123
} twai_general_config_t;
123124

124125
/**

tools/test_apps/system/cxx_build_test/main/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ if(CONFIG_SOC_I2C_SUPPORTED)
77
list(APPEND srcs test_i2c_lcd.cpp)
88
endif()
99

10+
if(CONFIG_SOC_TWAI_SUPPORTED)
11+
list(APPEND srcs test_twai.cpp)
12+
endif()
13+
1014
idf_component_register(SRCS "${srcs}"
1115
INCLUDE_DIRS "."
1216
PRIV_REQUIRES driver esp_lcd
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Unlicense OR CC0-1.0
5+
*/
6+
#include "driver/twai.h"
7+
8+
void test_twai_apis(void)
9+
{
10+
twai_filter_config_t f_config = TWAI_FILTER_CONFIG_ACCEPT_ALL();
11+
twai_general_config_t g_config = TWAI_GENERAL_CONFIG_DEFAULT(GPIO_NUM_0, GPIO_NUM_1, TWAI_MODE_NO_ACK);
12+
twai_timing_config_t t_config = TWAI_TIMING_CONFIG_100KBITS();
13+
twai_driver_install(&g_config, &t_config, &f_config);
14+
twai_driver_uninstall();
15+
}

0 commit comments

Comments
 (0)