diff --git a/components/esp_driver_dac/test_apps/dac/main/test_dac.c b/components/esp_driver_dac/test_apps/dac/main/test_dac.c index ad41491a51..d33f135cbe 100644 --- a/components/esp_driver_dac/test_apps/dac/main/test_dac.c +++ b/components/esp_driver_dac/test_apps/dac/main/test_dac.c @@ -257,7 +257,7 @@ TEST_CASE("DAC_dma_convert_frequency_test", "[dac]") gpio_set_direction(GPIO_NUM_4, GPIO_MODE_INPUT_OUTPUT); // The DAC conversion frequency is equal to I2S bclk. esp_rom_gpio_connect_out_signal(GPIO_NUM_4, i2s_periph_signal[0].m_tx_ws_sig, 0, 0); - esp_rom_gpio_connect_in_signal(GPIO_NUM_4, pcnt_periph_signals.groups[0].units[0].channels[0].pulse_sig, 0); + esp_rom_gpio_connect_in_signal(GPIO_NUM_4, soc_pcnt_signals[0].units[0].channels[0].pulse_sig_id_matrix, 0); size_t len = 800; uint8_t data[len]; diff --git a/components/esp_driver_i2s/test_apps/i2s/main/test_i2s.c b/components/esp_driver_i2s/test_apps/i2s/main/test_i2s.c index 9c949a1d0a..98aec26314 100644 --- a/components/esp_driver_i2s/test_apps/i2s/main/test_i2s.c +++ b/components/esp_driver_i2s/test_apps/i2s/main/test_i2s.c @@ -847,7 +847,7 @@ static void i2s_test_common_sample_rate(i2s_chan_handle_t rx_chan, i2s_std_clk_c gpio_func_sel(MASTER_WS_IO, PIN_FUNC_GPIO); gpio_set_direction(MASTER_WS_IO, GPIO_MODE_INPUT_OUTPUT); esp_rom_gpio_connect_out_signal(MASTER_WS_IO, i2s_periph_signal[0].m_rx_ws_sig, 0, 0); - esp_rom_gpio_connect_in_signal(MASTER_WS_IO, pcnt_periph_signals.groups[0].units[0].channels[0].pulse_sig, 0); + esp_rom_gpio_connect_in_signal(MASTER_WS_IO, soc_pcnt_signals[0].units[0].channels[0].pulse_sig_id_matrix, 0); const uint32_t test_freq[] = { 8000, 10000, 11025, 12000, 16000, 22050, diff --git a/components/esp_driver_pcnt/src/pulse_cnt.c b/components/esp_driver_pcnt/src/pulse_cnt.c index 30a65f7dc6..0858c496bd 100644 --- a/components/esp_driver_pcnt/src/pulse_cnt.c +++ b/components/esp_driver_pcnt/src/pulse_cnt.c @@ -68,8 +68,8 @@ typedef struct pcnt_chan_t pcnt_chan_t; struct pcnt_platform_t { _lock_t mutex; // platform level mutex lock - pcnt_group_t *groups[SOC_PCNT_GROUPS]; // pcnt group pool - int group_ref_counts[SOC_PCNT_GROUPS]; // reference count used to protect group install/uninstall + pcnt_group_t *groups[SOC_PCNT_ATTR(INST_NUM)]; // pcnt group pool + int group_ref_counts[SOC_PCNT_ATTR(INST_NUM)]; // reference count used to protect group install/uninstall }; struct pcnt_group_t { @@ -77,7 +77,7 @@ struct pcnt_group_t { int intr_priority; // PCNT interrupt priority portMUX_TYPE spinlock; // to protect per-group register level concurrent access pcnt_hal_context_t hal; - pcnt_unit_t *units[SOC_PCNT_UNITS_PER_GROUP]; // array of PCNT units + pcnt_unit_t *units[SOC_PCNT_ATTR(UNITS_PER_INST)]; // array of PCNT units #if CONFIG_PM_ENABLE esp_pm_lock_handle_t pm_lock; // power management lock #endif @@ -112,7 +112,7 @@ struct pcnt_unit_t { int clear_signal_gpio_num; // which gpio clear signal input int accum_value; // accumulated count value pcnt_step_interval_t step_info; // step interval info - pcnt_chan_t *channels[SOC_PCNT_CHANNELS_PER_UNIT]; // array of PCNT channels + pcnt_chan_t *channels[SOC_PCNT_ATTR(CHANS_PER_UNIT)]; // array of PCNT channels pcnt_watch_point_t watchers[PCNT_LL_WATCH_EVENT_MAX]; // array of PCNT watchers intr_handle_t intr; // interrupt handle pcnt_unit_fsm_t fsm; // record PCNT unit's driver state @@ -145,12 +145,12 @@ static esp_err_t pcnt_register_to_group(pcnt_unit_t *unit) { pcnt_group_t *group = NULL; int unit_id = -1; - for (int i = 0; i < SOC_PCNT_GROUPS; i++) { + for (int i = 0; i < SOC_PCNT_ATTR(INST_NUM); i++) { group = pcnt_acquire_group_handle(i); ESP_RETURN_ON_FALSE(group, ESP_ERR_NO_MEM, TAG, "no mem for group (%d)", i); // loop to search free unit in the group portENTER_CRITICAL(&group->spinlock); - for (int j = 0; j < SOC_PCNT_UNITS_PER_GROUP; j++) { + for (int j = 0; j < SOC_PCNT_ATTR(UNITS_PER_INST); j++) { if (!group->units[j]) { unit_id = j; group->units[j] = unit; @@ -243,7 +243,7 @@ esp_err_t pcnt_new_unit(const pcnt_unit_config_t *config, pcnt_unit_handle_t *re } else { isr_flags |= PCNT_ALLOW_INTR_PRIORITY_MASK; } - ESP_GOTO_ON_ERROR(esp_intr_alloc_intrstatus(pcnt_periph_signals.groups[group_id].irq, isr_flags, + ESP_GOTO_ON_ERROR(esp_intr_alloc_intrstatus(soc_pcnt_signals[group_id].irq_id, isr_flags, (uint32_t)pcnt_ll_get_intr_status_reg(group->hal.dev), PCNT_LL_UNIT_WATCH_EVENT(unit_id), pcnt_default_isr, unit, &unit->intr), err, TAG, "install interrupt service failed"); @@ -311,13 +311,13 @@ esp_err_t pcnt_del_unit(pcnt_unit_handle_t unit) int group_id = group->group_id; int unit_id = unit->unit_id; - for (int i = 0; i < SOC_PCNT_CHANNELS_PER_UNIT; i++) { + for (int i = 0; i < SOC_PCNT_ATTR(CHANS_PER_UNIT); i++) { ESP_RETURN_ON_FALSE(!unit->channels[i], ESP_ERR_INVALID_STATE, TAG, "channel %d still in working", i); } #if SOC_PCNT_SUPPORT_CLEAR_SIGNAL if (unit->clear_signal_gpio_num >= 0) { - uint32_t clear_signal_idx = pcnt_periph_signals.groups[group_id].units[unit_id].clear_sig; + uint32_t clear_signal_idx = soc_pcnt_signals[group_id].units[unit_id].clear_sig_id_matrix; esp_rom_gpio_connect_in_signal(GPIO_MATRIX_CONST_ZERO_INPUT, clear_signal_idx, 0); } #endif // SOC_PCNT_SUPPORT_CLEAR_SIGNAL @@ -335,7 +335,7 @@ esp_err_t pcnt_unit_set_clear_signal(pcnt_unit_handle_t unit, const pcnt_clear_s pcnt_group_t *group = unit->group; int group_id = group->group_id; int unit_id = unit->unit_id; - uint32_t clear_signal_idx = pcnt_periph_signals.groups[group_id].units[unit_id].clear_sig; + uint32_t clear_signal_idx = soc_pcnt_signals[group_id].units[unit_id].clear_sig_id_matrix; if (config) { int io_num = config->clear_signal_gpio_num; @@ -534,7 +534,7 @@ esp_err_t pcnt_unit_register_event_callbacks(pcnt_unit_handle_t unit, const pcnt } else { isr_flags |= PCNT_ALLOW_INTR_PRIORITY_MASK; } - ESP_RETURN_ON_ERROR(esp_intr_alloc_intrstatus(pcnt_periph_signals.groups[group_id].irq, isr_flags, + ESP_RETURN_ON_ERROR(esp_intr_alloc_intrstatus(soc_pcnt_signals[group_id].irq_id, isr_flags, (uint32_t)pcnt_ll_get_intr_status_reg(group->hal.dev), PCNT_LL_UNIT_WATCH_EVENT(unit_id), pcnt_default_isr, unit, &unit->intr), TAG, "install interrupt service failed"); @@ -592,7 +592,7 @@ esp_err_t pcnt_unit_add_watch_point(pcnt_unit_handle_t unit, int watch_point) } // other threshold watch point else { - int thres_num = SOC_PCNT_THRES_POINT_PER_UNIT - 1; + int thres_num = SOC_PCNT_ATTR(THRES_POINT_PER_UNIT) - 1; switch (thres_num) { case 1: if (unit->watchers[PCNT_LL_WATCH_EVENT_THRES1].event_id == PCNT_LL_WATCH_EVENT_INVALID) { @@ -779,7 +779,7 @@ esp_err_t pcnt_new_channel(pcnt_unit_handle_t unit, const pcnt_chan_config_t *co // search for a free channel int channel_id = -1; portENTER_CRITICAL(&unit->spinlock); - for (int i = 0; i < SOC_PCNT_CHANNELS_PER_UNIT; i++) { + for (int i = 0; i < SOC_PCNT_ATTR(CHANS_PER_UNIT); i++) { if (!unit->channels[i]) { channel_id = i; unit->channels[channel_id] = channel; @@ -794,12 +794,12 @@ esp_err_t pcnt_new_channel(pcnt_unit_handle_t unit, const pcnt_chan_config_t *co gpio_func_sel(config->edge_gpio_num, PIN_FUNC_GPIO); gpio_input_enable(config->edge_gpio_num); esp_rom_gpio_connect_in_signal(config->edge_gpio_num, - pcnt_periph_signals.groups[group_id].units[unit_id].channels[channel_id].pulse_sig, + soc_pcnt_signals[group_id].units[unit_id].channels[channel_id].pulse_sig_id_matrix, config->flags.invert_edge_input); } else { // using virtual IO esp_rom_gpio_connect_in_signal(config->flags.virt_edge_io_level ? GPIO_MATRIX_CONST_ONE_INPUT : GPIO_MATRIX_CONST_ZERO_INPUT, - pcnt_periph_signals.groups[group_id].units[unit_id].channels[channel_id].pulse_sig, + soc_pcnt_signals[group_id].units[unit_id].channels[channel_id].pulse_sig_id_matrix, config->flags.invert_edge_input); } @@ -807,12 +807,12 @@ esp_err_t pcnt_new_channel(pcnt_unit_handle_t unit, const pcnt_chan_config_t *co gpio_func_sel(config->level_gpio_num, PIN_FUNC_GPIO); gpio_input_enable(config->level_gpio_num); esp_rom_gpio_connect_in_signal(config->level_gpio_num, - pcnt_periph_signals.groups[group_id].units[unit_id].channels[channel_id].control_sig, + soc_pcnt_signals[group_id].units[unit_id].channels[channel_id].ctl_sig_id_matrix, config->flags.invert_level_input); } else { // using virtual IO esp_rom_gpio_connect_in_signal(config->flags.virt_level_io_level ? GPIO_MATRIX_CONST_ONE_INPUT : GPIO_MATRIX_CONST_ZERO_INPUT, - pcnt_periph_signals.groups[group_id].units[unit_id].channels[channel_id].control_sig, + soc_pcnt_signals[group_id].units[unit_id].channels[channel_id].ctl_sig_id_matrix, config->flags.invert_level_input); } @@ -846,12 +846,12 @@ esp_err_t pcnt_del_channel(pcnt_channel_handle_t chan) if (chan->level_gpio_num >= 0) { esp_rom_gpio_connect_in_signal(GPIO_MATRIX_CONST_ONE_INPUT, - pcnt_periph_signals.groups[group_id].units[unit_id].channels[channel_id].control_sig, + soc_pcnt_signals[group_id].units[unit_id].channels[channel_id].ctl_sig_id_matrix, 0); } if (chan->edge_gpio_num >= 0) { esp_rom_gpio_connect_in_signal(GPIO_MATRIX_CONST_ONE_INPUT, - pcnt_periph_signals.groups[group_id].units[unit_id].channels[channel_id].pulse_sig, + soc_pcnt_signals[group_id].units[unit_id].channels[channel_id].pulse_sig_id_matrix, 0); } diff --git a/components/esp_driver_pcnt/test_apps/pulse_cnt/main/test_pulse_cnt.c b/components/esp_driver_pcnt/test_apps/pulse_cnt/main/test_pulse_cnt.c index fdf5477afc..057405fbd6 100644 --- a/components/esp_driver_pcnt/test_apps/pulse_cnt/main/test_pulse_cnt.c +++ b/components/esp_driver_pcnt/test_apps/pulse_cnt/main/test_pulse_cnt.c @@ -9,12 +9,13 @@ #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "unity.h" +#include "soc/soc_caps.h" +#include "soc/pcnt_periph.h" +#include "hal/pcnt_ll.h" #include "driver/pulse_cnt.h" #include "driver/gpio.h" -#include "soc/soc_caps.h" #include "esp_attr.h" #include "test_pulse_cnt_board.h" -#include "hal/pcnt_ll.h" TEST_CASE("pcnt_unit_install_uninstall", "[pcnt]") { @@ -23,11 +24,11 @@ TEST_CASE("pcnt_unit_install_uninstall", "[pcnt]") .high_limit = 100, .intr_priority = 0, }; - pcnt_unit_handle_t units[SOC_PCNT_UNITS_PER_GROUP]; + pcnt_unit_handle_t units[SOC_PCNT_ATTR(UNITS_PER_INST)]; int count_value = 0; printf("install pcnt units and check initial count\r\n"); - for (int i = 0; i < SOC_PCNT_UNITS_PER_GROUP - 1; i++) { + for (int i = 0; i < SOC_PCNT_ATTR(UNITS_PER_INST) - 1; i++) { TEST_ESP_OK(pcnt_new_unit(&unit_config, &units[i])); TEST_ESP_OK(pcnt_unit_get_count(units[i], &count_value)); TEST_ASSERT_EQUAL(0, count_value); @@ -35,9 +36,9 @@ TEST_CASE("pcnt_unit_install_uninstall", "[pcnt]") // unit with a different interrupt priority unit_config.intr_priority = 3; - TEST_ESP_ERR(ESP_ERR_INVALID_STATE, pcnt_new_unit(&unit_config, &units[SOC_PCNT_UNITS_PER_GROUP - 1])); + TEST_ESP_ERR(ESP_ERR_INVALID_STATE, pcnt_new_unit(&unit_config, &units[SOC_PCNT_ATTR(UNITS_PER_INST) - 1])); unit_config.intr_priority = 0; - TEST_ESP_OK(pcnt_new_unit(&unit_config, &units[SOC_PCNT_UNITS_PER_GROUP - 1])); + TEST_ESP_OK(pcnt_new_unit(&unit_config, &units[SOC_PCNT_ATTR(UNITS_PER_INST) - 1])); // no more free pcnt units TEST_ASSERT_EQUAL(ESP_ERR_NOT_FOUND, pcnt_new_unit(&unit_config, &units[0])); @@ -46,7 +47,7 @@ TEST_CASE("pcnt_unit_install_uninstall", "[pcnt]") pcnt_glitch_filter_config_t filter_config = { .max_glitch_ns = 1000, }; - for (int i = 0; i < SOC_PCNT_UNITS_PER_GROUP; i++) { + for (int i = 0; i < SOC_PCNT_ATTR(UNITS_PER_INST); i++) { TEST_ESP_OK(pcnt_unit_set_glitch_filter(units[i], &filter_config)); } // invalid glitch configuration @@ -56,30 +57,30 @@ TEST_CASE("pcnt_unit_install_uninstall", "[pcnt]") .on_reach = NULL, }; printf("enable pcnt units\r\n"); - for (int i = 0; i < SOC_PCNT_UNITS_PER_GROUP; i++) { + for (int i = 0; i < SOC_PCNT_ATTR(UNITS_PER_INST); i++) { TEST_ESP_OK(pcnt_unit_register_event_callbacks(units[i], &cbs, NULL)); TEST_ESP_OK(pcnt_unit_enable(units[i])); } printf("start pcnt units\r\n"); - for (int i = 0; i < SOC_PCNT_UNITS_PER_GROUP; i++) { + for (int i = 0; i < SOC_PCNT_ATTR(UNITS_PER_INST); i++) { TEST_ESP_OK(pcnt_unit_start(units[i])); } printf("stop pcnt units\r\n"); - for (int i = 0; i < SOC_PCNT_UNITS_PER_GROUP; i++) { + for (int i = 0; i < SOC_PCNT_ATTR(UNITS_PER_INST); i++) { TEST_ESP_OK(pcnt_unit_stop(units[i])); } // can't uninstall unit before disable it TEST_ASSERT_EQUAL(ESP_ERR_INVALID_STATE, pcnt_del_unit(units[0])); printf("disable pcnt units\r\n"); - for (int i = 0; i < SOC_PCNT_UNITS_PER_GROUP; i++) { + for (int i = 0; i < SOC_PCNT_ATTR(UNITS_PER_INST); i++) { TEST_ESP_OK(pcnt_unit_disable(units[i])); } printf("uninstall pcnt units\r\n"); - for (int i = 0; i < SOC_PCNT_UNITS_PER_GROUP; i++) { + for (int i = 0; i < SOC_PCNT_ATTR(UNITS_PER_INST); i++) { TEST_ESP_OK(pcnt_del_unit(units[i])); } } @@ -96,17 +97,17 @@ TEST_CASE("pcnt_channel_install_uninstall", "[pcnt]") .edge_gpio_num = TEST_PCNT_GPIO_A, // only detect edge signal in this case .level_gpio_num = -1, }; - pcnt_unit_handle_t units[SOC_PCNT_UNITS_PER_GROUP]; - pcnt_channel_handle_t chans[SOC_PCNT_UNITS_PER_GROUP][SOC_PCNT_CHANNELS_PER_UNIT]; + pcnt_unit_handle_t units[SOC_PCNT_ATTR(UNITS_PER_INST)]; + pcnt_channel_handle_t chans[SOC_PCNT_ATTR(UNITS_PER_INST)][SOC_PCNT_ATTR(CHANS_PER_UNIT)]; printf("install pcnt units\r\n"); - for (int i = 0; i < SOC_PCNT_UNITS_PER_GROUP; i++) { + for (int i = 0; i < SOC_PCNT_ATTR(UNITS_PER_INST); i++) { TEST_ESP_OK(pcnt_new_unit(&unit_config, &units[i])); } printf("install pcnt channels\r\n"); - for (int i = 0; i < SOC_PCNT_UNITS_PER_GROUP; i++) { - for (int j = 0; j < SOC_PCNT_CHANNELS_PER_UNIT; j++) { + for (int i = 0; i < SOC_PCNT_ATTR(UNITS_PER_INST); i++) { + for (int j = 0; j < SOC_PCNT_ATTR(CHANS_PER_UNIT); j++) { TEST_ESP_OK(pcnt_new_channel(units[i], &chan_config, &chans[i][j])); TEST_ESP_OK(pcnt_channel_set_edge_action(chans[i][j], PCNT_CHANNEL_EDGE_ACTION_INCREASE, PCNT_CHANNEL_EDGE_ACTION_HOLD)); TEST_ESP_OK(pcnt_channel_set_level_action(chans[i][j], PCNT_CHANNEL_LEVEL_ACTION_KEEP, PCNT_CHANNEL_LEVEL_ACTION_KEEP)); @@ -117,55 +118,55 @@ TEST_CASE("pcnt_channel_install_uninstall", "[pcnt]") printf("start units\r\n"); int count_value = 0; - for (int i = 0; i < SOC_PCNT_UNITS_PER_GROUP; i++) { + for (int i = 0; i < SOC_PCNT_ATTR(UNITS_PER_INST); i++) { // start unit TEST_ESP_OK(pcnt_unit_start(units[i])); // trigger 10 rising edge on GPIO0 test_gpio_simulate_rising_edge(TEST_PCNT_GPIO_A, 10); TEST_ESP_OK(pcnt_unit_get_count(units[i], &count_value)); // each channel increases to the same unit counter - TEST_ASSERT_EQUAL(10 * SOC_PCNT_CHANNELS_PER_UNIT, count_value); + TEST_ASSERT_EQUAL(10 * SOC_PCNT_ATTR(CHANS_PER_UNIT), count_value); } printf("clear counts\r\n"); - for (int i = 0; i < SOC_PCNT_UNITS_PER_GROUP; i++) { + for (int i = 0; i < SOC_PCNT_ATTR(UNITS_PER_INST); i++) { TEST_ESP_OK(pcnt_unit_clear_count(units[i])); TEST_ESP_OK(pcnt_unit_get_count(units[i], &count_value)); TEST_ASSERT_EQUAL(0, count_value); } printf("stop unit\r\n"); - for (int i = 0; i < SOC_PCNT_UNITS_PER_GROUP; i++) { + for (int i = 0; i < SOC_PCNT_ATTR(UNITS_PER_INST); i++) { // stop unit TEST_ESP_OK(pcnt_unit_stop(units[i])); } // trigger 10 rising edge on GPIO0 shouldn't increase the counter test_gpio_simulate_rising_edge(TEST_PCNT_GPIO_A, 10); - for (int i = 0; i < SOC_PCNT_UNITS_PER_GROUP; i++) { + for (int i = 0; i < SOC_PCNT_ATTR(UNITS_PER_INST); i++) { TEST_ESP_OK(pcnt_unit_get_count(units[i], &count_value)); TEST_ASSERT_EQUAL(0, count_value); } printf("restart units\r\n"); - for (int i = 0; i < SOC_PCNT_UNITS_PER_GROUP; i++) { + for (int i = 0; i < SOC_PCNT_ATTR(UNITS_PER_INST); i++) { // start unit TEST_ESP_OK(pcnt_unit_start(units[i])); // trigger 10 rising edge on GPIO test_gpio_simulate_rising_edge(TEST_PCNT_GPIO_A, 10); TEST_ESP_OK(pcnt_unit_get_count(units[i], &count_value)); // each channel increases to the same unit counter - TEST_ASSERT_EQUAL(10 * SOC_PCNT_CHANNELS_PER_UNIT, count_value); + TEST_ASSERT_EQUAL(10 * SOC_PCNT_ATTR(CHANS_PER_UNIT), count_value); } printf("uninstall channels and units\r\n"); - for (int i = 0; i < SOC_PCNT_UNITS_PER_GROUP; i++) { + for (int i = 0; i < SOC_PCNT_ATTR(UNITS_PER_INST); i++) { // stop unit TEST_ESP_OK(pcnt_unit_stop(units[i])); TEST_ESP_OK(pcnt_unit_disable(units[i])); // can't uninstall unit when channel is still alive TEST_ASSERT_EQUAL(ESP_ERR_INVALID_STATE, pcnt_del_unit(units[i])); - for (int j = 0; j < SOC_PCNT_CHANNELS_PER_UNIT; j++) { + for (int j = 0; j < SOC_PCNT_ATTR(CHANS_PER_UNIT); j++) { TEST_ESP_OK(pcnt_del_channel(chans[i][j])); } TEST_ESP_OK(pcnt_del_unit(units[i])); diff --git a/components/soc/esp32/include/soc/Kconfig.soc_caps.in b/components/soc/esp32/include/soc/Kconfig.soc_caps.in index 095b85a197..36bda8aacc 100644 --- a/components/soc/esp32/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32/include/soc/Kconfig.soc_caps.in @@ -559,22 +559,6 @@ config SOC_MPU_REGION_WO_SUPPORTED bool default n -config SOC_PCNT_GROUPS - int - default 1 - -config SOC_PCNT_UNITS_PER_GROUP - int - default 8 - -config SOC_PCNT_CHANNELS_PER_UNIT - int - default 2 - -config SOC_PCNT_THRES_POINT_PER_UNIT - int - default 2 - config SOC_RMT_GROUPS int default 1 diff --git a/components/soc/esp32/include/soc/soc_caps.h b/components/soc/esp32/include/soc/soc_caps.h index e88c4c984f..8a22bebce8 100644 --- a/components/soc/esp32/include/soc/soc_caps.h +++ b/components/soc/esp32/include/soc/soc_caps.h @@ -275,12 +275,6 @@ #define SOC_MPU_REGION_RO_SUPPORTED 0 #define SOC_MPU_REGION_WO_SUPPORTED 0 -/*-------------------------- PCNT CAPS ---------------------------------------*/ -#define SOC_PCNT_GROUPS (1U) -#define SOC_PCNT_UNITS_PER_GROUP (8) -#define SOC_PCNT_CHANNELS_PER_UNIT (2) -#define SOC_PCNT_THRES_POINT_PER_UNIT (2) - /*-------------------------- RMT CAPS ----------------------------------------*/ #define SOC_RMT_GROUPS 1U /*!< One RMT group */ #define SOC_RMT_TX_CANDIDATES_PER_GROUP 8 /*!< Number of channels that capable of Transmit in each group */ diff --git a/components/soc/esp32/include/soc/soc_caps_full.h b/components/soc/esp32/include/soc/soc_caps_full.h index acf38bfcb4..5ae5119a7f 100644 --- a/components/soc/esp32/include/soc/soc_caps_full.h +++ b/components/soc/esp32/include/soc/soc_caps_full.h @@ -23,3 +23,9 @@ /*--------------------------- SDM (Sigma-Delta Modulator) ------------------------*/ #define _SOC_CAPS_SDM_INST_NUM 1 // Number of SDM instances #define _SOC_CAPS_SDM_CHANS_PER_INST 8 // Number of channels in each SDM instance + +/*--------------------------- PCNT (Pulse Counter) ------------------------*/ +#define _SOC_CAPS_PCNT_INST_NUM 1 // Number of PCNT instances +#define _SOC_CAPS_PCNT_UNITS_PER_INST 8 // Number of units in each PCNT instance +#define _SOC_CAPS_PCNT_CHANS_PER_UNIT 2 // Number of channels in each PCNT unit +#define _SOC_CAPS_PCNT_THRES_POINT_PER_UNIT 2 // Number of threshold points in each PCNT unit diff --git a/components/soc/esp32/pcnt_periph.c b/components/soc/esp32/pcnt_periph.c index 9fbdce0113..0190bd06b2 100644 --- a/components/soc/esp32/pcnt_periph.c +++ b/components/soc/esp32/pcnt_periph.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -8,106 +8,104 @@ #include "soc/gpio_sig_map.h" #include "soc/soc.h" -const pcnt_signal_conn_t pcnt_periph_signals = { - .groups = { - [0] = { - .irq = ETS_PCNT_INTR_SOURCE, - .module_name = "pcnt0", - .units = { - [0] = { - .channels = { - [0] = { - .control_sig = PCNT_CTRL_CH0_IN0_IDX, - .pulse_sig = PCNT_SIG_CH0_IN0_IDX - }, - [1] = { - .control_sig = PCNT_CTRL_CH1_IN0_IDX, - .pulse_sig = PCNT_SIG_CH1_IN0_IDX - } +const soc_pcnt_signal_desc_t soc_pcnt_signals[1] = { + [0] = { + .irq_id = ETS_PCNT_INTR_SOURCE, + .module_name = "pcnt0", + .units = { + [0] = { + .channels = { + [0] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH0_IN0_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH0_IN0_IDX + }, + [1] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH1_IN0_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH1_IN0_IDX } - }, - [1] = { - .channels = { - [0] = { - .control_sig = PCNT_CTRL_CH0_IN1_IDX, - .pulse_sig = PCNT_SIG_CH0_IN1_IDX - }, - [1] = { - .control_sig = PCNT_CTRL_CH1_IN1_IDX, - .pulse_sig = PCNT_SIG_CH1_IN1_IDX - } + } + }, + [1] = { + .channels = { + [0] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH0_IN1_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH0_IN1_IDX + }, + [1] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH1_IN1_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH1_IN1_IDX } - }, - [2] = { - .channels = { - [0] = { - .control_sig = PCNT_CTRL_CH0_IN2_IDX, - .pulse_sig = PCNT_SIG_CH0_IN2_IDX - }, - [1] = { - .control_sig = PCNT_CTRL_CH1_IN2_IDX, - .pulse_sig = PCNT_SIG_CH1_IN2_IDX - } + } + }, + [2] = { + .channels = { + [0] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH0_IN2_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH0_IN2_IDX + }, + [1] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH1_IN2_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH1_IN2_IDX } - }, - [3] = { - .channels = { - [0] = { - .control_sig = PCNT_CTRL_CH0_IN3_IDX, - .pulse_sig = PCNT_SIG_CH0_IN3_IDX - }, - [1] = { - .control_sig = PCNT_CTRL_CH1_IN3_IDX, - .pulse_sig = PCNT_SIG_CH1_IN3_IDX - } + } + }, + [3] = { + .channels = { + [0] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH0_IN3_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH0_IN3_IDX + }, + [1] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH1_IN3_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH1_IN3_IDX } - }, - [4] = { - .channels = { - [0] = { - .control_sig = PCNT_CTRL_CH0_IN4_IDX, - .pulse_sig = PCNT_SIG_CH0_IN4_IDX - }, - [1] = { - .control_sig = PCNT_CTRL_CH1_IN4_IDX, - .pulse_sig = PCNT_SIG_CH1_IN4_IDX - } + } + }, + [4] = { + .channels = { + [0] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH0_IN4_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH0_IN4_IDX + }, + [1] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH1_IN4_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH1_IN4_IDX } - }, - [5] = { - .channels = { - [0] = { - .control_sig = PCNT_CTRL_CH0_IN5_IDX, - .pulse_sig = PCNT_SIG_CH0_IN5_IDX - }, - [1] = { - .control_sig = PCNT_CTRL_CH1_IN5_IDX, - .pulse_sig = PCNT_SIG_CH1_IN5_IDX - } + } + }, + [5] = { + .channels = { + [0] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH0_IN5_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH0_IN5_IDX + }, + [1] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH1_IN5_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH1_IN5_IDX } - }, - [6] = { - .channels = { - [0] = { - .control_sig = PCNT_CTRL_CH0_IN6_IDX, - .pulse_sig = PCNT_SIG_CH0_IN6_IDX - }, - [1] = { - .control_sig = PCNT_CTRL_CH1_IN6_IDX, - .pulse_sig = PCNT_SIG_CH1_IN6_IDX - } + } + }, + [6] = { + .channels = { + [0] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH0_IN6_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH0_IN6_IDX + }, + [1] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH1_IN6_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH1_IN6_IDX } - }, - [7] = { - .channels = { - [0] = { - .control_sig = PCNT_CTRL_CH0_IN7_IDX, - .pulse_sig = PCNT_SIG_CH0_IN7_IDX - }, - [1] = { - .control_sig = PCNT_CTRL_CH1_IN7_IDX, - .pulse_sig = PCNT_SIG_CH1_IN7_IDX - } + } + }, + [7] = { + .channels = { + [0] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH0_IN7_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH0_IN7_IDX + }, + [1] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH1_IN7_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH1_IN7_IDX } } } diff --git a/components/soc/esp32c5/include/soc/Kconfig.soc_caps.in b/components/soc/esp32c5/include/soc/Kconfig.soc_caps.in index b35f6352e0..8dfb2e7e3a 100644 --- a/components/soc/esp32c5/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32c5/include/soc/Kconfig.soc_caps.in @@ -839,22 +839,6 @@ config SOC_MMU_DI_VADDR_SHARED bool default y -config SOC_PCNT_GROUPS - int - default 1 - -config SOC_PCNT_UNITS_PER_GROUP - int - default 4 - -config SOC_PCNT_CHANNELS_PER_UNIT - int - default 2 - -config SOC_PCNT_THRES_POINT_PER_UNIT - int - default 2 - config SOC_PCNT_SUPPORT_RUNTIME_THRES_UPDATE bool default y diff --git a/components/soc/esp32c5/include/soc/soc_caps.h b/components/soc/esp32c5/include/soc/soc_caps.h index 35dbe9cdc6..4c3b57edf9 100644 --- a/components/soc/esp32c5/include/soc/soc_caps.h +++ b/components/soc/esp32c5/include/soc/soc_caps.h @@ -339,10 +339,6 @@ // #define SOC_MPU_REGION_WO_SUPPORTED 0 /*-------------------------- PCNT CAPS ---------------------------------------*/ -#define SOC_PCNT_GROUPS 1U -#define SOC_PCNT_UNITS_PER_GROUP 4 -#define SOC_PCNT_CHANNELS_PER_UNIT 2 -#define SOC_PCNT_THRES_POINT_PER_UNIT 2 #define SOC_PCNT_SUPPORT_RUNTIME_THRES_UPDATE 1 #define SOC_PCNT_SUPPORT_CLEAR_SIGNAL 1 #define SOC_PCNT_SUPPORT_STEP_NOTIFY 1 diff --git a/components/soc/esp32c5/include/soc/soc_caps_full.h b/components/soc/esp32c5/include/soc/soc_caps_full.h index d9ce210e7d..95748b6bc6 100644 --- a/components/soc/esp32c5/include/soc/soc_caps_full.h +++ b/components/soc/esp32c5/include/soc/soc_caps_full.h @@ -24,6 +24,12 @@ #define _SOC_CAPS_SDM_INST_NUM 1 // Number of SDM instances #define _SOC_CAPS_SDM_CHANS_PER_INST 4 // Number of channels in each SDM instance +/*--------------------------- PCNT (Pulse Counter) ------------------------*/ +#define _SOC_CAPS_PCNT_INST_NUM 1 // Number of PCNT instances +#define _SOC_CAPS_PCNT_UNITS_PER_INST 4 // Number of units in each PCNT instance +#define _SOC_CAPS_PCNT_CHANS_PER_UNIT 2 // Number of channels in each PCNT unit +#define _SOC_CAPS_PCNT_THRES_POINT_PER_UNIT 2 // Number of threshold points in each PCNT unit + /*--------------------------- ETM (Event Task Matrix) ----------------------------*/ #define _SOC_CAPS_ETM_INST_NUM 1 // Number of ETM instances #define _SOC_CAPS_ETM_CHANS_PER_INST 50 // Number of channels in each ETM instance diff --git a/components/soc/esp32c5/pcnt_periph.c b/components/soc/esp32c5/pcnt_periph.c index 56767409ef..641341582d 100644 --- a/components/soc/esp32c5/pcnt_periph.c +++ b/components/soc/esp32c5/pcnt_periph.c @@ -8,64 +8,62 @@ #include "soc/gpio_sig_map.h" #include "soc/pcnt_reg.h" -const pcnt_signal_conn_t pcnt_periph_signals = { - .groups = { - [0] = { - .irq = ETS_PCNT_INTR_SOURCE, - .module_name = "pcnt0", - .units = { - [0] = { - .channels = { - [0] = { - .control_sig = PCNT_CTRL_CH0_IN0_IDX, - .pulse_sig = PCNT_SIG_CH0_IN0_IDX - }, - [1] = { - .control_sig = PCNT_CTRL_CH1_IN0_IDX, - .pulse_sig = PCNT_SIG_CH1_IN0_IDX - } +const soc_pcnt_signal_desc_t soc_pcnt_signals[1] = { + [0] = { + .irq_id = ETS_PCNT_INTR_SOURCE, + .module_name = "pcnt0", + .units = { + [0] = { + .channels = { + [0] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH0_IN0_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH0_IN0_IDX }, - .clear_sig = PCNT_RST_IN0_IDX + [1] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH1_IN0_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH1_IN0_IDX + } }, - [1] = { - .channels = { - [0] = { - .control_sig = PCNT_CTRL_CH0_IN1_IDX, - .pulse_sig = PCNT_SIG_CH0_IN1_IDX, - }, - [1] = { - .control_sig = PCNT_CTRL_CH1_IN1_IDX, - .pulse_sig = PCNT_SIG_CH1_IN1_IDX - } + .clear_sig_id_matrix = PCNT_RST_IN0_IDX + }, + [1] = { + .channels = { + [0] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH0_IN1_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH0_IN1_IDX, }, - .clear_sig = PCNT_RST_IN1_IDX + [1] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH1_IN1_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH1_IN1_IDX + } }, - [2] = { - .channels = { - [0] = { - .control_sig = PCNT_CTRL_CH0_IN2_IDX, - .pulse_sig = PCNT_SIG_CH0_IN2_IDX, - }, - [1] = { - .control_sig = PCNT_CTRL_CH1_IN2_IDX, - .pulse_sig = PCNT_SIG_CH1_IN2_IDX - } + .clear_sig_id_matrix = PCNT_RST_IN1_IDX + }, + [2] = { + .channels = { + [0] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH0_IN2_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH0_IN2_IDX, }, - .clear_sig = PCNT_RST_IN2_IDX + [1] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH1_IN2_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH1_IN2_IDX + } }, - [3] = { - .channels = { - [0] = { - .control_sig = PCNT_CTRL_CH0_IN3_IDX, - .pulse_sig = PCNT_SIG_CH0_IN3_IDX, - }, - [1] = { - .control_sig = PCNT_CTRL_CH1_IN3_IDX, - .pulse_sig = PCNT_SIG_CH1_IN3_IDX - } + .clear_sig_id_matrix = PCNT_RST_IN2_IDX + }, + [3] = { + .channels = { + [0] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH0_IN3_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH0_IN3_IDX, }, - .clear_sig = PCNT_RST_IN3_IDX - } + [1] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH1_IN3_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH1_IN3_IDX + } + }, + .clear_sig_id_matrix = PCNT_RST_IN3_IDX } } } diff --git a/components/soc/esp32c6/include/soc/Kconfig.soc_caps.in b/components/soc/esp32c6/include/soc/Kconfig.soc_caps.in index fe2e6264f5..324b173594 100644 --- a/components/soc/esp32c6/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32c6/include/soc/Kconfig.soc_caps.in @@ -783,22 +783,6 @@ config SOC_MPU_REGION_WO_SUPPORTED bool default n -config SOC_PCNT_GROUPS - int - default 1 - -config SOC_PCNT_UNITS_PER_GROUP - int - default 4 - -config SOC_PCNT_CHANNELS_PER_UNIT - int - default 2 - -config SOC_PCNT_THRES_POINT_PER_UNIT - int - default 2 - config SOC_PCNT_SUPPORT_RUNTIME_THRES_UPDATE bool default y diff --git a/components/soc/esp32c6/include/soc/soc_caps.h b/components/soc/esp32c6/include/soc/soc_caps.h index 2906c6a1c7..b9f94b5022 100644 --- a/components/soc/esp32c6/include/soc/soc_caps.h +++ b/components/soc/esp32c6/include/soc/soc_caps.h @@ -315,10 +315,6 @@ #define SOC_MPU_REGION_WO_SUPPORTED 0 /*-------------------------- PCNT CAPS ---------------------------------------*/ -#define SOC_PCNT_GROUPS 1U -#define SOC_PCNT_UNITS_PER_GROUP 4 -#define SOC_PCNT_CHANNELS_PER_UNIT 2 -#define SOC_PCNT_THRES_POINT_PER_UNIT 2 #define SOC_PCNT_SUPPORT_RUNTIME_THRES_UPDATE 1 /*--------------------------- RMT CAPS ---------------------------------------*/ diff --git a/components/soc/esp32c6/include/soc/soc_caps_full.h b/components/soc/esp32c6/include/soc/soc_caps_full.h index d9ce210e7d..95748b6bc6 100644 --- a/components/soc/esp32c6/include/soc/soc_caps_full.h +++ b/components/soc/esp32c6/include/soc/soc_caps_full.h @@ -24,6 +24,12 @@ #define _SOC_CAPS_SDM_INST_NUM 1 // Number of SDM instances #define _SOC_CAPS_SDM_CHANS_PER_INST 4 // Number of channels in each SDM instance +/*--------------------------- PCNT (Pulse Counter) ------------------------*/ +#define _SOC_CAPS_PCNT_INST_NUM 1 // Number of PCNT instances +#define _SOC_CAPS_PCNT_UNITS_PER_INST 4 // Number of units in each PCNT instance +#define _SOC_CAPS_PCNT_CHANS_PER_UNIT 2 // Number of channels in each PCNT unit +#define _SOC_CAPS_PCNT_THRES_POINT_PER_UNIT 2 // Number of threshold points in each PCNT unit + /*--------------------------- ETM (Event Task Matrix) ----------------------------*/ #define _SOC_CAPS_ETM_INST_NUM 1 // Number of ETM instances #define _SOC_CAPS_ETM_CHANS_PER_INST 50 // Number of channels in each ETM instance diff --git a/components/soc/esp32c6/pcnt_periph.c b/components/soc/esp32c6/pcnt_periph.c index 920a5001a9..490f2ed821 100644 --- a/components/soc/esp32c6/pcnt_periph.c +++ b/components/soc/esp32c6/pcnt_periph.c @@ -8,58 +8,56 @@ #include "soc/gpio_sig_map.h" #include "soc/pcnt_reg.h" -const pcnt_signal_conn_t pcnt_periph_signals = { - .groups = { - [0] = { - .irq = ETS_PCNT_INTR_SOURCE, - .module_name = "pcnt0", - .units = { - [0] = { - .channels = { - [0] = { - .control_sig = PCNT_CTRL_CH0_IN0_IDX, - .pulse_sig = PCNT_SIG_CH0_IN0_IDX - }, - [1] = { - .control_sig = PCNT_CTRL_CH1_IN0_IDX, - .pulse_sig = PCNT_SIG_CH1_IN0_IDX - } +const soc_pcnt_signal_desc_t soc_pcnt_signals[1] = { + [0] = { + .irq_id = ETS_PCNT_INTR_SOURCE, + .module_name = "pcnt0", + .units = { + [0] = { + .channels = { + [0] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH0_IN0_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH0_IN0_IDX + }, + [1] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH1_IN0_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH1_IN0_IDX } - }, - [1] = { - .channels = { - [0] = { - .control_sig = PCNT_CTRL_CH0_IN1_IDX, - .pulse_sig = PCNT_SIG_CH0_IN1_IDX - }, - [1] = { - .control_sig = PCNT_CTRL_CH1_IN1_IDX, - .pulse_sig = PCNT_SIG_CH1_IN1_IDX - } + } + }, + [1] = { + .channels = { + [0] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH0_IN1_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH0_IN1_IDX + }, + [1] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH1_IN1_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH1_IN1_IDX } - }, - [2] = { - .channels = { - [0] = { - .control_sig = PCNT_CTRL_CH0_IN2_IDX, - .pulse_sig = PCNT_SIG_CH0_IN2_IDX - }, - [1] = { - .control_sig = PCNT_CTRL_CH1_IN2_IDX, - .pulse_sig = PCNT_SIG_CH1_IN2_IDX - } + } + }, + [2] = { + .channels = { + [0] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH0_IN2_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH0_IN2_IDX + }, + [1] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH1_IN2_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH1_IN2_IDX } - }, - [3] = { - .channels = { - [0] = { - .control_sig = PCNT_CTRL_CH0_IN3_IDX, - .pulse_sig = PCNT_SIG_CH0_IN3_IDX - }, - [1] = { - .control_sig = PCNT_CTRL_CH1_IN3_IDX, - .pulse_sig = PCNT_SIG_CH1_IN3_IDX - } + } + }, + [3] = { + .channels = { + [0] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH0_IN3_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH0_IN3_IDX + }, + [1] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH1_IN3_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH1_IN3_IDX } } } diff --git a/components/soc/esp32h2/include/soc/Kconfig.soc_caps.in b/components/soc/esp32h2/include/soc/Kconfig.soc_caps.in index 0db2579197..af9e2b89d6 100644 --- a/components/soc/esp32h2/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32h2/include/soc/Kconfig.soc_caps.in @@ -775,22 +775,6 @@ config SOC_MPU_REGION_WO_SUPPORTED bool default n -config SOC_PCNT_GROUPS - int - default 1 - -config SOC_PCNT_UNITS_PER_GROUP - int - default 4 - -config SOC_PCNT_CHANNELS_PER_UNIT - int - default 2 - -config SOC_PCNT_THRES_POINT_PER_UNIT - int - default 2 - config SOC_PCNT_SUPPORT_RUNTIME_THRES_UPDATE bool default y diff --git a/components/soc/esp32h2/include/soc/soc_caps.h b/components/soc/esp32h2/include/soc/soc_caps.h index feeb153f2c..5505ecc227 100644 --- a/components/soc/esp32h2/include/soc/soc_caps.h +++ b/components/soc/esp32h2/include/soc/soc_caps.h @@ -328,10 +328,6 @@ #define SOC_MPU_REGION_WO_SUPPORTED 0 /*-------------------------- PCNT CAPS ---------------------------------------*/ -#define SOC_PCNT_GROUPS 1U -#define SOC_PCNT_UNITS_PER_GROUP 4 -#define SOC_PCNT_CHANNELS_PER_UNIT 2 -#define SOC_PCNT_THRES_POINT_PER_UNIT 2 #define SOC_PCNT_SUPPORT_RUNTIME_THRES_UPDATE 1 #define SOC_PCNT_SUPPORT_STEP_NOTIFY 1 /*!< Only avliable in chip version above 1.2*/ diff --git a/components/soc/esp32h2/include/soc/soc_caps_full.h b/components/soc/esp32h2/include/soc/soc_caps_full.h index d9ce210e7d..95748b6bc6 100644 --- a/components/soc/esp32h2/include/soc/soc_caps_full.h +++ b/components/soc/esp32h2/include/soc/soc_caps_full.h @@ -24,6 +24,12 @@ #define _SOC_CAPS_SDM_INST_NUM 1 // Number of SDM instances #define _SOC_CAPS_SDM_CHANS_PER_INST 4 // Number of channels in each SDM instance +/*--------------------------- PCNT (Pulse Counter) ------------------------*/ +#define _SOC_CAPS_PCNT_INST_NUM 1 // Number of PCNT instances +#define _SOC_CAPS_PCNT_UNITS_PER_INST 4 // Number of units in each PCNT instance +#define _SOC_CAPS_PCNT_CHANS_PER_UNIT 2 // Number of channels in each PCNT unit +#define _SOC_CAPS_PCNT_THRES_POINT_PER_UNIT 2 // Number of threshold points in each PCNT unit + /*--------------------------- ETM (Event Task Matrix) ----------------------------*/ #define _SOC_CAPS_ETM_INST_NUM 1 // Number of ETM instances #define _SOC_CAPS_ETM_CHANS_PER_INST 50 // Number of channels in each ETM instance diff --git a/components/soc/esp32h2/pcnt_periph.c b/components/soc/esp32h2/pcnt_periph.c index 920a5001a9..490f2ed821 100644 --- a/components/soc/esp32h2/pcnt_periph.c +++ b/components/soc/esp32h2/pcnt_periph.c @@ -8,58 +8,56 @@ #include "soc/gpio_sig_map.h" #include "soc/pcnt_reg.h" -const pcnt_signal_conn_t pcnt_periph_signals = { - .groups = { - [0] = { - .irq = ETS_PCNT_INTR_SOURCE, - .module_name = "pcnt0", - .units = { - [0] = { - .channels = { - [0] = { - .control_sig = PCNT_CTRL_CH0_IN0_IDX, - .pulse_sig = PCNT_SIG_CH0_IN0_IDX - }, - [1] = { - .control_sig = PCNT_CTRL_CH1_IN0_IDX, - .pulse_sig = PCNT_SIG_CH1_IN0_IDX - } +const soc_pcnt_signal_desc_t soc_pcnt_signals[1] = { + [0] = { + .irq_id = ETS_PCNT_INTR_SOURCE, + .module_name = "pcnt0", + .units = { + [0] = { + .channels = { + [0] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH0_IN0_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH0_IN0_IDX + }, + [1] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH1_IN0_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH1_IN0_IDX } - }, - [1] = { - .channels = { - [0] = { - .control_sig = PCNT_CTRL_CH0_IN1_IDX, - .pulse_sig = PCNT_SIG_CH0_IN1_IDX - }, - [1] = { - .control_sig = PCNT_CTRL_CH1_IN1_IDX, - .pulse_sig = PCNT_SIG_CH1_IN1_IDX - } + } + }, + [1] = { + .channels = { + [0] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH0_IN1_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH0_IN1_IDX + }, + [1] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH1_IN1_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH1_IN1_IDX } - }, - [2] = { - .channels = { - [0] = { - .control_sig = PCNT_CTRL_CH0_IN2_IDX, - .pulse_sig = PCNT_SIG_CH0_IN2_IDX - }, - [1] = { - .control_sig = PCNT_CTRL_CH1_IN2_IDX, - .pulse_sig = PCNT_SIG_CH1_IN2_IDX - } + } + }, + [2] = { + .channels = { + [0] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH0_IN2_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH0_IN2_IDX + }, + [1] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH1_IN2_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH1_IN2_IDX } - }, - [3] = { - .channels = { - [0] = { - .control_sig = PCNT_CTRL_CH0_IN3_IDX, - .pulse_sig = PCNT_SIG_CH0_IN3_IDX - }, - [1] = { - .control_sig = PCNT_CTRL_CH1_IN3_IDX, - .pulse_sig = PCNT_SIG_CH1_IN3_IDX - } + } + }, + [3] = { + .channels = { + [0] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH0_IN3_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH0_IN3_IDX + }, + [1] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH1_IN3_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH1_IN3_IDX } } } diff --git a/components/soc/esp32h21/include/soc/Kconfig.soc_caps.in b/components/soc/esp32h21/include/soc/Kconfig.soc_caps.in index 1508085055..0258d480c0 100644 --- a/components/soc/esp32h21/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32h21/include/soc/Kconfig.soc_caps.in @@ -475,22 +475,6 @@ config SOC_LEDC_CHANNEL_NUM int default 6 -config SOC_PCNT_GROUPS - int - default 1 - -config SOC_PCNT_UNITS_PER_GROUP - int - default 4 - -config SOC_PCNT_CHANNELS_PER_UNIT - int - default 2 - -config SOC_PCNT_THRES_POINT_PER_UNIT - int - default 2 - config SOC_PCNT_SUPPORT_RUNTIME_THRES_UPDATE bool default y diff --git a/components/soc/esp32h21/include/soc/soc_caps.h b/components/soc/esp32h21/include/soc/soc_caps.h index a9a5402f90..f7db4d907e 100644 --- a/components/soc/esp32h21/include/soc/soc_caps.h +++ b/components/soc/esp32h21/include/soc/soc_caps.h @@ -304,10 +304,6 @@ // #define SOC_MPU_REGION_WO_SUPPORTED 0 /*-------------------------- PCNT CAPS ---------------------------------------*/ -#define SOC_PCNT_GROUPS 1U -#define SOC_PCNT_UNITS_PER_GROUP 4 -#define SOC_PCNT_CHANNELS_PER_UNIT 2 -#define SOC_PCNT_THRES_POINT_PER_UNIT 2 #define SOC_PCNT_SUPPORT_RUNTIME_THRES_UPDATE 1 #define SOC_PCNT_SUPPORT_CLEAR_SIGNAL 1 #define SOC_PCNT_SUPPORT_STEP_NOTIFY 1 diff --git a/components/soc/esp32h21/include/soc/soc_caps_full.h b/components/soc/esp32h21/include/soc/soc_caps_full.h index d9ce210e7d..95748b6bc6 100644 --- a/components/soc/esp32h21/include/soc/soc_caps_full.h +++ b/components/soc/esp32h21/include/soc/soc_caps_full.h @@ -24,6 +24,12 @@ #define _SOC_CAPS_SDM_INST_NUM 1 // Number of SDM instances #define _SOC_CAPS_SDM_CHANS_PER_INST 4 // Number of channels in each SDM instance +/*--------------------------- PCNT (Pulse Counter) ------------------------*/ +#define _SOC_CAPS_PCNT_INST_NUM 1 // Number of PCNT instances +#define _SOC_CAPS_PCNT_UNITS_PER_INST 4 // Number of units in each PCNT instance +#define _SOC_CAPS_PCNT_CHANS_PER_UNIT 2 // Number of channels in each PCNT unit +#define _SOC_CAPS_PCNT_THRES_POINT_PER_UNIT 2 // Number of threshold points in each PCNT unit + /*--------------------------- ETM (Event Task Matrix) ----------------------------*/ #define _SOC_CAPS_ETM_INST_NUM 1 // Number of ETM instances #define _SOC_CAPS_ETM_CHANS_PER_INST 50 // Number of channels in each ETM instance diff --git a/components/soc/esp32h21/pcnt_periph.c b/components/soc/esp32h21/pcnt_periph.c index 8d1ddfc062..3f16293c77 100644 --- a/components/soc/esp32h21/pcnt_periph.c +++ b/components/soc/esp32h21/pcnt_periph.c @@ -8,64 +8,62 @@ #include "soc/gpio_sig_map.h" #include "soc/pcnt_reg.h" -const pcnt_signal_conn_t pcnt_periph_signals = { - .groups = { - [0] = { - .irq = ETS_PCNT_INTR_SOURCE, - .module_name = "pcnt0", - .units = { - [0] = { - .channels = { - [0] = { - .control_sig = PCNT_CTRL_CH0_IN0_IDX, - .pulse_sig = PCNT_SIG_CH0_IN0_IDX - }, - [1] = { - .control_sig = PCNT_CTRL_CH1_IN0_IDX, - .pulse_sig = PCNT_SIG_CH1_IN0_IDX - } +const soc_pcnt_signal_desc_t soc_pcnt_signals[1] = { + [0] = { + .irq_id = ETS_PCNT_INTR_SOURCE, + .module_name = "pcnt0", + .units = { + [0] = { + .channels = { + [0] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH0_IN0_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH0_IN0_IDX }, - .clear_sig = PCNT_RST_IN0_IDX + [1] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH1_IN0_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH1_IN0_IDX + } }, - [1] = { - .channels = { - [0] = { - .control_sig = PCNT_CTRL_CH0_IN1_IDX, - .pulse_sig = PCNT_SIG_CH0_IN1_IDX, - }, - [1] = { - .control_sig = PCNT_CTRL_CH1_IN1_IDX, - .pulse_sig = PCNT_SIG_CH1_IN1_IDX - } + .clear_sig_id_matrix = PCNT_RST_IN0_IDX + }, + [1] = { + .channels = { + [0] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH0_IN1_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH0_IN1_IDX, }, - .clear_sig = PCNT_RST_IN1_IDX + [1] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH1_IN1_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH1_IN1_IDX + } }, - [2] = { - .channels = { - [0] = { - .control_sig = PCNT_CTRL_CH0_IN2_IDX, - .pulse_sig = PCNT_SIG_CH0_IN2_IDX, - }, - [1] = { - .control_sig = PCNT_CTRL_CH1_IN2_IDX, - .pulse_sig = PCNT_SIG_CH1_IN2_IDX - } + .clear_sig_id_matrix = PCNT_RST_IN1_IDX + }, + [2] = { + .channels = { + [0] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH0_IN2_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH0_IN2_IDX, }, - .clear_sig = PCNT_RST_IN2_IDX + [1] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH1_IN2_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH1_IN2_IDX + } }, - [3] = { - .channels = { - [0] = { - .control_sig = PCNT_CTRL_CH0_IN3_IDX, - .pulse_sig = PCNT_SIG_CH0_IN3_IDX, - }, - [1] = { - .control_sig = PCNT_CTRL_CH1_IN3_IDX, - .pulse_sig = PCNT_SIG_CH1_IN3_IDX - } + .clear_sig_id_matrix = PCNT_RST_IN2_IDX + }, + [3] = { + .channels = { + [0] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH0_IN3_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH0_IN3_IDX, }, - .clear_sig = PCNT_RST_IN3_IDX - } + [1] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH1_IN3_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH1_IN3_IDX + } + }, + .clear_sig_id_matrix = PCNT_RST_IN3_IDX } } } diff --git a/components/soc/esp32p4/include/soc/Kconfig.soc_caps.in b/components/soc/esp32p4/include/soc/Kconfig.soc_caps.in index 671aca30e2..acdd394b65 100644 --- a/components/soc/esp32p4/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32p4/include/soc/Kconfig.soc_caps.in @@ -1147,22 +1147,6 @@ config SOC_MPU_REGION_WO_SUPPORTED bool default n -config SOC_PCNT_GROUPS - int - default 1 - -config SOC_PCNT_UNITS_PER_GROUP - int - default 4 - -config SOC_PCNT_CHANNELS_PER_UNIT - int - default 2 - -config SOC_PCNT_THRES_POINT_PER_UNIT - int - default 2 - config SOC_PCNT_SUPPORT_RUNTIME_THRES_UPDATE bool default y diff --git a/components/soc/esp32p4/include/soc/soc_caps.h b/components/soc/esp32p4/include/soc/soc_caps.h index 59519b23da..7c27283af4 100644 --- a/components/soc/esp32p4/include/soc/soc_caps.h +++ b/components/soc/esp32p4/include/soc/soc_caps.h @@ -419,10 +419,6 @@ #define SOC_MPU_REGION_WO_SUPPORTED 0 /*-------------------------- PCNT CAPS ---------------------------------------*/ -#define SOC_PCNT_GROUPS 1U -#define SOC_PCNT_UNITS_PER_GROUP 4 -#define SOC_PCNT_CHANNELS_PER_UNIT 2 -#define SOC_PCNT_THRES_POINT_PER_UNIT 2 #define SOC_PCNT_SUPPORT_RUNTIME_THRES_UPDATE 1 #define SOC_PCNT_SUPPORT_CLEAR_SIGNAL 1 /*!< Support clear signal input */ diff --git a/components/soc/esp32p4/include/soc/soc_caps_full.h b/components/soc/esp32p4/include/soc/soc_caps_full.h index 44735d0ac2..1992d8cc7d 100644 --- a/components/soc/esp32p4/include/soc/soc_caps_full.h +++ b/components/soc/esp32p4/include/soc/soc_caps_full.h @@ -24,6 +24,12 @@ #define _SOC_CAPS_SDM_INST_NUM 1 // Number of SDM instances #define _SOC_CAPS_SDM_CHANS_PER_INST 8 // Number of channels in each SDM instance +/*--------------------------- PCNT (Pulse Counter) ------------------------*/ +#define _SOC_CAPS_PCNT_INST_NUM 1 // Number of PCNT instances +#define _SOC_CAPS_PCNT_UNITS_PER_INST 4 // Number of units in each PCNT instance +#define _SOC_CAPS_PCNT_CHANS_PER_UNIT 2 // Number of channels in each PCNT unit +#define _SOC_CAPS_PCNT_THRES_POINT_PER_UNIT 2 // Number of threshold points in each PCNT unit + /*--------------------------- ETM (Event Task Matrix) ----------------------------*/ #define _SOC_CAPS_ETM_INST_NUM 1 // Number of ETM instances #define _SOC_CAPS_ETM_CHANS_PER_INST 50 // Number of channels in each ETM instance diff --git a/components/soc/esp32p4/pcnt_periph.c b/components/soc/esp32p4/pcnt_periph.c index 9acf3713ad..8ed3e5a4d2 100644 --- a/components/soc/esp32p4/pcnt_periph.c +++ b/components/soc/esp32p4/pcnt_periph.c @@ -8,64 +8,62 @@ #include "soc/gpio_sig_map.h" #include "soc/pcnt_reg.h" -const pcnt_signal_conn_t pcnt_periph_signals = { - .groups = { - [0] = { - .irq = ETS_PCNT_INTR_SOURCE, - .module_name = "pcnt0", - .units = { - [0] = { - .channels = { - [0] = { - .control_sig = PCNT_CTRL_CH0_PAD_IN0_IDX, - .pulse_sig = PCNT_SIG_CH0_PAD_IN0_IDX - }, - [1] = { - .control_sig = PCNT_CTRL_CH1_PAD_IN0_IDX, - .pulse_sig = PCNT_SIG_CH1_PAD_IN0_IDX - } +const soc_pcnt_signal_desc_t soc_pcnt_signals[1] = { + [0] = { + .irq_id = ETS_PCNT_INTR_SOURCE, + .module_name = "pcnt0", + .units = { + [0] = { + .channels = { + [0] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH0_PAD_IN0_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH0_PAD_IN0_IDX }, - .clear_sig = PCNT_RST_PAD_IN0_IDX + [1] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH1_PAD_IN0_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH1_PAD_IN0_IDX + } }, - [1] = { - .channels = { - [0] = { - .control_sig = PCNT_CTRL_CH0_PAD_IN1_IDX, - .pulse_sig = PCNT_SIG_CH0_PAD_IN1_IDX, - }, - [1] = { - .control_sig = PCNT_CTRL_CH1_PAD_IN1_IDX, - .pulse_sig = PCNT_SIG_CH1_PAD_IN1_IDX - } + .clear_sig_id_matrix = PCNT_RST_PAD_IN0_IDX + }, + [1] = { + .channels = { + [0] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH0_PAD_IN1_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH0_PAD_IN1_IDX, }, - .clear_sig = PCNT_RST_PAD_IN1_IDX + [1] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH1_PAD_IN1_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH1_PAD_IN1_IDX + } }, - [2] = { - .channels = { - [0] = { - .control_sig = PCNT_CTRL_CH0_PAD_IN2_IDX, - .pulse_sig = PCNT_SIG_CH0_PAD_IN2_IDX, - }, - [1] = { - .control_sig = PCNT_CTRL_CH1_PAD_IN2_IDX, - .pulse_sig = PCNT_SIG_CH1_PAD_IN2_IDX - } + .clear_sig_id_matrix = PCNT_RST_PAD_IN1_IDX + }, + [2] = { + .channels = { + [0] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH0_PAD_IN2_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH0_PAD_IN2_IDX, }, - .clear_sig = PCNT_RST_PAD_IN2_IDX + [1] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH1_PAD_IN2_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH1_PAD_IN2_IDX + } }, - [3] = { - .channels = { - [0] = { - .control_sig = PCNT_CTRL_CH0_PAD_IN3_IDX, - .pulse_sig = PCNT_SIG_CH0_PAD_IN3_IDX, - }, - [1] = { - .control_sig = PCNT_CTRL_CH1_PAD_IN3_IDX, - .pulse_sig = PCNT_SIG_CH1_PAD_IN3_IDX - } + .clear_sig_id_matrix = PCNT_RST_PAD_IN2_IDX + }, + [3] = { + .channels = { + [0] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH0_PAD_IN3_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH0_PAD_IN3_IDX, }, - .clear_sig = PCNT_RST_PAD_IN3_IDX - } + [1] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH1_PAD_IN3_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH1_PAD_IN3_IDX + } + }, + .clear_sig_id_matrix = PCNT_RST_PAD_IN3_IDX } } } diff --git a/components/soc/esp32s2/include/soc/Kconfig.soc_caps.in b/components/soc/esp32s2/include/soc/Kconfig.soc_caps.in index eb439915ab..95d67be84c 100644 --- a/components/soc/esp32s2/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32s2/include/soc/Kconfig.soc_caps.in @@ -583,22 +583,6 @@ config SOC_MPU_REGION_WO_SUPPORTED bool default n -config SOC_PCNT_GROUPS - int - default 1 - -config SOC_PCNT_UNITS_PER_GROUP - int - default 4 - -config SOC_PCNT_CHANNELS_PER_UNIT - int - default 2 - -config SOC_PCNT_THRES_POINT_PER_UNIT - int - default 2 - config SOC_RMT_GROUPS int default 1 diff --git a/components/soc/esp32s2/include/soc/soc_caps.h b/components/soc/esp32s2/include/soc/soc_caps.h index 1423ab4114..adef439f9a 100644 --- a/components/soc/esp32s2/include/soc/soc_caps.h +++ b/components/soc/esp32s2/include/soc/soc_caps.h @@ -257,12 +257,6 @@ #define SOC_MPU_REGION_RO_SUPPORTED 0 #define SOC_MPU_REGION_WO_SUPPORTED 0 -/*-------------------------- PCNT CAPS ---------------------------------------*/ -#define SOC_PCNT_GROUPS (1U) -#define SOC_PCNT_UNITS_PER_GROUP (4) -#define SOC_PCNT_CHANNELS_PER_UNIT (2) -#define SOC_PCNT_THRES_POINT_PER_UNIT (2) - /*-------------------------- RMT CAPS ----------------------------------------*/ #define SOC_RMT_GROUPS 1U /*!< One RMT group */ #define SOC_RMT_TX_CANDIDATES_PER_GROUP 4 /*!< Number of channels that capable of Transmit in each group */ diff --git a/components/soc/esp32s2/include/soc/soc_caps_full.h b/components/soc/esp32s2/include/soc/soc_caps_full.h index acf38bfcb4..3e0297910a 100644 --- a/components/soc/esp32s2/include/soc/soc_caps_full.h +++ b/components/soc/esp32s2/include/soc/soc_caps_full.h @@ -23,3 +23,9 @@ /*--------------------------- SDM (Sigma-Delta Modulator) ------------------------*/ #define _SOC_CAPS_SDM_INST_NUM 1 // Number of SDM instances #define _SOC_CAPS_SDM_CHANS_PER_INST 8 // Number of channels in each SDM instance + +/*--------------------------- PCNT (Pulse Counter) ------------------------*/ +#define _SOC_CAPS_PCNT_INST_NUM 1 // Number of PCNT instances +#define _SOC_CAPS_PCNT_UNITS_PER_INST 4 // Number of units in each PCNT instance +#define _SOC_CAPS_PCNT_CHANS_PER_UNIT 2 // Number of channels in each PCNT unit +#define _SOC_CAPS_PCNT_THRES_POINT_PER_UNIT 2 // Number of threshold points in each PCNT unit diff --git a/components/soc/esp32s2/pcnt_periph.c b/components/soc/esp32s2/pcnt_periph.c index bff39a4713..d28cd840b0 100644 --- a/components/soc/esp32s2/pcnt_periph.c +++ b/components/soc/esp32s2/pcnt_periph.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -7,58 +7,56 @@ #include "soc/pcnt_periph.h" #include "soc/gpio_sig_map.h" -const pcnt_signal_conn_t pcnt_periph_signals = { - .groups = { - [0] = { - .irq = ETS_PCNT_INTR_SOURCE, - .module_name = "pcnt0", - .units = { - [0] = { - .channels = { - [0] = { - .control_sig = PCNT_CTRL_CH0_IN0_IDX, - .pulse_sig = PCNT_SIG_CH0_IN0_IDX - }, - [1] = { - .control_sig = PCNT_CTRL_CH1_IN0_IDX, - .pulse_sig = PCNT_SIG_CH1_IN0_IDX - } +const soc_pcnt_signal_desc_t soc_pcnt_signals[1] = { + [0] = { + .irq_id = ETS_PCNT_INTR_SOURCE, + .module_name = "pcnt0", + .units = { + [0] = { + .channels = { + [0] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH0_IN0_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH0_IN0_IDX + }, + [1] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH1_IN0_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH1_IN0_IDX } - }, - [1] = { - .channels = { - [0] = { - .control_sig = PCNT_CTRL_CH0_IN1_IDX, - .pulse_sig = PCNT_SIG_CH0_IN1_IDX - }, - [1] = { - .control_sig = PCNT_CTRL_CH1_IN1_IDX, - .pulse_sig = PCNT_SIG_CH1_IN1_IDX - } + } + }, + [1] = { + .channels = { + [0] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH0_IN1_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH0_IN1_IDX + }, + [1] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH1_IN1_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH1_IN1_IDX } - }, - [2] = { - .channels = { - [0] = { - .control_sig = PCNT_CTRL_CH0_IN2_IDX, - .pulse_sig = PCNT_SIG_CH0_IN2_IDX - }, - [1] = { - .control_sig = PCNT_CTRL_CH1_IN2_IDX, - .pulse_sig = PCNT_SIG_CH1_IN2_IDX - } + } + }, + [2] = { + .channels = { + [0] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH0_IN2_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH0_IN2_IDX + }, + [1] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH1_IN2_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH1_IN2_IDX } - }, - [3] = { - .channels = { - [0] = { - .control_sig = PCNT_CTRL_CH0_IN3_IDX, - .pulse_sig = PCNT_SIG_CH0_IN3_IDX - }, - [1] = { - .control_sig = PCNT_CTRL_CH1_IN3_IDX, - .pulse_sig = PCNT_SIG_CH1_IN3_IDX - } + } + }, + [3] = { + .channels = { + [0] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH0_IN3_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH0_IN3_IDX + }, + [1] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH1_IN3_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH1_IN3_IDX } } } diff --git a/components/soc/esp32s3/include/soc/Kconfig.soc_caps.in b/components/soc/esp32s3/include/soc/Kconfig.soc_caps.in index 6e419a744a..39220f92b1 100644 --- a/components/soc/esp32s3/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32s3/include/soc/Kconfig.soc_caps.in @@ -703,22 +703,6 @@ config SOC_MPU_REGION_WO_SUPPORTED bool default n -config SOC_PCNT_GROUPS - int - default 1 - -config SOC_PCNT_UNITS_PER_GROUP - int - default 4 - -config SOC_PCNT_CHANNELS_PER_UNIT - int - default 2 - -config SOC_PCNT_THRES_POINT_PER_UNIT - int - default 2 - config SOC_RMT_GROUPS int default 1 diff --git a/components/soc/esp32s3/include/soc/soc_caps.h b/components/soc/esp32s3/include/soc/soc_caps.h index 2648161b7c..696f1426d8 100644 --- a/components/soc/esp32s3/include/soc/soc_caps.h +++ b/components/soc/esp32s3/include/soc/soc_caps.h @@ -280,12 +280,6 @@ #define SOC_MPU_REGION_RO_SUPPORTED 0 #define SOC_MPU_REGION_WO_SUPPORTED 0 -/*-------------------------- PCNT CAPS ---------------------------------------*/ -#define SOC_PCNT_GROUPS (1U) -#define SOC_PCNT_UNITS_PER_GROUP (4) -#define SOC_PCNT_CHANNELS_PER_UNIT (2) -#define SOC_PCNT_THRES_POINT_PER_UNIT (2) - /*-------------------------- RMT CAPS ----------------------------------------*/ #define SOC_RMT_GROUPS 1U /*!< One RMT group */ #define SOC_RMT_TX_CANDIDATES_PER_GROUP 4 /*!< Number of channels that capable of Transmit in each group */ diff --git a/components/soc/esp32s3/include/soc/soc_caps_full.h b/components/soc/esp32s3/include/soc/soc_caps_full.h index c1cdc3b38c..ce9945f26a 100644 --- a/components/soc/esp32s3/include/soc/soc_caps_full.h +++ b/components/soc/esp32s3/include/soc/soc_caps_full.h @@ -23,3 +23,9 @@ /*--------------------------- SDM (Sigma-Delta Modulator) ------------------------*/ #define _SOC_CAPS_SDM_INST_NUM 1 // Number of SDM instances #define _SOC_CAPS_SDM_CHANS_PER_INST 8 // Number of channels in each SDM instance + +/*--------------------------- PCNT (Pulse Counter) ------------------------*/ +#define _SOC_CAPS_PCNT_INST_NUM 1 // Number of PCNT instances +#define _SOC_CAPS_PCNT_UNITS_PER_INST 4 // Number of units in each PCNT instance +#define _SOC_CAPS_PCNT_CHANS_PER_UNIT 2 // Number of channels in each PCNT unit +#define _SOC_CAPS_PCNT_THRES_POINT_PER_UNIT 2 // Number of threshold points in each PCNT unit diff --git a/components/soc/esp32s3/pcnt_periph.c b/components/soc/esp32s3/pcnt_periph.c index bff39a4713..d28cd840b0 100644 --- a/components/soc/esp32s3/pcnt_periph.c +++ b/components/soc/esp32s3/pcnt_periph.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -7,58 +7,56 @@ #include "soc/pcnt_periph.h" #include "soc/gpio_sig_map.h" -const pcnt_signal_conn_t pcnt_periph_signals = { - .groups = { - [0] = { - .irq = ETS_PCNT_INTR_SOURCE, - .module_name = "pcnt0", - .units = { - [0] = { - .channels = { - [0] = { - .control_sig = PCNT_CTRL_CH0_IN0_IDX, - .pulse_sig = PCNT_SIG_CH0_IN0_IDX - }, - [1] = { - .control_sig = PCNT_CTRL_CH1_IN0_IDX, - .pulse_sig = PCNT_SIG_CH1_IN0_IDX - } +const soc_pcnt_signal_desc_t soc_pcnt_signals[1] = { + [0] = { + .irq_id = ETS_PCNT_INTR_SOURCE, + .module_name = "pcnt0", + .units = { + [0] = { + .channels = { + [0] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH0_IN0_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH0_IN0_IDX + }, + [1] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH1_IN0_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH1_IN0_IDX } - }, - [1] = { - .channels = { - [0] = { - .control_sig = PCNT_CTRL_CH0_IN1_IDX, - .pulse_sig = PCNT_SIG_CH0_IN1_IDX - }, - [1] = { - .control_sig = PCNT_CTRL_CH1_IN1_IDX, - .pulse_sig = PCNT_SIG_CH1_IN1_IDX - } + } + }, + [1] = { + .channels = { + [0] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH0_IN1_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH0_IN1_IDX + }, + [1] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH1_IN1_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH1_IN1_IDX } - }, - [2] = { - .channels = { - [0] = { - .control_sig = PCNT_CTRL_CH0_IN2_IDX, - .pulse_sig = PCNT_SIG_CH0_IN2_IDX - }, - [1] = { - .control_sig = PCNT_CTRL_CH1_IN2_IDX, - .pulse_sig = PCNT_SIG_CH1_IN2_IDX - } + } + }, + [2] = { + .channels = { + [0] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH0_IN2_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH0_IN2_IDX + }, + [1] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH1_IN2_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH1_IN2_IDX } - }, - [3] = { - .channels = { - [0] = { - .control_sig = PCNT_CTRL_CH0_IN3_IDX, - .pulse_sig = PCNT_SIG_CH0_IN3_IDX - }, - [1] = { - .control_sig = PCNT_CTRL_CH1_IN3_IDX, - .pulse_sig = PCNT_SIG_CH1_IN3_IDX - } + } + }, + [3] = { + .channels = { + [0] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH0_IN3_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH0_IN3_IDX + }, + [1] = { + .ctl_sig_id_matrix = PCNT_CTRL_CH1_IN3_IDX, + .pulse_sig_id_matrix = PCNT_SIG_CH1_IN3_IDX } } } diff --git a/components/soc/include/soc/pcnt_periph.h b/components/soc/include/soc/pcnt_periph.h index 18edab8b42..817661aa79 100644 --- a/components/soc/include/soc/pcnt_periph.h +++ b/components/soc/include/soc/pcnt_periph.h @@ -7,32 +7,34 @@ #pragma once #include -#include "soc/soc_caps.h" +#include +#include "soc/soc_caps_full.h" #include "soc/periph_defs.h" +// helper macros to access module attributes +#define SOC_PCNT_ATTR(_attr) SOC_MODULE_ATTR(PCNT, _attr) + #ifdef __cplusplus extern "C" { #endif -#if SOC_PCNT_SUPPORTED +#if SOC_HAS(PCNT) typedef struct { + const char *module_name; // module name struct { - const char *module_name; struct { - struct { - const uint32_t pulse_sig; - const uint32_t control_sig; - } channels[SOC_PCNT_CHANNELS_PER_UNIT]; - const uint32_t clear_sig; - } units[SOC_PCNT_UNITS_PER_GROUP]; - const uint32_t irq; - } groups[SOC_PCNT_GROUPS]; -} pcnt_signal_conn_t; + const int pulse_sig_id_matrix; // pulse signal ID in the GPIO matrix + const int ctl_sig_id_matrix; // control signal ID in the GPIO matrix + } channels[SOC_PCNT_ATTR(CHANS_PER_UNIT)]; + const int clear_sig_id_matrix; // clear signal ID in the GPIO matrix + } units[SOC_PCNT_ATTR(UNITS_PER_INST)]; + const int irq_id; // interrupt source ID +} soc_pcnt_signal_desc_t; -extern const pcnt_signal_conn_t pcnt_periph_signals; +extern const soc_pcnt_signal_desc_t soc_pcnt_signals[SOC_PCNT_ATTR(INST_NUM)]; -#endif // SOC_PCNT_SUPPORTED +#endif // SOC_HAS(PCNT) #ifdef __cplusplus } diff --git a/docs/en/api-reference/peripherals/pcnt.rst b/docs/en/api-reference/peripherals/pcnt.rst index a252430bb5..746b1c6eb3 100644 --- a/docs/en/api-reference/peripherals/pcnt.rst +++ b/docs/en/api-reference/peripherals/pcnt.rst @@ -60,7 +60,7 @@ To install a PCNT unit, there is a configuration structure that needs to be give Since all PCNT units share the same interrupt source, when installing multiple PCNT units make sure that the interrupt priority :cpp:member:`pcnt_unit_config_t::intr_priority` is the same for each unit. -Unit allocation and initialization is done by calling a function :cpp:func:`pcnt_new_unit` with :cpp:type:`pcnt_unit_config_t` as an input parameter. The function will return a PCNT unit handle only when it runs correctly. Specifically, when there are no more free PCNT units in the pool (i.e., unit resources have been used up), then this function will return :c:macro:`ESP_ERR_NOT_FOUND` error. The total number of available PCNT units is recorded by :c:macro:`SOC_PCNT_UNITS_PER_GROUP` for reference. +Unit allocation and initialization is done by calling a function :cpp:func:`pcnt_new_unit` with :cpp:type:`pcnt_unit_config_t` as an input parameter. The function will return a PCNT unit handle only when it runs correctly. Specifically, when there are no more free PCNT units in the pool (i.e., unit resources have been used up), then this function will return :c:macro:`ESP_ERR_NOT_FOUND` error. If a previously created PCNT unit is no longer needed, it is recommended to recycle the resource by calling :cpp:func:`pcnt_del_unit`. Which in return allows the underlying unit hardware to be used for other purposes. Before deleting a PCNT unit, one should ensure the following prerequisites: @@ -88,7 +88,7 @@ To install a PCNT channel, you must initialize a :cpp:type:`pcnt_chan_config_t` - :cpp:member:`pcnt_chan_config_t::virt_edge_io_level` and :cpp:member:`pcnt_chan_config_t::virt_level_io_level` specify the virtual IO level for **edge** and **level** input signal, to ensure a deterministic state for such control signal. Please note, they are only valid when either :cpp:member:`pcnt_chan_config_t::edge_gpio_num` or :cpp:member:`pcnt_chan_config_t::level_gpio_num` is assigned to ``-1``. - :cpp:member:`pcnt_chan_config_t::invert_edge_input` and :cpp:member:`pcnt_chan_config_t::invert_level_input` are used to decide whether to invert the input signals before they going into PCNT hardware. The invert is done by GPIO matrix instead of PCNT hardware. -Channel allocating and initialization is done by calling a function :cpp:func:`pcnt_new_channel` with the above :cpp:type:`pcnt_chan_config_t` as an input parameter plus a PCNT unit handle returned from :cpp:func:`pcnt_new_unit`. This function will return a PCNT channel handle if it runs correctly. Specifically, when there are no more free PCNT channel within the unit (i.e., channel resources have been used up), then this function will return :c:macro:`ESP_ERR_NOT_FOUND` error. The total number of available PCNT channels within the unit is recorded by :c:macro:`SOC_PCNT_CHANNELS_PER_UNIT` for reference. Note that, when install a PCNT channel for a specific unit, one should ensure the unit is in the init state, otherwise this function will return :c:macro:`ESP_ERR_INVALID_STATE` error. +Channel allocating and initialization is done by calling a function :cpp:func:`pcnt_new_channel` with the above :cpp:type:`pcnt_chan_config_t` as an input parameter plus a PCNT unit handle returned from :cpp:func:`pcnt_new_unit`. This function will return a PCNT channel handle if it runs correctly. Specifically, when there are no more free PCNT channel within the unit (i.e., channel resources have been used up), then this function will return :c:macro:`ESP_ERR_NOT_FOUND` error. Note that, when install a PCNT channel for a specific unit, one should ensure the unit is in the init state, otherwise this function will return :c:macro:`ESP_ERR_INVALID_STATE` error. If a previously created PCNT channel is no longer needed, it is recommended to recycle the resources by calling :cpp:func:`pcnt_del_channel`. Which in return allows the underlying channel hardware to be used for other purposes. diff --git a/docs/zh_CN/api-reference/peripherals/pcnt.rst b/docs/zh_CN/api-reference/peripherals/pcnt.rst index cf7554d44f..ecd6d3437c 100644 --- a/docs/zh_CN/api-reference/peripherals/pcnt.rst +++ b/docs/zh_CN/api-reference/peripherals/pcnt.rst @@ -60,7 +60,7 @@ PCNT 单元和通道分别用 :cpp:type:`pcnt_unit_handle_t` 与 :cpp:type:`pcnt 由于所有 PCNT 单元共享一个中断源,安装多个 PCNT 单元时请确保每个单元的中断优先级 :cpp:member:`pcnt_unit_config_t::intr_priority` 一致。 -调用函数 :cpp:func:`pcnt_new_unit` 并将 :cpp:type:`pcnt_unit_config_t` 作为其输入值,可对 PCNT 单元进行分配和初始化。该函数正常运行时,会返回一个 PCNT 单元句柄。没有可用的 PCNT 单元时(即 PCNT 单元全部被占用),该函数会返回错误 :c:macro:`ESP_ERR_NOT_FOUND`。可用的 PCNT 单元总数记录在 :c:macro:`SOC_PCNT_UNITS_PER_GROUP` 中,以供参考。 +调用函数 :cpp:func:`pcnt_new_unit` 并将 :cpp:type:`pcnt_unit_config_t` 作为其输入值,可对 PCNT 单元进行分配和初始化。该函数正常运行时,会返回一个 PCNT 单元句柄。没有可用的 PCNT 单元时(即 PCNT 单元全部被占用),该函数会返回错误 :c:macro:`ESP_ERR_NOT_FOUND`。 如果不再需要之前创建的某个 PCNT 单元,建议通过调用 :cpp:func:`pcnt_del_unit` 来回收该单元,从而该单元可用于其他用途。删除某个 PCNT 单元之前,需要满足以下条件: @@ -88,7 +88,7 @@ PCNT 单元和通道分别用 :cpp:type:`pcnt_unit_handle_t` 与 :cpp:type:`pcnt - :cpp:member:`pcnt_chan_config_t::virt_edge_io_level` 与 :cpp:member:`pcnt_chan_config_t::virt_level_io_level` 用于指定 **边沿** 信号和 **电平** 信号的虚拟 IO 电平,以保证这些控制信号处于确定状态。请注意,只有在 :cpp:member:`pcnt_chan_config_t::edge_gpio_num` 或 :cpp:member:`pcnt_chan_config_t::level_gpio_num` 设置为 `-1` 时,这两个参数才有效。 - :cpp:member:`pcnt_chan_config_t::invert_edge_input` 与 :cpp:member:`pcnt_chan_config_t::invert_level_input` 用于确定信号在输入 PCNT 之前是否需要被翻转,信号翻转由 GPIO 矩阵(不是 PCNT 单元)执行。 -调用函数 :cpp:func:`pcnt_new_channel`,将 :cpp:type:`pcnt_chan_config_t` 作为输入值并调用 :cpp:func:`pcnt_new_unit` 返回的 PCNT 单元句柄,可对 PCNT 通道进行分配和初始化。如果该函数正常运行,会返回一个 PCNT 通道句柄。如果没有可用的 PCNT 通道(PCNT 通道资源全部被占用),该函数会返回错误 :c:macro:`ESP_ERR_NOT_FOUND`。可用的 PCNT 通道总数记录在 :c:macro:`SOC_PCNT_CHANNELS_PER_UNIT`,以供参考。注意,为某个单元安装 PCNT 通道时,应确保该单元处于初始状态,否则函数 :cpp:func:`pcnt_new_channel` 会返回错误 :c:macro:`ESP_ERR_INVALID_STATE`。 +调用函数 :cpp:func:`pcnt_new_channel`,将 :cpp:type:`pcnt_chan_config_t` 作为输入值并调用 :cpp:func:`pcnt_new_unit` 返回的 PCNT 单元句柄,可对 PCNT 通道进行分配和初始化。如果该函数正常运行,会返回一个 PCNT 通道句柄。如果没有可用的 PCNT 通道(PCNT 通道资源全部被占用),该函数会返回错误 :c:macro:`ESP_ERR_NOT_FOUND`。注意,为某个单元安装 PCNT 通道时,应确保该单元处于初始状态,否则函数 :cpp:func:`pcnt_new_channel` 会返回错误 :c:macro:`ESP_ERR_INVALID_STATE`。 如果不再需要之前创建的某个 PCNT 通道,建议通过调用 :cpp:func:`pcnt_del_channel` 回收该通道,从而该通道可用于其他用途。