mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-04 13:14:32 +02:00
remove(legacy_sdm): remove legacy sdm driver in IDF v6.0
This commit is contained in:
@@ -26,11 +26,6 @@ if(CONFIG_SOC_RMT_SUPPORTED)
|
|||||||
list(APPEND srcs "deprecated/rmt_legacy.c")
|
list(APPEND srcs "deprecated/rmt_legacy.c")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Sigma-Delta Modulation legacy driver
|
|
||||||
if(CONFIG_SOC_SDM_SUPPORTED)
|
|
||||||
list(APPEND srcs "deprecated/sigma_delta_legacy.c")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Touch Sensor related source files
|
# Touch Sensor related source files
|
||||||
if(CONFIG_SOC_TOUCH_SENSOR_SUPPORTED)
|
if(CONFIG_SOC_TOUCH_SENSOR_SUPPORTED)
|
||||||
if(CONFIG_SOC_TOUCH_SENSOR_VERSION LESS 3)
|
if(CONFIG_SOC_TOUCH_SENSOR_VERSION LESS 3)
|
||||||
|
@@ -28,23 +28,6 @@ menu "Driver Configurations"
|
|||||||
This configuration option allows the user to bypass the conflict check mechanism with legacy code.
|
This configuration option allows the user to bypass the conflict check mechanism with legacy code.
|
||||||
endmenu # Legacy I2C Driver Configurationss
|
endmenu # Legacy I2C Driver Configurationss
|
||||||
|
|
||||||
menu "Legacy SDM Driver Configurations"
|
|
||||||
depends on SOC_SDM_SUPPORTED
|
|
||||||
config SDM_SUPPRESS_DEPRECATE_WARN
|
|
||||||
bool "Suppress legacy driver deprecated warning"
|
|
||||||
default n
|
|
||||||
help
|
|
||||||
whether to suppress the deprecation warnings when using legacy SDM driver (driver/sigmadelta.h).
|
|
||||||
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_SKIP_LEGACY_CONFLICT_CHECK
|
|
||||||
bool "Skip legacy conflict check"
|
|
||||||
default n
|
|
||||||
help
|
|
||||||
This configuration option allows the user to bypass the conflict check mechanism with legacy code.
|
|
||||||
endmenu # Legacy SDM Driver Configurationss
|
|
||||||
|
|
||||||
menu "Legacy Touch Sensor Driver Configurations"
|
menu "Legacy Touch Sensor Driver Configurations"
|
||||||
depends on SOC_TOUCH_SENSOR_SUPPORTED
|
depends on SOC_TOUCH_SENSOR_SUPPORTED
|
||||||
config TOUCH_SUPPRESS_DEPRECATE_WARN
|
config TOUCH_SUPPRESS_DEPRECATE_WARN
|
||||||
|
@@ -1,82 +0,0 @@
|
|||||||
/*
|
|
||||||
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include "esp_err.h"
|
|
||||||
#include "driver/gpio.h"
|
|
||||||
#include "driver/sigmadelta_types_legacy.h"
|
|
||||||
|
|
||||||
#if !CONFIG_SDM_SUPPRESS_DEPRECATE_WARN
|
|
||||||
#warning "The legacy sigma-delta driver is deprecated, please use driver/sdm.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Configure Sigma-delta channel
|
|
||||||
*
|
|
||||||
* @param config Pointer of Sigma-delta channel configuration struct
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
* - ESP_OK Success
|
|
||||||
* - ESP_ERR_INVALID_STATE sigmadelta driver already initialized
|
|
||||||
* - ESP_ERR_INVALID_ARG Parameter error
|
|
||||||
*/
|
|
||||||
esp_err_t sigmadelta_config(const sigmadelta_config_t *config);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Set Sigma-delta channel duty.
|
|
||||||
*
|
|
||||||
* This function is used to set Sigma-delta channel duty,
|
|
||||||
* If you add a capacitor between the output pin and ground,
|
|
||||||
* the average output voltage will be Vdc = VDDIO / 256 * duty + VDDIO/2,
|
|
||||||
* where VDDIO is the power supply voltage.
|
|
||||||
*
|
|
||||||
* @param channel Sigma-delta channel number
|
|
||||||
* @param duty Sigma-delta duty 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.
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
* - ESP_OK Success
|
|
||||||
* - ESP_ERR_INVALID_STATE sigmadelta driver has not been initialized
|
|
||||||
* - ESP_ERR_INVALID_ARG Parameter error
|
|
||||||
*/
|
|
||||||
esp_err_t sigmadelta_set_duty(sigmadelta_channel_t channel, int8_t duty);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Set Sigma-delta channel's clock pre-scale value.
|
|
||||||
* The source clock is APP_CLK, 80MHz. The clock frequency of the sigma-delta channel is APP_CLK / pre_scale
|
|
||||||
*
|
|
||||||
* @param channel Sigma-delta channel number
|
|
||||||
* @param prescale The divider of source clock, ranges from 0 to 255
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
* - ESP_OK Success
|
|
||||||
* - ESP_ERR_INVALID_STATE sigmadelta driver has not been initialized
|
|
||||||
* - ESP_ERR_INVALID_ARG Parameter error
|
|
||||||
*/
|
|
||||||
esp_err_t sigmadelta_set_prescale(sigmadelta_channel_t channel, uint8_t prescale);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Set Sigma-delta signal output pin
|
|
||||||
*
|
|
||||||
* @param channel Sigma-delta channel number
|
|
||||||
* @param gpio_num GPIO number of output pin.
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
* - ESP_OK Success
|
|
||||||
* - ESP_ERR_INVALID_STATE sigmadelta driver has not been initialized
|
|
||||||
* - ESP_ERR_INVALID_ARG Parameter error
|
|
||||||
*/
|
|
||||||
esp_err_t sigmadelta_set_pin(sigmadelta_channel_t channel, gpio_num_t gpio_num);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
@@ -1,54 +0,0 @@
|
|||||||
/*
|
|
||||||
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include "soc/soc_caps.h"
|
|
||||||
#include "driver/gpio.h" // for gpio_num_t type define
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief SIGMADELTA port number, the max port number is (SIGMADELTA_NUM_MAX -1).
|
|
||||||
*/
|
|
||||||
typedef enum {
|
|
||||||
SIGMADELTA_PORT_0, /*!< SIGMADELTA port 0 */
|
|
||||||
SIGMADELTA_PORT_MAX, /*!< SIGMADELTA port max */
|
|
||||||
} sigmadelta_port_t;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Sigma-delta channel list
|
|
||||||
*/
|
|
||||||
typedef enum {
|
|
||||||
SIGMADELTA_CHANNEL_0, /*!< Sigma-delta channel 0 */
|
|
||||||
SIGMADELTA_CHANNEL_1, /*!< Sigma-delta channel 1 */
|
|
||||||
SIGMADELTA_CHANNEL_2, /*!< Sigma-delta channel 2 */
|
|
||||||
SIGMADELTA_CHANNEL_3, /*!< Sigma-delta channel 3 */
|
|
||||||
#if SOC_SDM_CHANNELS_PER_GROUP > 4
|
|
||||||
SIGMADELTA_CHANNEL_4, /*!< Sigma-delta channel 4 */
|
|
||||||
SIGMADELTA_CHANNEL_5, /*!< Sigma-delta channel 5 */
|
|
||||||
SIGMADELTA_CHANNEL_6, /*!< Sigma-delta channel 6 */
|
|
||||||
SIGMADELTA_CHANNEL_7, /*!< Sigma-delta channel 7 */
|
|
||||||
#endif
|
|
||||||
SIGMADELTA_CHANNEL_MAX, /*!< Sigma-delta channel max */
|
|
||||||
} sigmadelta_channel_t;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Sigma-delta configure struct
|
|
||||||
*/
|
|
||||||
typedef struct {
|
|
||||||
sigmadelta_channel_t channel; /*!< Sigma-delta channel number */
|
|
||||||
int8_t sigmadelta_duty; /*!< Sigma-delta duty, duty ranges from -128 to 127. */
|
|
||||||
uint8_t sigmadelta_prescale; /*!< Sigma-delta prescale, prescale ranges from 0 to 255. */
|
|
||||||
gpio_num_t sigmadelta_gpio; /*!< Sigma-delta output io number, refer to gpio.h for more details. */
|
|
||||||
} sigmadelta_config_t;
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
@@ -1,149 +0,0 @@
|
|||||||
/*
|
|
||||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "esp_log.h"
|
|
||||||
#include "esp_check.h"
|
|
||||||
#include "esp_err.h"
|
|
||||||
#include "esp_heap_caps.h"
|
|
||||||
#include "driver/gpio.h"
|
|
||||||
#include "driver/sigmadelta_types_legacy.h"
|
|
||||||
#include "soc/sdm_periph.h"
|
|
||||||
#include "hal/sdm_hal.h"
|
|
||||||
#include "hal/sdm_ll.h"
|
|
||||||
#include "hal/gpio_hal.h"
|
|
||||||
#include "esp_rom_gpio.h"
|
|
||||||
#include "esp_private/gpio.h"
|
|
||||||
|
|
||||||
static const char *TAG = "sdm(legacy)";
|
|
||||||
|
|
||||||
#define SIGMADELTA_CHECK(a,str,ret_val) ESP_RETURN_ON_FALSE(a, ret_val, TAG, "%s", str)
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
sdm_hal_context_t hal; /*!< SIGMADELTA hal context*/
|
|
||||||
} sigmadelta_obj_t;
|
|
||||||
|
|
||||||
static sigmadelta_obj_t *p_sigmadelta_obj[SIGMADELTA_PORT_MAX] = {0};
|
|
||||||
|
|
||||||
#define SIGMADELTA_OBJ_CHECK(sigmadelta_port) { \
|
|
||||||
SIGMADELTA_CHECK((sigmadelta_port < SIGMADELTA_PORT_MAX), "sigmadelta port error", ESP_ERR_INVALID_ARG); \
|
|
||||||
SIGMADELTA_CHECK((p_sigmadelta_obj[sigmadelta_port]), "sigmadelta driver has not been initialized", ESP_ERR_INVALID_STATE); \
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline esp_err_t _sigmadelta_set_duty(sigmadelta_port_t sigmadelta_port, sigmadelta_channel_t channel, int8_t duty)
|
|
||||||
{
|
|
||||||
SIGMADELTA_OBJ_CHECK(sigmadelta_port);
|
|
||||||
|
|
||||||
sdm_ll_set_pulse_density(p_sigmadelta_obj[sigmadelta_port]->hal.dev, channel, duty);
|
|
||||||
return ESP_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline esp_err_t _sigmadelta_set_prescale(sigmadelta_port_t sigmadelta_port, sigmadelta_channel_t channel, uint8_t prescale)
|
|
||||||
{
|
|
||||||
SIGMADELTA_OBJ_CHECK(sigmadelta_port);
|
|
||||||
|
|
||||||
sdm_ll_set_prescale(p_sigmadelta_obj[sigmadelta_port]->hal.dev, channel, prescale + 1);
|
|
||||||
return ESP_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline esp_err_t _sigmadelta_set_pin(sigmadelta_port_t sigmadelta_port, sigmadelta_channel_t channel, gpio_num_t gpio_num)
|
|
||||||
{
|
|
||||||
SIGMADELTA_OBJ_CHECK(sigmadelta_port);
|
|
||||||
|
|
||||||
gpio_func_sel(gpio_num, PIN_FUNC_GPIO);
|
|
||||||
gpio_set_direction(gpio_num, GPIO_MODE_OUTPUT);
|
|
||||||
esp_rom_gpio_connect_out_signal(gpio_num, sigma_delta_periph_signals.channels[channel].sd_sig, 0, 0);
|
|
||||||
return ESP_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline esp_err_t _sigmadelta_config(sigmadelta_port_t sigmadelta_port, const sigmadelta_config_t *config)
|
|
||||||
{
|
|
||||||
SIGMADELTA_OBJ_CHECK(sigmadelta_port);
|
|
||||||
|
|
||||||
_sigmadelta_set_duty(sigmadelta_port, config->channel, config->sigmadelta_duty);
|
|
||||||
_sigmadelta_set_prescale(sigmadelta_port, config->channel, config->sigmadelta_prescale);
|
|
||||||
_sigmadelta_set_pin(sigmadelta_port, config->channel, config->sigmadelta_gpio);
|
|
||||||
return ESP_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
esp_err_t sigmadelta_deinit(sigmadelta_port_t sigmadelta_port)
|
|
||||||
{
|
|
||||||
SIGMADELTA_OBJ_CHECK(sigmadelta_port);
|
|
||||||
|
|
||||||
heap_caps_free(p_sigmadelta_obj[sigmadelta_port]);
|
|
||||||
p_sigmadelta_obj[sigmadelta_port] = NULL;
|
|
||||||
return ESP_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
esp_err_t sigmadelta_init(sigmadelta_port_t sigmadelta_port)
|
|
||||||
{
|
|
||||||
SIGMADELTA_CHECK((sigmadelta_port < SIGMADELTA_PORT_MAX), "sigmadelta_port error", ESP_ERR_INVALID_ARG);
|
|
||||||
SIGMADELTA_CHECK((p_sigmadelta_obj[sigmadelta_port]) == NULL, "sigmadelta driver already initialized", ESP_ERR_INVALID_STATE);
|
|
||||||
|
|
||||||
p_sigmadelta_obj[sigmadelta_port] = (sigmadelta_obj_t *) heap_caps_calloc(1, sizeof(sigmadelta_obj_t), MALLOC_CAP_DEFAULT);
|
|
||||||
|
|
||||||
if (p_sigmadelta_obj[sigmadelta_port] == NULL) {
|
|
||||||
ESP_LOGE(TAG, "TAG driver malloc error");
|
|
||||||
return ESP_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
sdm_hal_init(&(p_sigmadelta_obj[sigmadelta_port]->hal), sigmadelta_port);
|
|
||||||
sdm_ll_enable_clock(p_sigmadelta_obj[sigmadelta_port]->hal.dev, true);
|
|
||||||
return ESP_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: The following functions are wrappers, for compatibility with current API.
|
|
||||||
|
|
||||||
esp_err_t sigmadelta_set_duty(sigmadelta_channel_t channel, int8_t duty)
|
|
||||||
{
|
|
||||||
SIGMADELTA_CHECK(channel < SIGMADELTA_CHANNEL_MAX, "sigmadelta channel error", ESP_ERR_INVALID_ARG);
|
|
||||||
return _sigmadelta_set_duty(SIGMADELTA_PORT_0, channel, duty);
|
|
||||||
}
|
|
||||||
|
|
||||||
esp_err_t sigmadelta_set_prescale(sigmadelta_channel_t channel, uint8_t prescale)
|
|
||||||
{
|
|
||||||
SIGMADELTA_CHECK(channel < SIGMADELTA_CHANNEL_MAX, "sigmadelta channel error", ESP_ERR_INVALID_ARG);
|
|
||||||
return _sigmadelta_set_prescale(SIGMADELTA_PORT_0, channel, prescale);
|
|
||||||
}
|
|
||||||
|
|
||||||
esp_err_t sigmadelta_set_pin(sigmadelta_channel_t channel, gpio_num_t gpio_num)
|
|
||||||
{
|
|
||||||
SIGMADELTA_CHECK(channel < SIGMADELTA_CHANNEL_MAX, "sigmadelta channel error", ESP_ERR_INVALID_ARG);
|
|
||||||
SIGMADELTA_CHECK(GPIO_IS_VALID_OUTPUT_GPIO(gpio_num), "sigmadelta gpio num error", ESP_ERR_INVALID_ARG);
|
|
||||||
return _sigmadelta_set_pin(SIGMADELTA_PORT_0, channel, gpio_num);
|
|
||||||
}
|
|
||||||
|
|
||||||
esp_err_t sigmadelta_config(const sigmadelta_config_t *config)
|
|
||||||
{
|
|
||||||
SIGMADELTA_CHECK(config->channel < SIGMADELTA_CHANNEL_MAX, "sigmadelta channel error", ESP_ERR_INVALID_ARG);
|
|
||||||
SIGMADELTA_CHECK(GPIO_IS_VALID_OUTPUT_GPIO(config->sigmadelta_gpio), "sigmadelta gpio num error", ESP_ERR_INVALID_ARG);
|
|
||||||
esp_err_t ret;
|
|
||||||
|
|
||||||
if ((p_sigmadelta_obj[SIGMADELTA_PORT_0]) == NULL) {
|
|
||||||
ret = sigmadelta_init(SIGMADELTA_PORT_0);
|
|
||||||
if (ret != ESP_OK) {
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return _sigmadelta_config(SIGMADELTA_PORT_0, config);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if !CONFIG_SDM_SKIP_LEGACY_CONFLICT_CHECK
|
|
||||||
/**
|
|
||||||
* @brief This function will be called during start up, to check that sdm driver is not running along with the legacy sdm driver
|
|
||||||
*/
|
|
||||||
__attribute__((constructor))
|
|
||||||
static void check_sdm_driver_conflict(void)
|
|
||||||
{
|
|
||||||
// This function was declared as weak here. sdm driver has one implementation.
|
|
||||||
// So if sdm driver is not linked in, then `sdm_new_channel` should be NULL at runtime.
|
|
||||||
extern __attribute__((weak)) esp_err_t sdm_new_channel(const void *config, void **ret_unit);
|
|
||||||
if ((void *)sdm_new_channel != NULL) {
|
|
||||||
ESP_EARLY_LOGE(TAG, "CONFLICT! driver_ng is not allowed to be used with the legacy driver");
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
ESP_EARLY_LOGW(TAG, "legacy driver is deprecated, please migrate to `driver/sdm.h`");
|
|
||||||
}
|
|
||||||
#endif //CONFIG_PCNT_SKIP_LEGACY_CONFLICT_CHECK
|
|
@@ -14,14 +14,6 @@ components/driver/test_apps/legacy_rmt_driver:
|
|||||||
depends_filepatterns:
|
depends_filepatterns:
|
||||||
- components/driver/deprecated/**/*rmt*
|
- components/driver/deprecated/**/*rmt*
|
||||||
|
|
||||||
components/driver/test_apps/legacy_sigma_delta_driver:
|
|
||||||
disable:
|
|
||||||
- if: SOC_SDM_SUPPORTED != 1
|
|
||||||
depends_filepatterns:
|
|
||||||
- components/driver/deprecated/**/*sigma*
|
|
||||||
depends_components:
|
|
||||||
- esp_driver_gpio
|
|
||||||
|
|
||||||
components/driver/test_apps/legacy_twai:
|
components/driver/test_apps/legacy_twai:
|
||||||
disable:
|
disable:
|
||||||
- if: SOC_TWAI_SUPPORTED != 1 or SOC_TWAI_SUPPORT_FD == 1
|
- if: SOC_TWAI_SUPPORTED != 1 or SOC_TWAI_SUPPORT_FD == 1
|
||||||
|
@@ -1,8 +0,0 @@
|
|||||||
# This is the project CMakeLists.txt file for the test subproject
|
|
||||||
cmake_minimum_required(VERSION 3.16)
|
|
||||||
|
|
||||||
# "Trim" the build. Include the minimal set of components, main, and anything it depends on.
|
|
||||||
set(COMPONENTS main)
|
|
||||||
|
|
||||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
|
||||||
project(legacy_sigma_delta_driver_test)
|
|
@@ -1,2 +0,0 @@
|
|||||||
| Supported Targets | ESP32 | ESP32-C3 | ESP32-C5 | ESP32-C6 | ESP32-H2 | ESP32-P4 | ESP32-S2 | ESP32-S3 |
|
|
||||||
| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- | -------- |
|
|
@@ -1,11 +0,0 @@
|
|||||||
set(srcs "test_app_main.c")
|
|
||||||
|
|
||||||
if(CONFIG_SOC_SDM_SUPPORTED)
|
|
||||||
list(APPEND srcs "test_sigma_delta_legacy.c")
|
|
||||||
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 esp_driver_gpio
|
|
||||||
WHOLE_ARCHIVE)
|
|
@@ -1,41 +0,0 @@
|
|||||||
/*
|
|
||||||
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "unity.h"
|
|
||||||
#include "unity_test_runner.h"
|
|
||||||
#include "esp_heap_caps.h"
|
|
||||||
|
|
||||||
// Some resources are lazy allocated in gpio/dedicated_gpio/delta_sigma driver, the threshold is left for that case
|
|
||||||
#define TEST_MEMORY_LEAK_THRESHOLD (-400)
|
|
||||||
|
|
||||||
static size_t before_free_8bit;
|
|
||||||
static size_t before_free_32bit;
|
|
||||||
|
|
||||||
static void check_leak(size_t before_free, size_t after_free, const char *type)
|
|
||||||
{
|
|
||||||
ssize_t delta = after_free - before_free;
|
|
||||||
printf("MALLOC_CAP_%s: Before %u bytes free, After %u bytes free (delta %d)\n", type, before_free, after_free, delta);
|
|
||||||
TEST_ASSERT_MESSAGE(delta >= TEST_MEMORY_LEAK_THRESHOLD, "memory leak");
|
|
||||||
}
|
|
||||||
|
|
||||||
void setUp(void)
|
|
||||||
{
|
|
||||||
before_free_8bit = heap_caps_get_free_size(MALLOC_CAP_8BIT);
|
|
||||||
before_free_32bit = heap_caps_get_free_size(MALLOC_CAP_32BIT);
|
|
||||||
}
|
|
||||||
|
|
||||||
void tearDown(void)
|
|
||||||
{
|
|
||||||
size_t after_free_8bit = heap_caps_get_free_size(MALLOC_CAP_8BIT);
|
|
||||||
size_t after_free_32bit = heap_caps_get_free_size(MALLOC_CAP_32BIT);
|
|
||||||
check_leak(before_free_8bit, after_free_8bit, "8BIT");
|
|
||||||
check_leak(before_free_32bit, after_free_32bit, "32BIT");
|
|
||||||
}
|
|
||||||
|
|
||||||
void app_main(void)
|
|
||||||
{
|
|
||||||
unity_run_menu();
|
|
||||||
}
|
|
@@ -1,65 +0,0 @@
|
|||||||
/*
|
|
||||||
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "freertos/FreeRTOS.h"
|
|
||||||
#include "freertos/task.h"
|
|
||||||
#include "unity.h"
|
|
||||||
#include "soc/soc_caps.h"
|
|
||||||
#include "driver/sigmadelta.h"
|
|
||||||
|
|
||||||
TEST_CASE("SigmaDelta_config_test", "[sigma_delta]")
|
|
||||||
{
|
|
||||||
sigmadelta_config_t sigmadelta_cfg = {
|
|
||||||
.sigmadelta_prescale = 80,
|
|
||||||
.sigmadelta_duty = 45,
|
|
||||||
.sigmadelta_gpio = 4,
|
|
||||||
};
|
|
||||||
for (int i = 0; i < SIGMADELTA_CHANNEL_MAX; i++) {
|
|
||||||
sigmadelta_cfg.channel = i;
|
|
||||||
TEST_ESP_OK(sigmadelta_config(&sigmadelta_cfg));
|
|
||||||
}
|
|
||||||
|
|
||||||
sigmadelta_cfg.channel = SIGMADELTA_CHANNEL_MAX;
|
|
||||||
TEST_ASSERT_EQUAL_MESSAGE(ESP_ERR_INVALID_ARG, sigmadelta_config(&sigmadelta_cfg), "wrong channel number should be inspected");
|
|
||||||
}
|
|
||||||
|
|
||||||
// connect GPIO4 with LED positive pin, and the GND pin connect LED negative pin
|
|
||||||
// logic analyzer help also to see the wave form(more standard and accurate)
|
|
||||||
TEST_CASE("SigmaDelta_pin_duty_prescale_set", "[sigma_delta]")
|
|
||||||
{
|
|
||||||
sigmadelta_config_t sigmadelta_cfg = {
|
|
||||||
.channel = 0,
|
|
||||||
.sigmadelta_prescale = 80,
|
|
||||||
.sigmadelta_duty = 0,
|
|
||||||
.sigmadelta_gpio = 4,
|
|
||||||
};
|
|
||||||
TEST_ESP_OK(sigmadelta_config(&sigmadelta_cfg));
|
|
||||||
|
|
||||||
int8_t duty = 0;
|
|
||||||
int inc = 1;
|
|
||||||
for (int i = 0; i < 100; i++) {
|
|
||||||
sigmadelta_set_duty(sigmadelta_cfg.channel, duty);
|
|
||||||
vTaskDelay(10 / portTICK_PERIOD_MS);
|
|
||||||
|
|
||||||
duty += inc;
|
|
||||||
if (duty == 127 || duty == -127) {
|
|
||||||
inc = (-1) * inc;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_ESP_OK(sigmadelta_set_prescale(0, 200));
|
|
||||||
for (int i = 0; i < 100; i++) {
|
|
||||||
sigmadelta_set_duty(sigmadelta_cfg.channel, duty);
|
|
||||||
vTaskDelay(10 / portTICK_PERIOD_MS);
|
|
||||||
|
|
||||||
duty += inc;
|
|
||||||
if (duty == 127 || duty == -127) {
|
|
||||||
inc = (-1) * inc;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_ESP_OK(sigmadelta_set_pin(sigmadelta_cfg.channel, 5));
|
|
||||||
}
|
|
@@ -1,22 +0,0 @@
|
|||||||
# SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
|
|
||||||
# SPDX-License-Identifier: CC0-1.0
|
|
||||||
import pytest
|
|
||||||
from pytest_embedded_idf import IdfDut
|
|
||||||
from pytest_embedded_idf.utils import idf_parametrize
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.generic
|
|
||||||
@pytest.mark.parametrize(
|
|
||||||
'config',
|
|
||||||
[
|
|
||||||
'release',
|
|
||||||
],
|
|
||||||
indirect=True,
|
|
||||||
)
|
|
||||||
@idf_parametrize(
|
|
||||||
'target',
|
|
||||||
['esp32', 'esp32c3', 'esp32c5', 'esp32c6', 'esp32h2', 'esp32s2', 'esp32s3', 'esp32p4'],
|
|
||||||
indirect=['target'],
|
|
||||||
)
|
|
||||||
def test_legacy_sigma_delta(dut: IdfDut) -> None:
|
|
||||||
dut.run_all_single_board_cases(group='sigma_delta')
|
|
@@ -1,5 +0,0 @@
|
|||||||
CONFIG_PM_ENABLE=y
|
|
||||||
CONFIG_FREERTOS_USE_TICKLESS_IDLE=y
|
|
||||||
CONFIG_COMPILER_OPTIMIZATION_SIZE=y
|
|
||||||
CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y
|
|
||||||
CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y
|
|
@@ -1,3 +0,0 @@
|
|||||||
CONFIG_FREERTOS_HZ=1000
|
|
||||||
CONFIG_ESP_TASK_WDT_EN=n
|
|
||||||
CONFIG_SDM_SUPPRESS_DEPRECATE_WARN=y
|
|
@@ -91,15 +91,17 @@ GPIO
|
|||||||
|
|
||||||
.. only:: SOC_SDM_SUPPORTED
|
.. only:: SOC_SDM_SUPPORTED
|
||||||
|
|
||||||
Sigma-Delta Modulator
|
.. _deprecate_sdm_legacy_driver:
|
||||||
---------------------
|
|
||||||
|
Legacy Sigma-Delta Modulator Driver is Deprecated
|
||||||
|
-------------------------------------------------
|
||||||
|
|
||||||
The Sigma-Delta Modulator driver has been redesigned into :doc:`SDM <../../../api-reference/peripherals/sdm>`.
|
The Sigma-Delta Modulator driver has been redesigned into :doc:`SDM <../../../api-reference/peripherals/sdm>`.
|
||||||
|
|
||||||
- The new driver implements a factory pattern, where the SDM channels are managed in a pool internally, thus users do not have to fix a SDM channel to a GPIO manually.
|
- The new driver implements a factory pattern, where the SDM channels are managed in a pool internally, thus users do not have to fix a SDM channel to a GPIO manually.
|
||||||
- All SDM channels can be allocated dynamically.
|
- All SDM channels can be allocated dynamically.
|
||||||
|
|
||||||
Although it is recommended to use the new driver APIs, the legacy driver is still available in the previous include path ``driver/sigmadelta.h``. However, by default, including ``driver/sigmadelta.h`` triggers the build warning below. The warning can be suppressed by Kconfig option :ref:`CONFIG_SDM_SUPPRESS_DEPRECATE_WARN`.
|
Although it is recommended to use the new driver APIs, the legacy driver is still available in the previous include path ``driver/sigmadelta.h``. However, by default, including ``driver/sigmadelta.h`` triggers the build warning below. The warning can be suppressed by Kconfig option ``CONFIG_SDM_SUPPRESS_DEPRECATE_WARN``.
|
||||||
|
|
||||||
.. code-block:: text
|
.. code-block:: text
|
||||||
|
|
||||||
@@ -122,9 +124,7 @@ GPIO
|
|||||||
- Channel configuration was done by channel allocation, in :cpp:func:`sdm_new_channel`. In the new driver, only the ``density`` can be changed at runtime, by :cpp:func:`sdm_channel_set_pulse_density`. Other parameters like ``gpio number`` and ``prescale`` are only allowed to set during channel allocation.
|
- Channel configuration was done by channel allocation, in :cpp:func:`sdm_new_channel`. In the new driver, only the ``density`` can be changed at runtime, by :cpp:func:`sdm_channel_set_pulse_density`. Other parameters like ``gpio number`` and ``prescale`` are only allowed to set during channel allocation.
|
||||||
- Before further channel operations, users should **enable** the channel in advance, by calling :cpp:func:`sdm_channel_enable`. This function helps to manage some system level services, like **Power Management**.
|
- Before further channel operations, users should **enable** the channel in advance, by calling :cpp:func:`sdm_channel_enable`. This function helps to manage some system level services, like **Power Management**.
|
||||||
|
|
||||||
.. _deprecate_gptimer_legacy_driver:
|
.. only:: SOC_GPTIMER_SUPPORTED
|
||||||
|
|
||||||
.. only:: not SOC_SDM_SUPPORTED
|
|
||||||
|
|
||||||
.. _deprecate_gptimer_legacy_driver:
|
.. _deprecate_gptimer_legacy_driver:
|
||||||
|
|
||||||
|
@@ -116,3 +116,10 @@ SDMMC
|
|||||||
-------------------------------------------
|
-------------------------------------------
|
||||||
|
|
||||||
The legacy temperature sensor driver ``driver/temp_sensor.h`` is deprecated since version 5.0 (see :ref:`deprecate_tsens_legacy_driver`). Starting from version 6.0, the legacy driver is completely removed. The new driver is placed in the :component:`esp_driver_tsens`, and the header file path is ``driver/temperature_sensor.h``.
|
The legacy temperature sensor driver ``driver/temp_sensor.h`` is deprecated since version 5.0 (see :ref:`deprecate_tsens_legacy_driver`). Starting from version 6.0, the legacy driver is completely removed. The new driver is placed in the :component:`esp_driver_tsens`, and the header file path is ``driver/temperature_sensor.h``.
|
||||||
|
|
||||||
|
.. only:: SOC_SDM_SUPPORTED
|
||||||
|
|
||||||
|
Legacy Sigma-Delta Modulator Driver is Removed
|
||||||
|
----------------------------------------------
|
||||||
|
|
||||||
|
The legacy Sigma-Delta Modulator driver ``driver/sigmadelta.h`` is deprecated since version 5.0 (see :ref:`deprecate_sdm_legacy_driver`). Starting from version 6.0, the legacy driver is completely removed. The new driver is placed in the :component:`esp_driver_sdm`, and the header file path is ``driver/sdm.h``.
|
||||||
|
@@ -90,15 +90,17 @@ GPIO
|
|||||||
|
|
||||||
.. only:: SOC_SDM_SUPPORTED
|
.. only:: SOC_SDM_SUPPORTED
|
||||||
|
|
||||||
Sigma-Delta 调制器
|
.. _deprecate_sdm_legacy_driver:
|
||||||
---------------------------------
|
|
||||||
|
旧版 Sigma-Delta 调制器驱动已被弃用
|
||||||
|
--------------------------------------------------
|
||||||
|
|
||||||
Sigma-Delta 调制器的驱动现已更新为 :doc:`SDM <../../../api-reference/peripherals/sdm>`。
|
Sigma-Delta 调制器的驱动现已更新为 :doc:`SDM <../../../api-reference/peripherals/sdm>`。
|
||||||
|
|
||||||
- 新驱动中实现了工厂模式,SDM 通道都位于内部通道池中,因此用户无需手动将 SDM 通道配置到 GPIO 管脚。
|
- 新驱动中实现了工厂模式,SDM 通道都位于内部通道池中,因此用户无需手动将 SDM 通道配置到 GPIO 管脚。
|
||||||
- SDM 通道会被自动分配。
|
- SDM 通道会被自动分配。
|
||||||
|
|
||||||
尽管我们推荐用户使用新的驱动 API,旧版驱动仍然可用,位于头文件引用路径 ``driver/sigmadelta.h`` 中。但是,引用 ``driver/sigmadelta.h`` 会默认触发如下编译警告,可通过配置 Kconfig 选项 :ref:`CONFIG_SDM_SUPPRESS_DEPRECATE_WARN` 关闭该警告。
|
尽管我们推荐用户使用新的驱动 API,旧版驱动仍然可用,位于头文件引用路径 ``driver/sigmadelta.h`` 中。但是,引用 ``driver/sigmadelta.h`` 会默认触发如下编译警告,可通过配置 Kconfig 选项 ``CONFIG_SDM_SUPPRESS_DEPRECATE_WARN`` 关闭该警告。
|
||||||
|
|
||||||
.. code-block:: text
|
.. code-block:: text
|
||||||
|
|
||||||
@@ -121,9 +123,7 @@ GPIO
|
|||||||
- 更新前,通道配置由通道分配在 :cpp:func:`sdm_new_channel` 完成。在新驱动中,只有 ``density`` 可在运行时由 :cpp:func:`sdm_channel_set_pulse_density` 更新。其他参数如 ``gpio number``、 ``prescale`` 只能在通道分配时进行设置。
|
- 更新前,通道配置由通道分配在 :cpp:func:`sdm_new_channel` 完成。在新驱动中,只有 ``density`` 可在运行时由 :cpp:func:`sdm_channel_set_pulse_density` 更新。其他参数如 ``gpio number``、 ``prescale`` 只能在通道分配时进行设置。
|
||||||
- 在进行下一步通道操作前,用户应通过调用 :cpp:func:`sdm_channel_enable` 提前 **使能** 该通道。该函数有助于管理一些系统级服务,如 **电源管理**。
|
- 在进行下一步通道操作前,用户应通过调用 :cpp:func:`sdm_channel_enable` 提前 **使能** 该通道。该函数有助于管理一些系统级服务,如 **电源管理**。
|
||||||
|
|
||||||
.. _deprecate_gptimer_legacy_driver:
|
.. only:: SOC_GPTIMER_SUPPORTED
|
||||||
|
|
||||||
.. only:: not SOC_SDM_SUPPORTED
|
|
||||||
|
|
||||||
.. _deprecate_gptimer_legacy_driver:
|
.. _deprecate_gptimer_legacy_driver:
|
||||||
|
|
||||||
|
@@ -115,3 +115,10 @@ SDMMC
|
|||||||
------------------------------------
|
------------------------------------
|
||||||
|
|
||||||
旧版的温度传感器驱动 ``driver/temp_sensor.h`` 在 5.1 的版本中就已经被弃用(请参考 :ref:`deprecate_tsens_legacy_driver`)。从 6.0 版本开始,旧版驱动被完全移除。新驱动位于 :component:`esp_driver_tsens` 组件中,头文件引用路径为 ``driver/temperature_sensor.h``。
|
旧版的温度传感器驱动 ``driver/temp_sensor.h`` 在 5.1 的版本中就已经被弃用(请参考 :ref:`deprecate_tsens_legacy_driver`)。从 6.0 版本开始,旧版驱动被完全移除。新驱动位于 :component:`esp_driver_tsens` 组件中,头文件引用路径为 ``driver/temperature_sensor.h``。
|
||||||
|
|
||||||
|
.. only:: SOC_SDM_SUPPORTED
|
||||||
|
|
||||||
|
旧版 Sigma-Delta 调制器驱动被移除
|
||||||
|
---------------------------------
|
||||||
|
|
||||||
|
旧版的 Sigma-Delta 调制器驱动 ``driver/sigmadelta.h`` 在 5.0 的版本中就已经被弃用(请参考 :ref:`deprecate_sdm_legacy_driver`)。从 6.0 版本开始,旧版驱动被完全移除。新驱动位于 :component:`esp_driver_sdm` 组件中,头文件引用路径为 ``driver/sdm.h``。
|
||||||
|
@@ -519,3 +519,6 @@
|
|||||||
-
|
-
|
||||||
re_variables: ['driver/mcpwm.h']
|
re_variables: ['driver/mcpwm.h']
|
||||||
hint_variables: ['legacy MCPWM', 'driver/mcpwm_prelude', 'esp_driver_mcpwm']
|
hint_variables: ['legacy MCPWM', 'driver/mcpwm_prelude', 'esp_driver_mcpwm']
|
||||||
|
-
|
||||||
|
re_variables: ['driver/sigmadelta.h']
|
||||||
|
hint_variables: ['legacy Sigma-Delta', 'driver/sdm.h', 'esp_driver_sdm']
|
||||||
|
Reference in New Issue
Block a user