From 24b3a4ee45c184a9dc2f837c8c6942c489d4aaa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Neboj=C5=A1a=20Cvetkovi=C4=87?= Date: Wed, 17 Jan 2024 13:34:40 +0000 Subject: [PATCH] fix(twai): TWAI_GENERAL_CONFIG_DEFAULT initialize controller_id Fix for C++ warning `-Wmissing-field-initializers` Closes https://github.com/espressif/esp-idf/pull/12998 --- components/driver/twai/include/driver/twai.h | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/components/driver/twai/include/driver/twai.h b/components/driver/twai/include/driver/twai.h index 87d23d5bfa..fe1bd8abb2 100644 --- a/components/driver/twai/include/driver/twai.h +++ b/components/driver/twai/include/driver/twai.h @@ -22,16 +22,26 @@ extern "C" { /** * @brief Initializer macro for general configuration structure. * - * This initializer macros allows the TX GPIO, RX GPIO, and operating mode to be - * configured. The other members of the general configuration structure are + * This initializer macros allows the controller ID, TX GPIO, RX GPIO, and operating + * mode to be configured. The other members of the general configuration structure are * assigned default values. */ -#define TWAI_GENERAL_CONFIG_DEFAULT(tx_io_num, rx_io_num, op_mode) {.mode = op_mode, .tx_io = tx_io_num, .rx_io = rx_io_num, \ +#define TWAI_GENERAL_CONFIG_DEFAULT_V2(controller_num, tx_io_num, rx_io_num, op_mode) {.controller_id = controller_num, \ + .mode = op_mode, .tx_io = tx_io_num, .rx_io = rx_io_num, \ .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} +/** + * @brief Initializer macro for general configuration structure. + * + * This initializer macros allows the TX GPIO, RX GPIO, and operating mode to be + * configured. Controller ID is set to 0 and he other members of the general configuration + * structure are assigned default values. + */ +#define TWAI_GENERAL_CONFIG_DEFAULT(tx_io_num, rx_io_num, op_mode) TWAI_GENERAL_CONFIG_DEFAULT_V2(0, tx_io_num, rx_io_num, op_mode) + /** * @brief Alert flags *