Merge branch 'feature/sdm_driver_esp32p4' into 'master'

esp_driver_sdm driver support on esp32p4

Closes IDF-7551

See merge request espressif/esp-idf!27543
This commit is contained in:
morris 2023-12-01 17:21:04 +08:00
commit 2d4a6748a3
30 changed files with 173 additions and 60 deletions

View File

@ -12,14 +12,13 @@ set(includes "deprecated"
"i2c/include"
"ledc/include"
"parlio/include"
"sigma_delta/include"
"touch_sensor/include"
"twai/include"
"uart/include"
"usb_serial_jtag/include")
# Always included linker fragments
set(ldfragments "linker.lf")
set(ldfragments "")
# ADC related source files (dprecated)
if(CONFIG_SOC_ADC_SUPPORTED)
@ -86,10 +85,9 @@ if(CONFIG_SOC_RMT_SUPPORTED)
list(APPEND srcs "deprecated/rmt_legacy.c")
endif()
# Sigma-Delta Modulation related source files
# Sigma-Delta Modulation legacy driver
if(CONFIG_SOC_SDM_SUPPORTED)
list(APPEND srcs "sigma_delta/sdm.c"
"deprecated/sigma_delta_legacy.c")
list(APPEND srcs "deprecated/sigma_delta_legacy.c")
endif()
# Temperature Sensor related source files
@ -144,7 +142,7 @@ else()
# have a public dependency on other "esp_driver_foo" components
esp_driver_gpio esp_driver_pcnt esp_driver_gptimer esp_driver_spi esp_driver_mcpwm
esp_driver_ana_cmpr esp_driver_i2s esp_driver_sdmmc esp_driver_sdspi esp_driver_sdio
esp_driver_dac esp_driver_rmt esp_driver_tsens
esp_driver_dac esp_driver_rmt esp_driver_tsens esp_driver_sdm
LDFRAGMENTS ${ldfragments}
)
endif()

View File

@ -66,32 +66,6 @@ menu "Driver Configurations"
orsource "./uart/Kconfig.uart"
menu "Sigma Delta Modulator Configuration"
depends on SOC_SDM_SUPPORTED
config SDM_CTRL_FUNC_IN_IRAM
bool "Place SDM control functions into IRAM"
default n
help
Place SDM control functions (like set_duty) into IRAM,
so that these functions can be IRAM-safe and able to be called in the other IRAM interrupt context.
Enabling this option can improve driver performance as well.
config SDM_SUPPRESS_DEPRECATE_WARN
bool "Suppress legacy driver deprecated warning"
default n
help
Wether to suppress the deprecation warnings when using legacy sigma delta driver.
If you want to continue using the legacy driver, and don't want to see related deprecation warnings,
you can enable this option.
config SDM_ENABLE_DEBUG_LOG
bool "Enable debug log"
default n
help
Wether to enable the debug log message for SDM driver.
Note that, this option only controls the SDM driver log, won't affect other drivers.
endmenu # Sigma Delta Modulator Configuration
menu "USB Serial/JTAG Configuration"
depends on SOC_USB_SERIAL_JTAG_SUPPORTED
config USJ_NO_AUTO_LS_ON_CONNECTION

View File

@ -62,7 +62,7 @@ components/driver/test_apps/legacy_sigma_delta_driver:
disable:
- if: SOC_SDM_SUPPORTED != 1
depends_filepatterns:
- components/driver/deprecated/**/*
- components/driver/deprecated/**/*sigma*
depends_components:
- esp_driver_gpio
@ -88,14 +88,6 @@ components/driver/test_apps/rs485:
temporary: true
reason: lack of runners
components/driver/test_apps/sigma_delta:
disable:
- if: SOC_SDM_SUPPORTED != 1
depends_filepatterns:
- components/driver/sigma_delta/**/*
depends_components:
- esp_driver_gpio
components/driver/test_apps/touch_sensor_v1:
disable:
- if: SOC_TOUCH_SENSOR_VERSION != 1

View File

@ -1,2 +1,2 @@
| Supported Targets | ESP32 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-S2 | ESP32-S3 |
| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- |
| Supported Targets | ESP32 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-P4 | ESP32-S2 | ESP32-S3 |
| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- |

View File

@ -0,0 +1,11 @@
set(srcs)
set(public_include "include")
if(CONFIG_SOC_SDM_SUPPORTED)
list(APPEND srcs "src/sdm.c")
endif()
idf_component_register(SRCS ${srcs}
INCLUDE_DIRS ${public_include}
PRIV_REQUIRES "esp_pm" "esp_driver_gpio"
LDFRAGMENTS "linker.lf"
)

View File

@ -0,0 +1,25 @@
menu "ESP-Driver:Sigma Delta Modulator Configurations"
depends on SOC_SDM_SUPPORTED
config SDM_CTRL_FUNC_IN_IRAM
bool "Place SDM control functions into IRAM"
default n
help
Place SDM control functions (like set_duty) into IRAM,
so that these functions can be IRAM-safe and able to be called in the other IRAM interrupt context.
Enabling this option can improve driver performance as well.
config SDM_SUPPRESS_DEPRECATE_WARN
bool "Suppress legacy driver deprecated warning"
default n
help
Wether to suppress the deprecation warnings when using legacy sigma delta driver.
If you want to continue using the legacy driver, and don't want to see related deprecation warnings,
you can enable this option.
config SDM_ENABLE_DEBUG_LOG
bool "Enable debug log"
default n
help
Wether to enable the debug log message for SDM driver.
Note that, this option only controls the SDM driver log, won't affect other drivers.
endmenu # Sigma Delta Modulator Configurations

View File

@ -1,5 +1,5 @@
[mapping:driver]
archive: libdriver.a
[mapping:sdm_driver]
archive: libesp_driver_sdm.a
entries:
if SDM_CTRL_FUNC_IN_IRAM = y:
sdm: sdm_channel_set_pulse_density (noflash)

View File

@ -210,7 +210,7 @@ esp_err_t sdm_new_channel(const sdm_config_t *config, sdm_channel_handle_t *ret_
ESP_GOTO_ON_FALSE(group->clk_src == 0 || group->clk_src == config->clk_src, ESP_ERR_INVALID_ARG, err, TAG, "clock source conflict");
uint32_t src_clk_hz = 0;
ESP_GOTO_ON_ERROR(esp_clk_tree_src_get_freq_hz((soc_module_clk_t)config->clk_src,
ESP_CLK_TREE_SRC_FREQ_PRECISION_CACHED, &src_clk_hz), err, TAG, "get source clock frequency failed");
ESP_CLK_TREE_SRC_FREQ_PRECISION_CACHED, &src_clk_hz), err, TAG, "get source clock frequency failed");
#if CONFIG_PM_ENABLE
esp_pm_lock_type_t pm_type = ESP_PM_NO_LIGHT_SLEEP;

View File

@ -0,0 +1,8 @@
# Documentation: .gitlab/ci/README.md#manifest-file-to-control-the-buildtest-apps
components/esp_driver_sdm/test_apps/sigma_delta:
disable:
- if: SOC_SDM_SUPPORTED != 1
depends_components:
- esp_driver_gpio
- esp_driver_sdm

View File

@ -10,7 +10,7 @@ project(sigma_delta_test)
if(CONFIG_COMPILER_DUMP_RTL_FILES)
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/driver/,${CMAKE_BINARY_DIR}/esp-idf/hal/
--rtl-dirs ${CMAKE_BINARY_DIR}/esp-idf/esp_driver_sdm/,${CMAKE_BINARY_DIR}/esp-idf/hal/
--elf-file ${CMAKE_BINARY_DIR}/sigma_delta_test.elf
find-refs
--from-sections=.iram0.text

View File

@ -1,2 +1,2 @@
| Supported Targets | ESP32 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-S2 | ESP32-S3 |
| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- |
| Supported Targets | ESP32 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-P4 | ESP32-S2 | ESP32-S3 |
| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- |

View File

@ -7,5 +7,5 @@ endif()
# In order for the cases defined by `TEST_CASE` to be linked into the final elf,
# the component can be registered as WHOLE_ARCHIVE
idf_component_register(SRCS ${srcs}
PRIV_REQUIRES unity driver
PRIV_REQUIRES unity esp_driver_sdm
WHOLE_ARCHIVE)

View File

@ -0,0 +1,58 @@
/*
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include <stdbool.h>
#include "hal/misc.h"
#include "hal/assert.h"
#include "soc/gpio_ext_struct.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Set Sigma-delta enable
*
* @param hw Peripheral SIGMADELTA hardware instance address.
* @param en Sigma-delta enable value
*/
static inline void sdm_ll_enable_clock(gpio_sd_dev_t *hw, bool en)
{
hw->misc.function_clk_en = en;
}
/**
* @brief Set Sigma-delta channel duty.
*
* @param hw Peripheral SIGMADELTA hardware instance address.
* @param channel Sigma-delta channel number
* @param density Sigma-delta quantized density of one channel, the value ranges from -128 to 127, recommended range is -90 ~ 90.
* The waveform is more like a random one in this range.
*/
__attribute__((always_inline))
static inline void sdm_ll_set_pulse_density(gpio_sd_dev_t *hw, int channel, int8_t density)
{
HAL_FORCE_MODIFY_U32_REG_FIELD(hw->channel[channel], duty, (uint32_t)density);
}
/**
* @brief Set Sigma-delta channel's clock pre-scale value.
*
* @param hw Peripheral SIGMADELTA hardware instance address.
* @param channel Sigma-delta channel number
* @param prescale The divider of source clock, ranges from 1 to 256
*/
static inline void sdm_ll_set_prescale(gpio_sd_dev_t *hw, int channel, uint32_t prescale)
{
HAL_ASSERT(prescale && prescale <= 256);
HAL_FORCE_MODIFY_U32_REG_FIELD(hw->channel[channel], prescale, prescale - 1);
}
#ifdef __cplusplus
}
#endif

View File

@ -87,6 +87,10 @@ config SOC_I2S_SUPPORTED
bool
default y
config SOC_SDM_SUPPORTED
bool
default y
config SOC_GPSPI_SUPPORTED
bool
default y
@ -909,7 +913,7 @@ config SOC_SDM_GROUPS
config SOC_SDM_CHANNELS_PER_GROUP
int
default 4
default 8
config SOC_SDM_CLK_SUPPORT_PLL_F80M
bool

View File

@ -477,7 +477,21 @@ typedef enum {
ISP_CLK_SRC_PLL240 = SOC_MOD_CLK_PLL_F240M, /*!< Select SOC_MOD_CLK_PLL_F240M as ISP source clock */
} soc_periph_isp_clk_src_t;
//////////////////////////////////////////////////SDM//////////////////////////////////////////////////////////////
//////////////////////////////////////////////////SDM///////////////////////////////////////////////////////////////////
/**
* @brief Array initializer for all supported clock sources of SDM
*/
#define SOC_SDM_CLKS {SOC_MOD_CLK_PLL_F80M, SOC_MOD_CLK_XTAL}
/**
* @brief Sigma Delta Modulator clock source
*/
typedef enum {
SDM_CLK_SRC_XTAL = SOC_MOD_CLK_XTAL, /*!< Select XTAL clock as the source clock */
SDM_CLK_SRC_PLL_F80M = SOC_MOD_CLK_PLL_F80M, /*!< Select PLL_F80M clock as the source clock */
SDM_CLK_SRC_DEFAULT = SOC_MOD_CLK_PLL_F80M, /*!< Select PLL_F80M clock as the default clock choice */
} soc_periph_sdm_clk_src_t;
//////////////////////////////////////////////////GPIO Glitch Filter////////////////////////////////////////////////////

View File

@ -49,7 +49,7 @@
#define SOC_RTC_MEM_SUPPORTED 1
#define SOC_RMT_SUPPORTED 1
#define SOC_I2S_SUPPORTED 1
// #define SOC_SDM_SUPPORTED 1 //TODO: IDF-7551
#define SOC_SDM_SUPPORTED 1
#define SOC_GPSPI_SUPPORTED 1
#define SOC_LEDC_SUPPORTED 1
#define SOC_I2C_SUPPORTED 1 //TODO: IDF-6507, TODO: IDF-7491
@ -408,7 +408,7 @@
/*-------------------------- Sigma Delta Modulator CAPS -----------------*/
#define SOC_SDM_GROUPS 1U
#define SOC_SDM_CHANNELS_PER_GROUP 4
#define SOC_SDM_CHANNELS_PER_GROUP 8
#define SOC_SDM_CLK_SUPPORT_PLL_F80M 1
#define SOC_SDM_CLK_SUPPORT_XTAL 1

View File

@ -8,5 +8,30 @@
#include "soc/gpio_sig_map.h"
const sigma_delta_signal_conn_t sigma_delta_periph_signals = {
.channels = {
[0] = {
GPIO_SD0_OUT_IDX
},
[1] = {
GPIO_SD1_OUT_IDX
},
[2] = {
GPIO_SD2_OUT_IDX
},
[3] = {
GPIO_SD3_OUT_IDX
},
[4] = {
GPIO_SD4_OUT_IDX
},
[5] = {
GPIO_SD5_OUT_IDX
},
[6] = {
GPIO_SD6_OUT_IDX
},
[7] = {
GPIO_SD7_OUT_IDX
}
}
};

View File

@ -79,7 +79,6 @@ INPUT = \
$(PROJECT_PATH)/components/driver/ledc/include/driver/ledc.h \
$(PROJECT_PATH)/components/driver/parlio/include/driver/parlio_tx.h \
$(PROJECT_PATH)/components/driver/parlio/include/driver/parlio_types.h \
$(PROJECT_PATH)/components/driver/sigma_delta/include/driver/sdm.h \
$(PROJECT_PATH)/components/driver/touch_sensor/include/driver/touch_sensor_common.h \
$(PROJECT_PATH)/components/driver/twai/include/driver/twai.h \
$(PROJECT_PATH)/components/driver/uart/include/driver/uart.h \
@ -134,6 +133,7 @@ INPUT = \
$(PROJECT_PATH)/components/esp_driver_rmt/include/driver/rmt_tx.h \
$(PROJECT_PATH)/components/esp_driver_rmt/include/driver/rmt_types.h \
$(PROJECT_PATH)/components/esp_driver_sdio/include/driver/sdio_slave.h \
$(PROJECT_PATH)/components/esp_driver_sdm/include/driver/sdm.h \
$(PROJECT_PATH)/components/esp_driver_sdmmc/include/driver/sdmmc_default_configs.h \
$(PROJECT_PATH)/components/esp_driver_sdmmc/include/driver/sdmmc_host.h \
$(PROJECT_PATH)/components/esp_driver_sdmmc/include/driver/sdmmc_types.h \

View File

@ -18,6 +18,7 @@ In order to control the dependence of other components on drivers at a smaller g
- `esp_driver_dac` - Driver for DAC
- `esp_driver_rmt` - Driver for RMT
- `esp_driver_tsens` - Driver for Temperature Sensor
- `esp_driver_sdm` - Driver for Sigma-Delta Modulator
For compatibility, the original `driver`` component is still treated as an all-in-one component by registering these `esp_driver_xyz`` components as its public dependencies. In other words, you do not need to modify the CMake file of an existing project, but you now have a way to specify the specific peripheral driver that your project depends on.

View File

@ -18,6 +18,7 @@
- `esp_driver_dac` - DAC 驱动
- `esp_driver_rmt` - RMT 驱动
- `esp_driver_tsens` - 温度传感器驱动
- `esp_driver_sdm` - Sigma-Delta 调制器驱动
为了兼容性,原来的 `driver` 组件仍然存在,并作为一个 “all-in-one" 的组件,将以上这些 `esp_driver_xyz` 组件注册成自己的公共依赖。换句话说,你无需修改既有项目的 CMake 文件,但是你现在多了一个途径去指定你项目依赖的具体的外设驱动。

View File

@ -290,6 +290,8 @@ examples/peripherals/secure_element/atecc608_ecdsa:
examples/peripherals/sigma_delta:
disable:
- if: SOC_SDM_SUPPORTED != 1
depends_components:
- esp_driver_sdm
examples/peripherals/spi_master/hd_eeprom:
disable:

View File

@ -1,5 +1,5 @@
| Supported Targets | ESP32 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-S2 | ESP32-S3 |
| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- |
| Supported Targets | ESP32 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-P4 | ESP32-S2 | ESP32-S3 |
| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- |
# Sigma Delta Modulation DAC Example

View File

@ -1,5 +1,5 @@
| Supported Targets | ESP32 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-S2 | ESP32-S3 |
| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- |
| Supported Targets | ESP32 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-P4 | ESP32-S2 | ESP32-S3 |
| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- |
# Sigma Delta Modulation LED Example