From f02facbe280255aefaed314b1908afb9f99f4654 Mon Sep 17 00:00:00 2001 From: morris Date: Thu, 27 Oct 2022 18:22:52 +0800 Subject: [PATCH] twai: describe peripheral info Describe peripheral informations in the twai_peirph.c, including: Interrupt number, GPIO matrix signal ID, etc --- components/soc/esp32/CMakeLists.txt | 1 + components/soc/esp32/twai_periph.c | 23 +++++++++++++++ components/soc/esp32c3/CMakeLists.txt | 3 +- components/soc/esp32c3/twai_periph.c | 22 ++++++++++++++ components/soc/esp32c6/CMakeLists.txt | 3 +- components/soc/esp32c6/twai_periph.c | 31 ++++++++++++++++++++ components/soc/esp32s2/CMakeLists.txt | 1 + components/soc/esp32s2/twai_periph.c | 22 ++++++++++++++ components/soc/esp32s3/CMakeLists.txt | 3 +- components/soc/esp32s3/twai_periph.c | 22 ++++++++++++++ components/soc/include/soc/twai_periph.h | 37 ++++++++++++++---------- tools/ci/check_copyright_ignore.txt | 1 - 12 files changed, 149 insertions(+), 20 deletions(-) create mode 100644 components/soc/esp32/twai_periph.c create mode 100644 components/soc/esp32c3/twai_periph.c create mode 100644 components/soc/esp32c6/twai_periph.c create mode 100644 components/soc/esp32s2/twai_periph.c create mode 100644 components/soc/esp32s3/twai_periph.c diff --git a/components/soc/esp32/CMakeLists.txt b/components/soc/esp32/CMakeLists.txt index ff9ee1c5cb..f68511833c 100644 --- a/components/soc/esp32/CMakeLists.txt +++ b/components/soc/esp32/CMakeLists.txt @@ -17,6 +17,7 @@ set(srcs "sdmmc_periph.c" "spi_periph.c" "timer_periph.c" + "twai_periph.c" "touch_sensor_periph.c" "uart_periph.c") diff --git a/components/soc/esp32/twai_periph.c b/components/soc/esp32/twai_periph.c new file mode 100644 index 0000000000..cf763269fe --- /dev/null +++ b/components/soc/esp32/twai_periph.c @@ -0,0 +1,23 @@ +/* + * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "soc/soc.h" +#include "soc/twai_periph.h" +#include "soc/gpio_sig_map.h" + +const twai_controller_signal_conn_t twai_controller_periph_signals = { + .controllers = { + [0] = { + .module = PERIPH_TWAI_MODULE, + .irq_id = ETS_TWAI_INTR_SOURCE, + .tx_sig = TWAI_TX_IDX, + .rx_sig = TWAI_RX_IDX, + .bus_off_sig = TWAI_BUS_OFF_ON_IDX, + .clk_out_sig = TWAI_CLKOUT_IDX, + .stand_by_sig = -1, + }, + } +}; diff --git a/components/soc/esp32c3/CMakeLists.txt b/components/soc/esp32c3/CMakeLists.txt index fb9dfaee3e..367b4da596 100644 --- a/components/soc/esp32c3/CMakeLists.txt +++ b/components/soc/esp32c3/CMakeLists.txt @@ -12,7 +12,8 @@ set(srcs "i2c_periph.c" "uart_periph.c" "temperature_sensor_periph.c" - "timer_periph.c") + "timer_periph.c" + "twai_periph.c") add_prefix(srcs "${CMAKE_CURRENT_LIST_DIR}/" "${srcs}") diff --git a/components/soc/esp32c3/twai_periph.c b/components/soc/esp32c3/twai_periph.c new file mode 100644 index 0000000000..bae7c6ec5d --- /dev/null +++ b/components/soc/esp32c3/twai_periph.c @@ -0,0 +1,22 @@ +/* + * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "soc/twai_periph.h" +#include "soc/gpio_sig_map.h" + +const twai_controller_signal_conn_t twai_controller_periph_signals = { + .controllers = { + [0] = { + .module = PERIPH_TWAI_MODULE, + .irq_id = ETS_TWAI_INTR_SOURCE, + .tx_sig = TWAI_TX_IDX, + .rx_sig = TWAI_RX_IDX, + .bus_off_sig = TWAI_BUS_OFF_ON_IDX, + .clk_out_sig = TWAI_CLKOUT_IDX, + .stand_by_sig = -1, + }, + } +}; diff --git a/components/soc/esp32c6/CMakeLists.txt b/components/soc/esp32c6/CMakeLists.txt index 0eb7ac39a9..6d07768487 100644 --- a/components/soc/esp32c6/CMakeLists.txt +++ b/components/soc/esp32c6/CMakeLists.txt @@ -14,7 +14,8 @@ set(srcs "i2c_periph.c" "uart_periph.c" "temperature_sensor_periph.c" - "timer_periph.c") + "timer_periph.c" + "twai_periph.c") # ESP32C6-TODO list(REMOVE_ITEM srcs diff --git a/components/soc/esp32c6/twai_periph.c b/components/soc/esp32c6/twai_periph.c new file mode 100644 index 0000000000..712102bf14 --- /dev/null +++ b/components/soc/esp32c6/twai_periph.c @@ -0,0 +1,31 @@ +/* + * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "soc/twai_periph.h" +#include "soc/gpio_sig_map.h" + +const twai_controller_signal_conn_t twai_controller_periph_signals = { + .controllers = { + [0] = { + .module = PERIPH_TWAI0_MODULE, + .irq_id = ETS_TWAI0_INTR_SOURCE, + .tx_sig = TWAI0_TX_IDX, + .rx_sig = TWAI0_RX_IDX, + .bus_off_sig = TWAI0_BUS_OFF_ON_IDX, + .clk_out_sig = TWAI0_CLKOUT_IDX, + .stand_by_sig = TWAI0_STANDBY_IDX, + }, + [1] = { + .module = PERIPH_TWAI1_MODULE, + .irq_id = ETS_TWAI1_INTR_SOURCE, + .tx_sig = TWAI1_TX_IDX, + .rx_sig = TWAI1_RX_IDX, + .bus_off_sig = TWAI1_BUS_OFF_ON_IDX, + .clk_out_sig = TWAI1_CLKOUT_IDX, + .stand_by_sig = TWAI1_STANDBY_IDX, + } + } +}; diff --git a/components/soc/esp32s2/CMakeLists.txt b/components/soc/esp32s2/CMakeLists.txt index 5f51433981..9ca95c4cfe 100644 --- a/components/soc/esp32s2/CMakeLists.txt +++ b/components/soc/esp32s2/CMakeLists.txt @@ -15,6 +15,7 @@ set(srcs "spi_periph.c" "timer_periph.c" "touch_sensor_periph.c" + "twai_periph.c" "uart_periph.c" "usb_periph.c" "temperature_sensor_periph.c" diff --git a/components/soc/esp32s2/twai_periph.c b/components/soc/esp32s2/twai_periph.c new file mode 100644 index 0000000000..bae7c6ec5d --- /dev/null +++ b/components/soc/esp32s2/twai_periph.c @@ -0,0 +1,22 @@ +/* + * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "soc/twai_periph.h" +#include "soc/gpio_sig_map.h" + +const twai_controller_signal_conn_t twai_controller_periph_signals = { + .controllers = { + [0] = { + .module = PERIPH_TWAI_MODULE, + .irq_id = ETS_TWAI_INTR_SOURCE, + .tx_sig = TWAI_TX_IDX, + .rx_sig = TWAI_RX_IDX, + .bus_off_sig = TWAI_BUS_OFF_ON_IDX, + .clk_out_sig = TWAI_CLKOUT_IDX, + .stand_by_sig = -1, + }, + } +}; diff --git a/components/soc/esp32s3/CMakeLists.txt b/components/soc/esp32s3/CMakeLists.txt index e2d20fb00b..fcc344c301 100644 --- a/components/soc/esp32s3/CMakeLists.txt +++ b/components/soc/esp32s3/CMakeLists.txt @@ -16,9 +16,10 @@ set(srcs "sdio_slave_periph.c" "sdmmc_periph.c" "spi_periph.c" + "temperature_sensor_periph.c" "timer_periph.c" "touch_sensor_periph.c" - "temperature_sensor_periph.c" + "twai_periph.c" "uart_periph.c" "usb_periph.c" "usb_otg_periph.c") diff --git a/components/soc/esp32s3/twai_periph.c b/components/soc/esp32s3/twai_periph.c new file mode 100644 index 0000000000..bae7c6ec5d --- /dev/null +++ b/components/soc/esp32s3/twai_periph.c @@ -0,0 +1,22 @@ +/* + * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "soc/twai_periph.h" +#include "soc/gpio_sig_map.h" + +const twai_controller_signal_conn_t twai_controller_periph_signals = { + .controllers = { + [0] = { + .module = PERIPH_TWAI_MODULE, + .irq_id = ETS_TWAI_INTR_SOURCE, + .tx_sig = TWAI_TX_IDX, + .rx_sig = TWAI_RX_IDX, + .bus_off_sig = TWAI_BUS_OFF_ON_IDX, + .clk_out_sig = TWAI_CLKOUT_IDX, + .stand_by_sig = -1, + }, + } +}; diff --git a/components/soc/include/soc/twai_periph.h b/components/soc/include/soc/twai_periph.h index 48fc1d8ea8..e97eb0e064 100644 --- a/components/soc/include/soc/twai_periph.h +++ b/components/soc/include/soc/twai_periph.h @@ -1,27 +1,32 @@ -// Copyright 2019 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once -#include "sdkconfig.h" +#include +#include "soc/soc_caps.h" +#include "soc/periph_defs.h" #ifdef __cplusplus extern "C" { #endif -#include "soc/soc_caps.h" -#include "soc/twai_struct.h" +typedef struct { + struct { + const periph_module_t module; // peripheral module + const int irq_id; // interrupt source ID + const int tx_sig; // TX signal ID in GPIO matrix + const int rx_sig; // RX signal ID in GPIO matrix + const int clk_out_sig; // CLK_OUT signal ID in GPIO matrix + const int bus_off_sig; // BUS_OFF status signal ID in GPIO matrix + const int stand_by_sig; // STAND_BY signal ID in GPIO matrix + } controllers[SOC_TWAI_CONTROLLER_NUM]; +} twai_controller_signal_conn_t; + +extern const twai_controller_signal_conn_t twai_controller_periph_signals; #ifdef __cplusplus } diff --git a/tools/ci/check_copyright_ignore.txt b/tools/ci/check_copyright_ignore.txt index c7e241016e..c6c4574d2e 100644 --- a/tools/ci/check_copyright_ignore.txt +++ b/tools/ci/check_copyright_ignore.txt @@ -1177,7 +1177,6 @@ components/soc/include/soc/ledc_periph.h components/soc/include/soc/sdio_slave_periph.h components/soc/include/soc/sdmmc_periph.h components/soc/include/soc/sens_periph.h -components/soc/include/soc/twai_periph.h components/soc/include/soc/uart_periph.h components/soc/include/soc/uhci_periph.h components/soc/lldesc.c