mirror of
https://github.com/espressif/esp-idf.git
synced 2026-04-27 19:13:21 +00:00
feat(hal): graudate the PCNT hal driver into a new component
This commit is contained in:
committed by
Chen Ji Chang
parent
8811f2ec07
commit
c84773f307
@@ -20,7 +20,6 @@
|
||||
// Following headers are used to test the conversion frequency
|
||||
#include "soc/i2s_periph.h"
|
||||
#include "driver/pulse_cnt.h"
|
||||
#include "soc/pcnt_periph.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2
|
||||
#include "esp_private/spi_common_internal.h"
|
||||
#endif
|
||||
@@ -257,7 +256,6 @@ 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, soc_pcnt_signals[0].units[0].channels[0].pulse_sig_id_matrix, 0);
|
||||
|
||||
size_t len = 800;
|
||||
uint8_t data[len];
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
#include "esp_private/i2s_platform.h"
|
||||
#if SOC_PCNT_SUPPORTED
|
||||
#include "driver/pulse_cnt.h"
|
||||
#include "soc/pcnt_periph.h"
|
||||
#include "hal/pcnt_periph.h"
|
||||
#endif
|
||||
|
||||
#include "../../test_inc/test_i2s.h"
|
||||
|
||||
@@ -6,6 +6,7 @@ if(CONFIG_SOC_PCNT_SUPPORTED)
|
||||
list(APPEND srcs "src/pulse_cnt.c")
|
||||
endif()
|
||||
|
||||
set(requires esp_hal_pcnt)
|
||||
if(${target} STREQUAL "linux")
|
||||
set(priv_requires "")
|
||||
else()
|
||||
@@ -14,6 +15,7 @@ endif()
|
||||
|
||||
idf_component_register(SRCS ${srcs}
|
||||
INCLUDE_DIRS ${public_include}
|
||||
REQUIRES "${requires}"
|
||||
PRIV_REQUIRES "${priv_requires}"
|
||||
LDFRAGMENTS "linker.lf"
|
||||
)
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "esp_pm.h"
|
||||
#include "esp_rom_gpio.h"
|
||||
#include "soc/soc_caps.h"
|
||||
#include "soc/pcnt_periph.h"
|
||||
#include "hal/pcnt_periph.h"
|
||||
#include "soc/gpio_pins.h"
|
||||
#include "hal/pcnt_hal.h"
|
||||
#include "hal/pcnt_ll.h"
|
||||
@@ -75,8 +75,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_ATTR(INST_NUM)]; // pcnt group pool
|
||||
int group_ref_counts[SOC_PCNT_ATTR(INST_NUM)]; // reference count used to protect group install/uninstall
|
||||
pcnt_group_t *groups[PCNT_LL_GET(INST_NUM)]; // pcnt group pool
|
||||
int group_ref_counts[PCNT_LL_GET(INST_NUM)]; // reference count used to protect group install/uninstall
|
||||
};
|
||||
|
||||
struct pcnt_group_t {
|
||||
@@ -85,7 +85,7 @@ struct pcnt_group_t {
|
||||
pcnt_clock_source_t clk_src; // PCNT clock source
|
||||
portMUX_TYPE spinlock; // to protect per-group register level concurrent access
|
||||
pcnt_hal_context_t hal;
|
||||
pcnt_unit_t *units[SOC_PCNT_ATTR(UNITS_PER_INST)]; // array of PCNT units
|
||||
pcnt_unit_t *units[PCNT_LL_GET(UNITS_PER_INST)]; // array of PCNT units
|
||||
#if CONFIG_PM_ENABLE
|
||||
esp_pm_lock_handle_t pm_lock; // power management lock
|
||||
#endif
|
||||
@@ -120,7 +120,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_ATTR(CHANS_PER_UNIT)]; // array of PCNT channels
|
||||
pcnt_chan_t *channels[PCNT_LL_GET(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
|
||||
@@ -154,12 +154,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_ATTR(INST_NUM); i++) {
|
||||
for (int i = 0; i < PCNT_LL_GET(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_ATTR(UNITS_PER_INST); j++) {
|
||||
for (int j = 0; j < PCNT_LL_GET(UNITS_PER_INST); j++) {
|
||||
if (!group->units[j]) {
|
||||
unit_id = j;
|
||||
group->units[j] = unit;
|
||||
@@ -324,7 +324,7 @@ 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_ATTR(CHANS_PER_UNIT); i++) {
|
||||
for (int i = 0; i < PCNT_LL_GET(CHANS_PER_UNIT); i++) {
|
||||
ESP_RETURN_ON_FALSE(!unit->channels[i], ESP_ERR_INVALID_STATE, TAG, "channel %d still in working", i);
|
||||
}
|
||||
|
||||
@@ -607,7 +607,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_ATTR(THRES_POINT_PER_UNIT) - 1;
|
||||
int thres_num = PCNT_LL_GET(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) {
|
||||
@@ -794,7 +794,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_ATTR(CHANS_PER_UNIT); i++) {
|
||||
for (int i = 0; i < PCNT_LL_GET(CHANS_PER_UNIT); i++) {
|
||||
if (!unit->channels[i]) {
|
||||
channel_id = i;
|
||||
unit->channels[channel_id] = channel;
|
||||
|
||||
@@ -9,9 +9,19 @@ project(pcnt_test)
|
||||
|
||||
idf_build_get_property(elf EXECUTABLE)
|
||||
if(CONFIG_COMPILER_DUMP_RTL_FILES)
|
||||
|
||||
# Collect RTL directories in a variable for readability. Join them
|
||||
# with commas so they are passed as a single --rtl-dirs argument to the script.
|
||||
set(PCNT_RTL_DIRS
|
||||
${CMAKE_BINARY_DIR}/esp-idf/esp_driver_pcnt
|
||||
${CMAKE_BINARY_DIR}/esp-idf/hal
|
||||
${CMAKE_BINARY_DIR}/esp-idf/esp_hal_pcnt
|
||||
)
|
||||
string(JOIN "," PCNT_RTL_DIRS_JOINED ${PCNT_RTL_DIRS})
|
||||
|
||||
add_custom_target(check_test_app_sections ALL
|
||||
COMMAND ${PYTHON} $ENV{IDF_PATH}/tools/ci/check_callgraph.py
|
||||
--rtl-dirs ${CMAKE_BINARY_DIR}/esp-idf/esp_driver_pcnt/,${CMAKE_BINARY_DIR}/esp-idf/hal/
|
||||
--rtl-dirs ${PCNT_RTL_DIRS_JOINED}
|
||||
--elf-file ${CMAKE_BINARY_DIR}/pcnt_test.elf
|
||||
find-refs
|
||||
--from-sections=.iram0.text
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "freertos/task.h"
|
||||
#include "unity.h"
|
||||
#include "soc/soc_caps.h"
|
||||
#include "soc/pcnt_periph.h"
|
||||
#include "hal/pcnt_periph.h"
|
||||
#include "hal/pcnt_ll.h"
|
||||
#include "driver/pulse_cnt.h"
|
||||
#include "driver/gpio.h"
|
||||
@@ -24,11 +24,11 @@ TEST_CASE("pcnt_unit_install_uninstall", "[pcnt]")
|
||||
.high_limit = 100,
|
||||
.intr_priority = 0,
|
||||
};
|
||||
pcnt_unit_handle_t units[SOC_PCNT_ATTR(UNITS_PER_INST)];
|
||||
pcnt_unit_handle_t units[PCNT_LL_GET(UNITS_PER_INST)];
|
||||
int count_value = 0;
|
||||
|
||||
printf("install pcnt units and check initial count\r\n");
|
||||
for (int i = 0; i < SOC_PCNT_ATTR(UNITS_PER_INST) - 1; i++) {
|
||||
for (int i = 0; i < PCNT_LL_GET(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);
|
||||
@@ -36,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_ATTR(UNITS_PER_INST) - 1]));
|
||||
TEST_ESP_ERR(ESP_ERR_INVALID_STATE, pcnt_new_unit(&unit_config, &units[PCNT_LL_GET(UNITS_PER_INST) - 1]));
|
||||
unit_config.intr_priority = 0;
|
||||
TEST_ESP_OK(pcnt_new_unit(&unit_config, &units[SOC_PCNT_ATTR(UNITS_PER_INST) - 1]));
|
||||
TEST_ESP_OK(pcnt_new_unit(&unit_config, &units[PCNT_LL_GET(UNITS_PER_INST) - 1]));
|
||||
|
||||
// no more free pcnt units
|
||||
TEST_ASSERT_EQUAL(ESP_ERR_NOT_FOUND, pcnt_new_unit(&unit_config, &units[0]));
|
||||
@@ -47,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_ATTR(UNITS_PER_INST); i++) {
|
||||
for (int i = 0; i < PCNT_LL_GET(UNITS_PER_INST); i++) {
|
||||
TEST_ESP_OK(pcnt_unit_set_glitch_filter(units[i], &filter_config));
|
||||
}
|
||||
// invalid glitch configuration
|
||||
@@ -57,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_ATTR(UNITS_PER_INST); i++) {
|
||||
for (int i = 0; i < PCNT_LL_GET(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_ATTR(UNITS_PER_INST); i++) {
|
||||
for (int i = 0; i < PCNT_LL_GET(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_ATTR(UNITS_PER_INST); i++) {
|
||||
for (int i = 0; i < PCNT_LL_GET(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_ATTR(UNITS_PER_INST); i++) {
|
||||
for (int i = 0; i < PCNT_LL_GET(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_ATTR(UNITS_PER_INST); i++) {
|
||||
for (int i = 0; i < PCNT_LL_GET(UNITS_PER_INST); i++) {
|
||||
TEST_ESP_OK(pcnt_del_unit(units[i]));
|
||||
}
|
||||
}
|
||||
@@ -97,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_ATTR(UNITS_PER_INST)];
|
||||
pcnt_channel_handle_t chans[SOC_PCNT_ATTR(UNITS_PER_INST)][SOC_PCNT_ATTR(CHANS_PER_UNIT)];
|
||||
pcnt_unit_handle_t units[PCNT_LL_GET(UNITS_PER_INST)];
|
||||
pcnt_channel_handle_t chans[PCNT_LL_GET(UNITS_PER_INST)][PCNT_LL_GET(CHANS_PER_UNIT)];
|
||||
|
||||
printf("install pcnt units\r\n");
|
||||
for (int i = 0; i < SOC_PCNT_ATTR(UNITS_PER_INST); i++) {
|
||||
for (int i = 0; i < PCNT_LL_GET(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_ATTR(UNITS_PER_INST); i++) {
|
||||
for (int j = 0; j < SOC_PCNT_ATTR(CHANS_PER_UNIT); j++) {
|
||||
for (int i = 0; i < PCNT_LL_GET(UNITS_PER_INST); i++) {
|
||||
for (int j = 0; j < PCNT_LL_GET(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));
|
||||
@@ -118,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_ATTR(UNITS_PER_INST); i++) {
|
||||
for (int i = 0; i < PCNT_LL_GET(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_ATTR(CHANS_PER_UNIT), count_value);
|
||||
TEST_ASSERT_EQUAL(10 * PCNT_LL_GET(CHANS_PER_UNIT), count_value);
|
||||
}
|
||||
|
||||
printf("clear counts\r\n");
|
||||
for (int i = 0; i < SOC_PCNT_ATTR(UNITS_PER_INST); i++) {
|
||||
for (int i = 0; i < PCNT_LL_GET(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_ATTR(UNITS_PER_INST); i++) {
|
||||
for (int i = 0; i < PCNT_LL_GET(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_ATTR(UNITS_PER_INST); i++) {
|
||||
for (int i = 0; i < PCNT_LL_GET(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_ATTR(UNITS_PER_INST); i++) {
|
||||
for (int i = 0; i < PCNT_LL_GET(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_ATTR(CHANS_PER_UNIT), count_value);
|
||||
TEST_ASSERT_EQUAL(10 * PCNT_LL_GET(CHANS_PER_UNIT), count_value);
|
||||
}
|
||||
|
||||
printf("uninstall channels and units\r\n");
|
||||
for (int i = 0; i < SOC_PCNT_ATTR(UNITS_PER_INST); i++) {
|
||||
for (int i = 0; i < PCNT_LL_GET(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_ATTR(CHANS_PER_UNIT); j++) {
|
||||
for (int j = 0; j < PCNT_LL_GET(CHANS_PER_UNIT); j++) {
|
||||
TEST_ESP_OK(pcnt_del_channel(chans[i][j]));
|
||||
}
|
||||
TEST_ESP_OK(pcnt_del_unit(units[i]));
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
idf_build_get_property(target IDF_TARGET)
|
||||
|
||||
if(${target} STREQUAL "linux")
|
||||
return() # This component is not supported by the POSIX/Linux simulator
|
||||
endif()
|
||||
|
||||
set(srcs)
|
||||
set(includes "include")
|
||||
|
||||
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/${target}/include")
|
||||
list(APPEND includes "${target}/include")
|
||||
endif()
|
||||
|
||||
# PCNT related source files
|
||||
if(CONFIG_SOC_PCNT_SUPPORTED)
|
||||
list(APPEND srcs "pcnt_hal.c" "${target}/pcnt_periph.c")
|
||||
endif()
|
||||
|
||||
idf_component_register(SRCS ${srcs}
|
||||
INCLUDE_DIRS ${includes}
|
||||
REQUIRES soc hal)
|
||||
@@ -0,0 +1,56 @@
|
||||
# ESP Hardware Abstraction Layer for PCNT Peripherals
|
||||
|
||||
> [!NOTE]
|
||||
> This component is currently in beta. Its API, behavior, and compatibility may change at any time and without notice; backward compatibility is not guaranteed. Use caution when integrating into production systems.
|
||||
|
||||
## Overview
|
||||
|
||||
The `esp_hal_pcnt` component provides a **Hardware Abstraction Layer** for PCNT (Pulse Counter) peripherals across ESP-IDF supported targets. This HAL enables efficient counting of external pulses and signals, with support for quadrature encoders, frequency measurement, and position tracking applications.
|
||||
|
||||
## Architecture
|
||||
|
||||
The PCNT HAL is structured in two main sub-layers:
|
||||
|
||||
1. **HAL Layer (Upper)**: Defines the operational steps and data structures required to control PCNT peripherals (e.g., initialization).
|
||||
|
||||
2. **Low-Level Layer (Bottom)**: Serves as a translation layer between the HAL and the register files defined in the `soc` component, handling target-specific register configurations.
|
||||
|
||||
## Features
|
||||
|
||||
### Core Counting Features
|
||||
- Bidirectional pulse counting (increment/decrement)
|
||||
- Configurable counting range with high/low limits
|
||||
- Counter value read operations
|
||||
- Counter clear and reset functionality
|
||||
- Start/stop control for counting operations
|
||||
|
||||
### Channel Configuration
|
||||
- Edge action configuration:
|
||||
- Hold: Keep current count value
|
||||
- Increase: Increment count value
|
||||
- Decrease: Decrement count value
|
||||
- Level action configuration:
|
||||
- Keep: Maintain current count mode
|
||||
- Inverse: Invert count direction
|
||||
- Hold: Freeze count value
|
||||
|
||||
### Event Detection
|
||||
- Threshold events
|
||||
- High/low limit events
|
||||
- Zero-crossing events
|
||||
- Watch-point events
|
||||
- Step events
|
||||
|
||||
### Signal Processing
|
||||
- Glitch filtering with configurable filter width
|
||||
|
||||
## Usage
|
||||
|
||||
The HAL functions primarily serve ESP-IDF PCNT peripheral drivers such as `esp_driver_pcnt` component.
|
||||
|
||||
Advanced developers can use these interfaces directly when implementing custom pulse counting applications, with the understanding that API stability is not guaranteed.
|
||||
|
||||
## Dependencies
|
||||
|
||||
- `soc`: Provides chip-specific register definitions and peripheral capabilities
|
||||
- `hal`: Core hardware abstraction utilities and macros
|
||||
+9
@@ -29,6 +29,9 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Get PCNT attribute
|
||||
#define PCNT_LL_GET(attr) (PCNT_LL_ ## attr)
|
||||
|
||||
#define PCNT_LL_GET_HW(num) (((num) == 0) ? (&PCNT) : NULL)
|
||||
#define PCNT_LL_MAX_GLITCH_WIDTH 1023
|
||||
#define PCNT_LL_MAX_LIM SHRT_MAX
|
||||
@@ -44,6 +47,12 @@ typedef enum {
|
||||
PCNT_LL_WATCH_EVENT_MAX
|
||||
} pcnt_ll_watch_event_id_t;
|
||||
|
||||
// SoC-based capabilities
|
||||
#define PCNT_LL_INST_NUM 1 // Number of PCNT instances
|
||||
#define PCNT_LL_UNITS_PER_INST 8 // Number of units in each PCNT instance
|
||||
#define PCNT_LL_CHANS_PER_UNIT 2 // Number of channels in each PCNT unit
|
||||
#define PCNT_LL_THRES_POINT_PER_UNIT 2 // Number of threshold points in each PCNT unit
|
||||
|
||||
#define PCNT_LL_WATCH_EVENT_MASK ((1 << PCNT_LL_WATCH_EVENT_MAX) - 1)
|
||||
#define PCNT_LL_UNIT_WATCH_EVENT(unit_id) (1 << (unit_id))
|
||||
#define PCNT_LL_CLOCK_SUPPORT_APB 1
|
||||
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "hal/pcnt_periph.h"
|
||||
#include "soc/gpio_sig_map.h"
|
||||
#include "soc/soc.h"
|
||||
|
||||
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] = {
|
||||
.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] = {
|
||||
.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] = {
|
||||
.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] = {
|
||||
.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] = {
|
||||
.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] = {
|
||||
.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] = {
|
||||
.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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
+9
-1
@@ -19,6 +19,9 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Get PCNT attribute
|
||||
#define PCNT_LL_GET(attr) (PCNT_LL_ ## attr)
|
||||
|
||||
#define PCNT_LL_GET_HW(num) (((num) == 0) ? (&PCNT) : NULL)
|
||||
#define PCNT_LL_MAX_GLITCH_WIDTH 1023
|
||||
#define PCNT_LL_MAX_LIM SHRT_MAX
|
||||
@@ -39,6 +42,12 @@ typedef enum {
|
||||
PCNT_LL_STEP_EVENT_REACH_INTERVAL_BACKWARD,
|
||||
} pcnt_ll_step_event_id_t;
|
||||
|
||||
// SoC-based capabilities
|
||||
#define PCNT_LL_INST_NUM 1 // Number of PCNT instances
|
||||
#define PCNT_LL_UNITS_PER_INST 4 // Number of units in each PCNT instance
|
||||
#define PCNT_LL_CHANS_PER_UNIT 2 // Number of channels in each PCNT unit
|
||||
#define PCNT_LL_THRES_POINT_PER_UNIT 2 // Number of threshold points in each PCNT unit
|
||||
|
||||
#define PCNT_LL_WATCH_EVENT_MASK ((1 << PCNT_LL_WATCH_EVENT_MAX) - 1)
|
||||
#define PCNT_LL_UNIT_WATCH_EVENT(unit_id) (1 << (unit_id))
|
||||
#define PCNT_LL_CLOCK_SUPPORT_APB 1
|
||||
@@ -512,7 +521,6 @@ static inline bool pcnt_ll_is_step_notify_supported(int group_id)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "soc/pcnt_periph.h"
|
||||
#include "hal/pcnt_periph.h"
|
||||
#include "soc/gpio_sig_map.h"
|
||||
#include "soc/pcnt_reg.h"
|
||||
|
||||
+9
@@ -26,6 +26,9 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Get PCNT attribute
|
||||
#define PCNT_LL_GET(attr) (PCNT_LL_ ## attr)
|
||||
|
||||
#define PCNT_LL_GET_HW(num) (((num) == 0) ? (&PCNT) : NULL)
|
||||
#define PCNT_LL_MAX_GLITCH_WIDTH 1023
|
||||
#define PCNT_LL_MAX_LIM SHRT_MAX
|
||||
@@ -41,6 +44,12 @@ typedef enum {
|
||||
PCNT_LL_WATCH_EVENT_MAX
|
||||
} pcnt_ll_watch_event_id_t;
|
||||
|
||||
// SoC-based capabilities
|
||||
#define PCNT_LL_INST_NUM 1 // Number of PCNT instances
|
||||
#define PCNT_LL_UNITS_PER_INST 4 // Number of units in each PCNT instance
|
||||
#define PCNT_LL_CHANS_PER_UNIT 2 // Number of channels in each PCNT unit
|
||||
#define PCNT_LL_THRES_POINT_PER_UNIT 2 // Number of threshold points in each PCNT unit
|
||||
|
||||
#define PCNT_LL_WATCH_EVENT_MASK ((1 << PCNT_LL_WATCH_EVENT_MAX) - 1)
|
||||
#define PCNT_LL_UNIT_WATCH_EVENT(unit_id) (1 << (unit_id))
|
||||
#define PCNT_LL_CLOCK_SUPPORT_APB 1
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "soc/pcnt_periph.h"
|
||||
#include "hal/pcnt_periph.h"
|
||||
#include "soc/gpio_sig_map.h"
|
||||
#include "soc/pcnt_reg.h"
|
||||
|
||||
+9
-1
@@ -29,6 +29,9 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Get PCNT attribute
|
||||
#define PCNT_LL_GET(attr) (PCNT_LL_ ## attr)
|
||||
|
||||
#define PCNT_LL_GET_HW(num) (((num) == 0) ? (&PCNT) : NULL)
|
||||
#define PCNT_LL_MAX_GLITCH_WIDTH 1023
|
||||
#define PCNT_LL_MAX_LIM SHRT_MAX
|
||||
@@ -49,6 +52,12 @@ typedef enum {
|
||||
PCNT_LL_STEP_EVENT_REACH_INTERVAL
|
||||
} pcnt_ll_step_event_id_t;
|
||||
|
||||
// SoC-based capabilities
|
||||
#define PCNT_LL_INST_NUM 1 // Number of PCNT instances
|
||||
#define PCNT_LL_UNITS_PER_INST 4 // Number of units in each PCNT instance
|
||||
#define PCNT_LL_CHANS_PER_UNIT 2 // Number of channels in each PCNT unit
|
||||
#define PCNT_LL_THRES_POINT_PER_UNIT 2 // Number of threshold points in each PCNT unit
|
||||
|
||||
#define PCNT_LL_WATCH_EVENT_MASK ((1 << PCNT_LL_WATCH_EVENT_MAX) - 1)
|
||||
#define PCNT_LL_UNIT_WATCH_EVENT(unit_id) (1 << (unit_id))
|
||||
#define PCNT_LL_STEP_NOTIFY_DIR_LIMIT 1
|
||||
@@ -532,7 +541,6 @@ static inline bool pcnt_ll_is_step_notify_supported(int group_id)
|
||||
return ESP_CHIP_REV_ABOVE(efuse_hal_chip_revision(), 102);
|
||||
}
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "soc/pcnt_periph.h"
|
||||
#include "hal/pcnt_periph.h"
|
||||
#include "soc/gpio_sig_map.h"
|
||||
#include "soc/pcnt_reg.h"
|
||||
|
||||
+9
-1
@@ -19,6 +19,9 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Get PCNT attribute
|
||||
#define PCNT_LL_GET(attr) (PCNT_LL_ ## attr)
|
||||
|
||||
#define PCNT_LL_GET_HW(num) (((num) == 0) ? (&PCNT) : NULL)
|
||||
#define PCNT_LL_MAX_GLITCH_WIDTH 1023
|
||||
#define PCNT_LL_MAX_LIM SHRT_MAX
|
||||
@@ -39,6 +42,12 @@ typedef enum {
|
||||
PCNT_LL_STEP_EVENT_REACH_INTERVAL_BACKWARD,
|
||||
} pcnt_ll_step_event_id_t;
|
||||
|
||||
// SoC-based capabilities
|
||||
#define PCNT_LL_INST_NUM 1 // Number of PCNT instances
|
||||
#define PCNT_LL_UNITS_PER_INST 4 // Number of units in each PCNT instance
|
||||
#define PCNT_LL_CHANS_PER_UNIT 2 // Number of channels in each PCNT unit
|
||||
#define PCNT_LL_THRES_POINT_PER_UNIT 2 // Number of threshold points in each PCNT unit
|
||||
|
||||
#define PCNT_LL_WATCH_EVENT_MASK ((1 << PCNT_LL_WATCH_EVENT_MAX) - 1)
|
||||
#define PCNT_LL_UNIT_WATCH_EVENT(unit_id) (1 << (unit_id))
|
||||
#define PCNT_LL_CLOCK_SUPPORT_APB 1
|
||||
@@ -512,7 +521,6 @@ static inline bool pcnt_ll_is_step_notify_supported(int group_id)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "soc/pcnt_periph.h"
|
||||
#include "hal/pcnt_periph.h"
|
||||
#include "soc/gpio_sig_map.h"
|
||||
#include "soc/pcnt_reg.h"
|
||||
|
||||
+9
@@ -19,6 +19,9 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Get PCNT attribute
|
||||
#define PCNT_LL_GET(attr) (PCNT_LL_ ## attr)
|
||||
|
||||
#define PCNT_LL_GET_HW(num) (((num) == 0) ? (&PCNT) : NULL)
|
||||
#define PCNT_LL_MAX_GLITCH_WIDTH 1023
|
||||
#define PCNT_LL_MAX_LIM SHRT_MAX
|
||||
@@ -39,6 +42,12 @@ typedef enum {
|
||||
PCNT_LL_STEP_EVENT_REACH_INTERVAL_BACKWARD,
|
||||
} pcnt_ll_step_event_id_t;
|
||||
|
||||
// SoC-based capabilities
|
||||
#define PCNT_LL_INST_NUM 1 // Number of PCNT instances
|
||||
#define PCNT_LL_UNITS_PER_INST 4 // Number of units in each PCNT instance
|
||||
#define PCNT_LL_CHANS_PER_UNIT 2 // Number of channels in each PCNT unit
|
||||
#define PCNT_LL_THRES_POINT_PER_UNIT 2 // Number of threshold points in each PCNT unit
|
||||
|
||||
#define PCNT_LL_WATCH_EVENT_MASK ((1 << PCNT_LL_WATCH_EVENT_MAX) - 1)
|
||||
#define PCNT_LL_UNIT_WATCH_EVENT(unit_id) (1 << (unit_id))
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "soc/pcnt_periph.h"
|
||||
#include "hal/pcnt_periph.h"
|
||||
#include "soc/gpio_sig_map.h"
|
||||
#include "soc/pcnt_reg.h"
|
||||
|
||||
+9
@@ -27,6 +27,9 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Get PCNT attribute
|
||||
#define PCNT_LL_GET(attr) (PCNT_LL_ ## attr)
|
||||
|
||||
#define PCNT_LL_GET_HW(num) (((num) == 0) ? (&PCNT) : NULL)
|
||||
#define PCNT_LL_MAX_GLITCH_WIDTH 1023
|
||||
#define PCNT_LL_MAX_LIM SHRT_MAX
|
||||
@@ -42,6 +45,12 @@ typedef enum {
|
||||
PCNT_LL_WATCH_EVENT_MAX
|
||||
} pcnt_ll_watch_event_id_t;
|
||||
|
||||
// SoC-based capabilities
|
||||
#define PCNT_LL_INST_NUM 1 // Number of PCNT instances
|
||||
#define PCNT_LL_UNITS_PER_INST 4 // Number of units in each PCNT instance
|
||||
#define PCNT_LL_CHANS_PER_UNIT 2 // Number of channels in each PCNT unit
|
||||
#define PCNT_LL_THRES_POINT_PER_UNIT 2 // Number of threshold points in each PCNT unit
|
||||
|
||||
#define PCNT_LL_WATCH_EVENT_MASK ((1 << PCNT_LL_WATCH_EVENT_MAX) - 1)
|
||||
#define PCNT_LL_UNIT_WATCH_EVENT(unit_id) (1 << (unit_id))
|
||||
#define PCNT_LL_CLOCK_SUPPORT_APB 1
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "soc/pcnt_periph.h"
|
||||
#include "hal/pcnt_periph.h"
|
||||
#include "soc/gpio_sig_map.h"
|
||||
#include "soc/pcnt_reg.h"
|
||||
|
||||
+9
-1
@@ -27,6 +27,9 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Get PCNT attribute
|
||||
#define PCNT_LL_GET(attr) (PCNT_LL_ ## attr)
|
||||
|
||||
#define PCNT_LL_GET_HW(num) (((num) == 0) ? (&PCNT) : NULL)
|
||||
#define PCNT_LL_MAX_GLITCH_WIDTH 1023
|
||||
#define PCNT_LL_MAX_LIM SHRT_MAX
|
||||
@@ -42,6 +45,12 @@ typedef enum {
|
||||
PCNT_LL_WATCH_EVENT_MAX
|
||||
} pcnt_ll_watch_event_id_t;
|
||||
|
||||
// SoC-based capabilities
|
||||
#define PCNT_LL_INST_NUM 1 // Number of PCNT instances
|
||||
#define PCNT_LL_UNITS_PER_INST 4 // Number of units in each PCNT instance
|
||||
#define PCNT_LL_CHANS_PER_UNIT 2 // Number of channels in each PCNT unit
|
||||
#define PCNT_LL_THRES_POINT_PER_UNIT 2 // Number of threshold points in each PCNT unit
|
||||
|
||||
#define PCNT_LL_WATCH_EVENT_MASK ((1 << PCNT_LL_WATCH_EVENT_MAX) - 1)
|
||||
#define PCNT_LL_UNIT_WATCH_EVENT(unit_id) (1 << (unit_id))
|
||||
#define PCNT_LL_CLOCK_SUPPORT_APB 1
|
||||
@@ -491,7 +500,6 @@ static inline void pcnt_ll_reset_register(int group_id)
|
||||
pcnt_ll_reset_register(__VA_ARGS__); \
|
||||
} while(0)
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "soc/pcnt_periph.h"
|
||||
#include "hal/pcnt_periph.h"
|
||||
#include "soc/gpio_sig_map.h"
|
||||
|
||||
const soc_pcnt_signal_desc_t soc_pcnt_signals[1] = {
|
||||
+9
@@ -26,6 +26,9 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Get PCNT attribute
|
||||
#define PCNT_LL_GET(attr) (PCNT_LL_ ## attr)
|
||||
|
||||
#define PCNT_LL_GET_HW(num) (((num) == 0) ? (&PCNT) : NULL)
|
||||
#define PCNT_LL_MAX_GLITCH_WIDTH 1023
|
||||
#define PCNT_LL_MAX_LIM SHRT_MAX
|
||||
@@ -41,6 +44,12 @@ typedef enum {
|
||||
PCNT_LL_WATCH_EVENT_MAX
|
||||
} pcnt_ll_watch_event_id_t;
|
||||
|
||||
// SoC-based capabilities
|
||||
#define PCNT_LL_INST_NUM 1 // Number of PCNT instances
|
||||
#define PCNT_LL_UNITS_PER_INST 4 // Number of units in each PCNT instance
|
||||
#define PCNT_LL_CHANS_PER_UNIT 2 // Number of channels in each PCNT unit
|
||||
#define PCNT_LL_THRES_POINT_PER_UNIT 2 // Number of threshold points in each PCNT unit
|
||||
|
||||
#define PCNT_LL_WATCH_EVENT_MASK ((1 << PCNT_LL_WATCH_EVENT_MAX) - 1)
|
||||
#define PCNT_LL_UNIT_WATCH_EVENT(unit_id) (1 << (unit_id))
|
||||
#define PCNT_LL_CLOCK_SUPPORT_APB 1
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "soc/pcnt_periph.h"
|
||||
#include "hal/pcnt_periph.h"
|
||||
#include "soc/gpio_sig_map.h"
|
||||
|
||||
const soc_pcnt_signal_desc_t soc_pcnt_signals[1] = {
|
||||
+7
-7
@@ -8,11 +8,11 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "soc/soc_caps_full.h"
|
||||
#include "soc/soc_caps.h"
|
||||
#include "soc/interrupts.h"
|
||||
|
||||
// helper macros to access module attributes
|
||||
#define SOC_PCNT_ATTR(_attr) SOC_MODULE_ATTR(PCNT, _attr)
|
||||
#if SOC_HAS(PCNT)
|
||||
#include "hal/pcnt_ll.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -26,13 +26,13 @@ typedef struct {
|
||||
struct {
|
||||
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)];
|
||||
} channels[PCNT_LL_GET(CHANS_PER_UNIT)];
|
||||
const int clear_sig_id_matrix; // clear signal ID in the GPIO matrix
|
||||
} units[SOC_PCNT_ATTR(UNITS_PER_INST)];
|
||||
} units[PCNT_LL_GET(UNITS_PER_INST)];
|
||||
const int irq_id; // interrupt source ID
|
||||
} soc_pcnt_signal_desc_t;
|
||||
|
||||
extern const soc_pcnt_signal_desc_t soc_pcnt_signals[SOC_PCNT_ATTR(INST_NUM)];
|
||||
extern const soc_pcnt_signal_desc_t soc_pcnt_signals[PCNT_LL_GET(INST_NUM)];
|
||||
|
||||
#endif // SOC_HAS(PCNT)
|
||||
|
||||
@@ -82,6 +82,7 @@ else()
|
||||
esp_hal_wdt
|
||||
esp_hal_lcd
|
||||
esp_hal_mcpwm
|
||||
esp_hal_pcnt
|
||||
LDFRAGMENTS "linker.lf" "app.lf")
|
||||
add_subdirectory(port)
|
||||
|
||||
|
||||
@@ -111,10 +111,6 @@ elseif(NOT BOOTLOADER_BUILD)
|
||||
list(APPEND srcs "rmt_hal.c")
|
||||
endif()
|
||||
|
||||
if(CONFIG_SOC_PCNT_SUPPORTED)
|
||||
list(APPEND srcs "pcnt_hal.c")
|
||||
endif()
|
||||
|
||||
if(CONFIG_SOC_UHCI_SUPPORTED)
|
||||
list(APPEND srcs "uhci_hal.c")
|
||||
endif()
|
||||
|
||||
@@ -92,10 +92,6 @@ if(CONFIG_SOC_LEDC_SUPPORTED)
|
||||
list(APPEND srcs "${target_folder}/ledc_periph.c")
|
||||
endif()
|
||||
|
||||
if(CONFIG_SOC_PCNT_SUPPORTED)
|
||||
list(APPEND srcs "${target_folder}/pcnt_periph.c")
|
||||
endif()
|
||||
|
||||
if(CONFIG_SOC_RMT_SUPPORTED)
|
||||
list(APPEND srcs "${target_folder}/rmt_periph.c")
|
||||
endif()
|
||||
|
||||
@@ -13,12 +13,6 @@
|
||||
#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
|
||||
|
||||
/*------------------------------- I2S ---------------------------------------*/
|
||||
// helper macros to access module attributes
|
||||
#define _SOC_CAPS_I2S_INST_NUM 2 // Number of I2S instances
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "soc/pcnt_periph.h"
|
||||
#include "hal/pcnt_periph.h"
|
||||
#include "soc/gpio_sig_map.h"
|
||||
#include "soc/soc.h"
|
||||
|
||||
|
||||
@@ -17,12 +17,6 @@
|
||||
#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
|
||||
|
||||
/*------------------------------- I2S ---------------------------------------*/
|
||||
// helper macros to access module attributes
|
||||
#define _SOC_CAPS_I2S_INST_NUM 1 // Number of I2S instances
|
||||
|
||||
@@ -17,12 +17,6 @@
|
||||
#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
|
||||
|
||||
/*------------------------------- I2S ---------------------------------------*/
|
||||
// helper macros to access module attributes
|
||||
#define _SOC_CAPS_I2S_INST_NUM 1 // Number of I2S instances
|
||||
|
||||
@@ -17,12 +17,6 @@
|
||||
#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
|
||||
|
||||
/*------------------------------- I2S ---------------------------------------*/
|
||||
// helper macros to access module attributes
|
||||
#define _SOC_CAPS_I2S_INST_NUM 1 // Number of I2S instances
|
||||
|
||||
@@ -13,12 +13,6 @@
|
||||
#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
|
||||
|
||||
/*------------------------------- I2S ---------------------------------------*/
|
||||
// helper macros to access module attributes
|
||||
// #define _SOC_CAPS_I2S_INST_NUM 1 // Number of I2S instances
|
||||
|
||||
@@ -13,12 +13,6 @@
|
||||
#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
|
||||
|
||||
/*------------------------------- I2S ---------------------------------------*/
|
||||
// helper macros to access module attributes
|
||||
#define _SOC_CAPS_I2S_INST_NUM 1 // Number of I2S instances
|
||||
|
||||
@@ -17,12 +17,6 @@
|
||||
#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
|
||||
|
||||
/*------------------------------- I2S ---------------------------------------*/
|
||||
// helper macros to access module attributes
|
||||
#define _SOC_CAPS_I2S_INST_NUM 3 // Number of I2S instances
|
||||
|
||||
@@ -13,12 +13,6 @@
|
||||
#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
|
||||
|
||||
/*------------------------------- Dedicated GPIO ------------------------------*/
|
||||
#define _SOC_CAPS_DEDIC_GPIO_OUT_CHANS_PER_CPU 8 /*!< 8 outward channels on each CPU core */
|
||||
#define _SOC_CAPS_DEDIC_GPIO_IN_CHANS_PER_CPU 8 /*!< 8 inward channels on each CPU core */
|
||||
|
||||
@@ -13,12 +13,6 @@
|
||||
#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
|
||||
|
||||
/*------------------------------- Dedicated GPIO ------------------------------*/
|
||||
#define _SOC_CAPS_DEDIC_GPIO_OUT_CHANS_PER_CPU 8 /*!< 8 outward channels on each CPU core */
|
||||
#define _SOC_CAPS_DEDIC_GPIO_IN_CHANS_PER_CPU 8 /*!< 8 inward channels on each CPU core */
|
||||
|
||||
@@ -260,7 +260,7 @@ INPUT = \
|
||||
$(PROJECT_PATH)/components/hal/include/hal/ledc_types.h \
|
||||
$(PROJECT_PATH)/components/hal/include/hal/mcpwm_types.h \
|
||||
$(PROJECT_PATH)/components/hal/include/hal/parlio_types.h \
|
||||
$(PROJECT_PATH)/components/hal/include/hal/pcnt_types.h \
|
||||
$(PROJECT_PATH)/components/esp_hal_pcnt/include/hal/pcnt_types.h \
|
||||
$(PROJECT_PATH)/components/hal/include/hal/rmt_types.h \
|
||||
$(PROJECT_PATH)/components/hal/include/hal/rtc_io_types.h \
|
||||
$(PROJECT_PATH)/components/hal/include/hal/sdio_slave_types.h \
|
||||
|
||||
Reference in New Issue
Block a user