From 8e483e34a85fc29fb318e786d163e571e54ed692 Mon Sep 17 00:00:00 2001 From: morris Date: Tue, 20 Apr 2021 14:36:34 +0800 Subject: [PATCH] rmt: restructure rmt_signal_conn_t --- components/driver/rmt.c | 12 ++--- components/hal/include/hal/rmt_types.h | 4 +- components/soc/esp32/rmt_periph.c | 70 +++++++++++++------------ components/soc/esp32c3/rmt_periph.c | 40 +++++++------- components/soc/esp32s2/rmt_periph.c | 38 ++++++++------ components/soc/esp32s3/rmt_periph.c | 70 +++++++++++++------------ components/soc/include/soc/rmt_periph.h | 14 ++--- 7 files changed, 133 insertions(+), 115 deletions(-) diff --git a/components/driver/rmt.c b/components/driver/rmt.c index 7e8b7d5ef3..66f39929eb 100644 --- a/components/driver/rmt.c +++ b/components/driver/rmt.c @@ -125,8 +125,8 @@ static void rmt_module_enable(void) { RMT_ENTER_CRITICAL(); if (rmt_contex.rmt_module_enabled == false) { - periph_module_reset(rmt_periph_signals.module); - periph_module_enable(rmt_periph_signals.module); + periph_module_reset(rmt_periph_signals.groups[0].module); + periph_module_enable(rmt_periph_signals.groups[0].module); rmt_contex.rmt_module_enabled = true; } RMT_EXIT_CRITICAL(); @@ -137,7 +137,7 @@ static void rmt_module_disable(void) { RMT_ENTER_CRITICAL(); if (rmt_contex.rmt_module_enabled == true) { - periph_module_disable(rmt_periph_signals.module); + periph_module_disable(rmt_periph_signals.groups[0].module); rmt_contex.rmt_module_enabled = false; } RMT_EXIT_CRITICAL(); @@ -533,11 +533,11 @@ esp_err_t rmt_set_gpio(rmt_channel_t channel, rmt_mode_t mode, gpio_num_t gpio_n if (mode == RMT_MODE_TX) { RMT_CHECK(RMT_IS_TX_CHANNEL(channel), RMT_CHANNEL_ERROR_STR, ESP_ERR_INVALID_ARG); gpio_set_direction(gpio_num, GPIO_MODE_OUTPUT); - esp_rom_gpio_connect_out_signal(gpio_num, rmt_periph_signals.channels[channel].tx_sig, invert_signal, 0); + esp_rom_gpio_connect_out_signal(gpio_num, rmt_periph_signals.groups[0].channels[channel].tx_sig, invert_signal, 0); } else { RMT_CHECK(RMT_IS_RX_CHANNEL(channel), RMT_CHANNEL_ERROR_STR, ESP_ERR_INVALID_ARG); gpio_set_direction(gpio_num, GPIO_MODE_INPUT); - esp_rom_gpio_connect_in_signal(gpio_num, rmt_periph_signals.channels[channel].rx_sig, invert_signal); + esp_rom_gpio_connect_in_signal(gpio_num, rmt_periph_signals.groups[0].channels[channel].rx_sig, invert_signal); } return ESP_OK; } @@ -722,7 +722,7 @@ esp_err_t rmt_isr_register(void (*fn)(void *), void *arg, int intr_alloc_flags, RMT_CHECK((fn != NULL), RMT_ADDR_ERROR_STR, ESP_ERR_INVALID_ARG); RMT_CHECK(rmt_contex.rmt_driver_channels == 0, "RMT driver installed, can not install generic ISR handler", ESP_FAIL); - return esp_intr_alloc(rmt_periph_signals.irq, intr_alloc_flags, fn, arg, handle); + return esp_intr_alloc(rmt_periph_signals.groups[0].irq, intr_alloc_flags, fn, arg, handle); } esp_err_t rmt_isr_deregister(rmt_isr_handle_t handle) diff --git a/components/hal/include/hal/rmt_types.h b/components/hal/include/hal/rmt_types.h index 28b5bf59a3..9669fd4885 100644 --- a/components/hal/include/hal/rmt_types.h +++ b/components/hal/include/hal/rmt_types.h @@ -14,12 +14,12 @@ #pragma once +#include "soc/soc_caps.h" + #ifdef __cplusplus extern "C" { #endif -#include "soc/soc_caps.h" - /** * @brief RMT channel ID * diff --git a/components/soc/esp32/rmt_periph.c b/components/soc/esp32/rmt_periph.c index 98a9c7b7ae..48d5ea0b02 100644 --- a/components/soc/esp32/rmt_periph.c +++ b/components/soc/esp32/rmt_periph.c @@ -17,40 +17,44 @@ #include "soc/soc.h" const rmt_signal_conn_t rmt_periph_signals = { - .module = PERIPH_RMT_MODULE, - .irq = ETS_RMT_INTR_SOURCE, - .channels = { + .groups = { [0] = { - .tx_sig = RMT_SIG_OUT0_IDX, - .rx_sig = RMT_SIG_IN0_IDX - }, - [1] = { - .tx_sig = RMT_SIG_OUT1_IDX, - .rx_sig = RMT_SIG_IN1_IDX - }, - [2] = { - .tx_sig = RMT_SIG_OUT2_IDX, - .rx_sig = RMT_SIG_IN2_IDX - }, - [3] = { - .tx_sig = RMT_SIG_OUT3_IDX, - .rx_sig = RMT_SIG_IN3_IDX - }, - [4] = { - .tx_sig = RMT_SIG_OUT4_IDX, - .rx_sig = RMT_SIG_IN4_IDX - }, - [5] = { - .tx_sig = RMT_SIG_OUT5_IDX, - .rx_sig = RMT_SIG_IN5_IDX - }, - [6] = { - .tx_sig = RMT_SIG_OUT6_IDX, - .rx_sig = RMT_SIG_IN6_IDX - }, - [7] = { - .tx_sig = RMT_SIG_OUT7_IDX, - .rx_sig = RMT_SIG_IN7_IDX + .module = PERIPH_RMT_MODULE, + .irq = ETS_RMT_INTR_SOURCE, + .channels = { + [0] = { + .tx_sig = RMT_SIG_OUT0_IDX, + .rx_sig = RMT_SIG_IN0_IDX + }, + [1] = { + .tx_sig = RMT_SIG_OUT1_IDX, + .rx_sig = RMT_SIG_IN1_IDX + }, + [2] = { + .tx_sig = RMT_SIG_OUT2_IDX, + .rx_sig = RMT_SIG_IN2_IDX + }, + [3] = { + .tx_sig = RMT_SIG_OUT3_IDX, + .rx_sig = RMT_SIG_IN3_IDX + }, + [4] = { + .tx_sig = RMT_SIG_OUT4_IDX, + .rx_sig = RMT_SIG_IN4_IDX + }, + [5] = { + .tx_sig = RMT_SIG_OUT5_IDX, + .rx_sig = RMT_SIG_IN5_IDX + }, + [6] = { + .tx_sig = RMT_SIG_OUT6_IDX, + .rx_sig = RMT_SIG_IN6_IDX + }, + [7] = { + .tx_sig = RMT_SIG_OUT7_IDX, + .rx_sig = RMT_SIG_IN7_IDX + } + } } } }; diff --git a/components/soc/esp32c3/rmt_periph.c b/components/soc/esp32c3/rmt_periph.c index 1556cf92f4..8405b76487 100644 --- a/components/soc/esp32c3/rmt_periph.c +++ b/components/soc/esp32c3/rmt_periph.c @@ -16,24 +16,28 @@ #include "soc/gpio_sig_map.h" const rmt_signal_conn_t rmt_periph_signals = { - .module = PERIPH_RMT_MODULE, - .irq = ETS_RMT_INTR_SOURCE, - .channels = { + .groups = { [0] = { - .tx_sig = RMT_SIG_OUT0_IDX, - .rx_sig = -1 - }, - [1] = { - .tx_sig = RMT_SIG_OUT1_IDX, - .rx_sig = -1 - }, - [2] = { - .tx_sig = -1, - .rx_sig = RMT_SIG_IN0_IDX - }, - [3] = { - .tx_sig = -1, - .rx_sig = RMT_SIG_IN1_IDX - }, + .module = PERIPH_RMT_MODULE, + .irq = ETS_RMT_INTR_SOURCE, + .channels = { + [0] = { + .tx_sig = RMT_SIG_OUT0_IDX, + .rx_sig = -1 + }, + [1] = { + .tx_sig = RMT_SIG_OUT1_IDX, + .rx_sig = -1 + }, + [2] = { + .tx_sig = -1, + .rx_sig = RMT_SIG_IN0_IDX + }, + [3] = { + .tx_sig = -1, + .rx_sig = RMT_SIG_IN1_IDX + }, + } + } } }; diff --git a/components/soc/esp32s2/rmt_periph.c b/components/soc/esp32s2/rmt_periph.c index 35bd844145..59ddb0613d 100644 --- a/components/soc/esp32s2/rmt_periph.c +++ b/components/soc/esp32s2/rmt_periph.c @@ -16,24 +16,28 @@ #include "soc/gpio_sig_map.h" const rmt_signal_conn_t rmt_periph_signals = { - .module = PERIPH_RMT_MODULE, - .irq = ETS_RMT_INTR_SOURCE, - .channels = { + .groups = { [0] = { - .tx_sig = RMT_SIG_OUT0_IDX, - .rx_sig = RMT_SIG_IN0_IDX - }, - [1] = { - .tx_sig = RMT_SIG_OUT1_IDX, - .rx_sig = RMT_SIG_IN1_IDX - }, - [2] = { - .tx_sig = RMT_SIG_OUT2_IDX, - .rx_sig = RMT_SIG_IN2_IDX - }, - [3] = { - .tx_sig = RMT_SIG_OUT3_IDX, - .rx_sig = RMT_SIG_IN3_IDX + .module = PERIPH_RMT_MODULE, + .irq = ETS_RMT_INTR_SOURCE, + .channels = { + [0] = { + .tx_sig = RMT_SIG_OUT0_IDX, + .rx_sig = RMT_SIG_IN0_IDX + }, + [1] = { + .tx_sig = RMT_SIG_OUT1_IDX, + .rx_sig = RMT_SIG_IN1_IDX + }, + [2] = { + .tx_sig = RMT_SIG_OUT2_IDX, + .rx_sig = RMT_SIG_IN2_IDX + }, + [3] = { + .tx_sig = RMT_SIG_OUT3_IDX, + .rx_sig = RMT_SIG_IN3_IDX + } + } } } }; diff --git a/components/soc/esp32s3/rmt_periph.c b/components/soc/esp32s3/rmt_periph.c index 611d6425f6..4581bd30a7 100644 --- a/components/soc/esp32s3/rmt_periph.c +++ b/components/soc/esp32s3/rmt_periph.c @@ -16,40 +16,44 @@ #include "soc/gpio_sig_map.h" const rmt_signal_conn_t rmt_periph_signals = { - .module = PERIPH_RMT_MODULE, - .irq = ETS_RMT_INTR_SOURCE, - .channels = { + .groups = { [0] = { - .tx_sig = RMT_SIG_OUT0_IDX, - .rx_sig = -1 - }, - [1] = { - .tx_sig = RMT_SIG_OUT1_IDX, - .rx_sig = -1 - }, - [2] = { - .tx_sig = RMT_SIG_OUT2_IDX, - .rx_sig = -1 - }, - [3] = { - .tx_sig = RMT_SIG_OUT3_IDX, - .rx_sig = -1 - }, - [4] = { - .tx_sig = -1, - .rx_sig = RMT_SIG_IN0_IDX - }, - [5] = { - .tx_sig = -1, - .rx_sig = RMT_SIG_IN1_IDX - }, - [6] = { - .tx_sig = -1, - .rx_sig = RMT_SIG_IN2_IDX - }, - [7] = { - .tx_sig = -1, - .rx_sig = RMT_SIG_IN3_IDX + .module = PERIPH_RMT_MODULE, + .irq = ETS_RMT_INTR_SOURCE, + .channels = { + [0] = { + .tx_sig = RMT_SIG_OUT0_IDX, + .rx_sig = -1 + }, + [1] = { + .tx_sig = RMT_SIG_OUT1_IDX, + .rx_sig = -1 + }, + [2] = { + .tx_sig = RMT_SIG_OUT2_IDX, + .rx_sig = -1 + }, + [3] = { + .tx_sig = RMT_SIG_OUT3_IDX, + .rx_sig = -1 + }, + [4] = { + .tx_sig = -1, + .rx_sig = RMT_SIG_IN0_IDX + }, + [5] = { + .tx_sig = -1, + .rx_sig = RMT_SIG_IN1_IDX + }, + [6] = { + .tx_sig = -1, + .rx_sig = RMT_SIG_IN2_IDX + }, + [7] = { + .tx_sig = -1, + .rx_sig = RMT_SIG_IN3_IDX + } + } } } }; diff --git a/components/soc/include/soc/rmt_periph.h b/components/soc/include/soc/rmt_periph.h index c051889262..0a2d8e2a9a 100644 --- a/components/soc/include/soc/rmt_periph.h +++ b/components/soc/include/soc/rmt_periph.h @@ -23,13 +23,15 @@ extern "C" { typedef struct { struct { + const int irq; + const periph_module_t module; struct { - const int tx_sig; - const int rx_sig; - }; - } channels[SOC_RMT_CHANNELS_PER_GROUP]; - const int irq; - const periph_module_t module; + struct { + const int tx_sig; + const int rx_sig; + }; + } channels[SOC_RMT_CHANNELS_PER_GROUP]; + } groups[SOC_RMT_GROUPS]; } rmt_signal_conn_t; extern const rmt_signal_conn_t rmt_periph_signals;