mirror of
https://github.com/espressif/esp-idf.git
synced 2026-08-18 06:35:35 +03:00
Merge branch 'feat/tsens_slp_esp32h4' into 'master'
feat(temperature_sensor): Add temperature sensor sleep retention support on esp32h4 Closes IDF-12405, IDF-15617, and IDF-15648 See merge request espressif/esp-idf!48703
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
idf_build_get_property(target IDF_TARGET)
|
||||
|
||||
set(srcs)
|
||||
set(priv_req efuse)
|
||||
set(public_include "include")
|
||||
@@ -6,10 +8,15 @@ if(CONFIG_SOC_TEMP_SENSOR_SUPPORTED)
|
||||
if(CONFIG_SOC_TEMPERATURE_SENSOR_SUPPORT_ETM)
|
||||
list(APPEND srcs "src/temperature_sensor_etm.c")
|
||||
endif()
|
||||
if(CONFIG_SOC_PAU_SUPPORTED AND CONFIG_SOC_TEMPERATURE_SENSOR_SUPPORT_SLEEP_RETENTION
|
||||
AND CONFIG_SOC_TEMPERATURE_SENSOR_UNDER_PD_TOP_DOMAIN)
|
||||
list(APPEND srcs "${target}/temperature_sensor_retention.c")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
idf_component_register(SRCS ${srcs}
|
||||
INCLUDE_DIRS ${public_include}
|
||||
PRIV_INCLUDE_DIRS "src"
|
||||
REQUIRES esp_hal_ana_conv
|
||||
PRIV_REQUIRES ${priv_req}
|
||||
)
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "soc/regdma.h"
|
||||
#include "soc/apb_saradc_reg.h"
|
||||
#include "temperature_sensor_private.h"
|
||||
|
||||
// Temperature sensor sleep retention entries
|
||||
// Temperature sensor registers require set the reg_update bit to make the configuration take effect
|
||||
|
||||
/* Temperature sensor Registers Context
|
||||
Include: APB_SARADC_INT_ENA_REG /
|
||||
APB_SARADC_APB_TSENS_CTRL_REG / APB_SARADC_TSENS_CTRL2_REG / APB_TSENS_WAKE_REG / APB_TSENS_SAMPLE_REG
|
||||
*/
|
||||
#define TEMPERATURE_SENSOR_RETENTION_REGS_CNT 5
|
||||
#define TEMPERATURE_SENSOR_RETENTION_MAP_BASE APB_SARADC_INT_ENA_REG
|
||||
static const uint32_t temperature_sensor_regs_map[4] = {0x6c1, 0, 0, 0};
|
||||
static const regdma_entries_config_t temperature_sensor_regs_entries[] = {
|
||||
[0] = {
|
||||
.config = REGDMA_LINK_ADDR_MAP_INIT(REGDMA_TSENS_LINK(0x00), TEMPERATURE_SENSOR_RETENTION_MAP_BASE, TEMPERATURE_SENSOR_RETENTION_MAP_BASE, TEMPERATURE_SENSOR_RETENTION_REGS_CNT, 0, 0, temperature_sensor_regs_map[0], temperature_sensor_regs_map[1], temperature_sensor_regs_map[2], temperature_sensor_regs_map[3]), \
|
||||
.owner = ENTRY(0) | ENTRY(2)
|
||||
}, \
|
||||
};
|
||||
|
||||
const temperature_sensor_reg_ctx_link_t temperature_sensor_regs_retention = {
|
||||
.link_list = temperature_sensor_regs_entries,
|
||||
.link_num = ARRAY_SIZE(temperature_sensor_regs_entries),
|
||||
.module_id = SLEEP_RETENTION_MODULE_TEMP_SENSOR,
|
||||
};
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "soc/regdma.h"
|
||||
#include "soc/apb_saradc_reg.h"
|
||||
#include "temperature_sensor_private.h"
|
||||
|
||||
// Temperature sensor sleep retention entries
|
||||
// Temperature sensor registers require set the reg_update bit to make the configuration take effect
|
||||
|
||||
/* Temperature sensor Registers Context
|
||||
Include: APB_SARADC_INT_ENA_REG /
|
||||
APB_SARADC_APB_TSENS_CTRL_REG / APB_SARADC_TSENS_CTRL2_REG / APB_TSENS_WAKE_REG / APB_TSENS_SAMPLE_REG
|
||||
*/
|
||||
#define TEMPERATURE_SENSOR_RETENTION_REGS_CNT 5
|
||||
#define TEMPERATURE_SENSOR_RETENTION_MAP_BASE APB_SARADC_INT_ENA_REG
|
||||
static const uint32_t temperature_sensor_regs_map[4] = {0x6c1, 0, 0, 0};
|
||||
static const regdma_entries_config_t temperature_sensor_regs_entries[] = {
|
||||
[0] = {
|
||||
.config = REGDMA_LINK_ADDR_MAP_INIT(REGDMA_TSENS_LINK(0x00), TEMPERATURE_SENSOR_RETENTION_MAP_BASE, TEMPERATURE_SENSOR_RETENTION_MAP_BASE, TEMPERATURE_SENSOR_RETENTION_REGS_CNT, 0, 0, temperature_sensor_regs_map[0], temperature_sensor_regs_map[1], temperature_sensor_regs_map[2], temperature_sensor_regs_map[3]), \
|
||||
.owner = ENTRY(0) | ENTRY(2)
|
||||
}, \
|
||||
};
|
||||
|
||||
const temperature_sensor_reg_ctx_link_t temperature_sensor_regs_retention = {
|
||||
.link_list = temperature_sensor_regs_entries,
|
||||
.link_num = ARRAY_SIZE(temperature_sensor_regs_entries),
|
||||
.module_id = SLEEP_RETENTION_MODULE_TEMP_SENSOR,
|
||||
};
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "soc/regdma.h"
|
||||
#include "soc/apb_saradc_reg.h"
|
||||
#include "temperature_sensor_private.h"
|
||||
|
||||
// Temperature sensor sleep retention entries
|
||||
// Temperature sensor registers require set the reg_update bit to make the configuration take effect
|
||||
|
||||
/* Temperature sensor Registers Context
|
||||
Include: SARADC_INT_ENA_REG /
|
||||
APB_SARADC_APB_TSENS_CTRL_REG / APB_SARADC_TSENS_CTRL2_REG / APB_TSENS_WAKE_REG / APB_TSENS_SAMPLE_REG
|
||||
*/
|
||||
#define TEMPERATURE_SENSOR_RETENTION_REGS_CNT 5
|
||||
#define TEMPERATURE_SENSOR_RETENTION_MAP_BASE SARADC_INT_ENA_REG
|
||||
static const uint32_t temperature_sensor_regs_map[4] = {0x6c1, 0, 0, 0};
|
||||
static const regdma_entries_config_t temperature_sensor_regs_entries[] = {
|
||||
[0] = {
|
||||
.config = REGDMA_LINK_ADDR_MAP_INIT(REGDMA_TSENS_LINK(0x00), TEMPERATURE_SENSOR_RETENTION_MAP_BASE, TEMPERATURE_SENSOR_RETENTION_MAP_BASE, TEMPERATURE_SENSOR_RETENTION_REGS_CNT, 0, 0, temperature_sensor_regs_map[0], temperature_sensor_regs_map[1], temperature_sensor_regs_map[2], temperature_sensor_regs_map[3]), \
|
||||
.owner = ENTRY(0) | ENTRY(2)
|
||||
}, \
|
||||
};
|
||||
|
||||
const temperature_sensor_reg_ctx_link_t temperature_sensor_regs_retention = {
|
||||
.link_list = temperature_sensor_regs_entries,
|
||||
.link_num = ARRAY_SIZE(temperature_sensor_regs_entries),
|
||||
.module_id = SLEEP_RETENTION_MODULE_TEMP_SENSOR,
|
||||
};
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "soc/regdma.h"
|
||||
#include "soc/apb_saradc_reg.h"
|
||||
#include "temperature_sensor_private.h"
|
||||
|
||||
// Temperature sensor sleep retention entries
|
||||
// Temperature sensor registers require set the reg_update bit to make the configuration take effect
|
||||
|
||||
/* Temperature sensor Registers Context
|
||||
Include: APB_SARADC_INT_ENA_REG /
|
||||
APB_SARADC_APB_TSENS_CTRL_REG / APB_SARADC_TSENS_CTRL2_REG / APB_TSENS_WAKE_REG / APB_TSENS_SAMPLE_REG
|
||||
*/
|
||||
#define TEMPERATURE_SENSOR_RETENTION_REGS_CNT 5
|
||||
#define TEMPERATURE_SENSOR_RETENTION_MAP_BASE APB_SARADC_INT_ENA_REG
|
||||
static const uint32_t temperature_sensor_regs_map[4] = {0x6c1, 0, 0, 0};
|
||||
static const regdma_entries_config_t temperature_sensor_regs_entries[] = {
|
||||
[0] = {
|
||||
.config = REGDMA_LINK_ADDR_MAP_INIT(REGDMA_TSENS_LINK(0x00), TEMPERATURE_SENSOR_RETENTION_MAP_BASE, TEMPERATURE_SENSOR_RETENTION_MAP_BASE, TEMPERATURE_SENSOR_RETENTION_REGS_CNT, 0, 0, temperature_sensor_regs_map[0], temperature_sensor_regs_map[1], temperature_sensor_regs_map[2], temperature_sensor_regs_map[3]), \
|
||||
.owner = ENTRY(0) | ENTRY(2)
|
||||
}, \
|
||||
};
|
||||
|
||||
const temperature_sensor_reg_ctx_link_t temperature_sensor_regs_retention = {
|
||||
.link_list = temperature_sensor_regs_entries,
|
||||
.link_num = ARRAY_SIZE(temperature_sensor_regs_entries),
|
||||
.module_id = SLEEP_RETENTION_MODULE_TEMP_SENSOR,
|
||||
};
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "soc/regdma.h"
|
||||
#include "soc/apb_saradc_reg.h"
|
||||
#include "temperature_sensor_private.h"
|
||||
|
||||
// Temperature sensor sleep retention entries
|
||||
// Temperature sensor registers require set the reg_update bit to make the configuration take effect
|
||||
|
||||
/* Temperature sensor Registers Context
|
||||
Include: APB_SARADC_INT_ENA_REG /
|
||||
APB_SARADC_APB_TSENS_CTRL_REG / APB_SARADC_TSENS_CTRL2_REG / APB_TSENS_WAKE_REG / APB_TSENS_SAMPLE_REG
|
||||
*/
|
||||
#define TEMPERATURE_SENSOR_RETENTION_REGS_CNT 5
|
||||
#define TEMPERATURE_SENSOR_RETENTION_MAP_BASE APB_SARADC_INT_ENA_REG
|
||||
static const uint32_t temperature_sensor_regs_map[4] = {0x6c1, 0, 0, 0};
|
||||
static const regdma_entries_config_t temperature_sensor_regs_entries[] = {
|
||||
[0] = {
|
||||
.config = REGDMA_LINK_ADDR_MAP_INIT(REGDMA_TSENS_LINK(0x00), TEMPERATURE_SENSOR_RETENTION_MAP_BASE, TEMPERATURE_SENSOR_RETENTION_MAP_BASE, TEMPERATURE_SENSOR_RETENTION_REGS_CNT, 0, 0, temperature_sensor_regs_map[0], temperature_sensor_regs_map[1], temperature_sensor_regs_map[2], temperature_sensor_regs_map[3]), \
|
||||
.owner = ENTRY(0) | ENTRY(2)
|
||||
}, \
|
||||
};
|
||||
|
||||
const temperature_sensor_reg_ctx_link_t temperature_sensor_regs_retention = {
|
||||
.link_list = temperature_sensor_regs_entries,
|
||||
.link_num = ARRAY_SIZE(temperature_sensor_regs_entries),
|
||||
.module_id = SLEEP_RETENTION_MODULE_TEMP_SENSOR,
|
||||
};
|
||||
@@ -145,9 +145,6 @@ esp_err_t temperature_sensor_install(const temperature_sensor_config_t *tsens_co
|
||||
|
||||
#if !SOC_TEMPERATURE_SENSOR_SUPPORT_SLEEP_RETENTION
|
||||
ESP_RETURN_ON_FALSE(tsens_config->flags.allow_pd == 0, ESP_ERR_NOT_SUPPORTED, TAG, "not able to power down in light sleep");
|
||||
#if SOC_PM_SUPPORT_TOP_PD
|
||||
esp_sleep_pd_config(ESP_PD_DOMAIN_TOP, ESP_PD_OPTION_ON); //IDF-15648
|
||||
#endif
|
||||
#endif // SOC_TEMPERATURE_SENSOR_SUPPORT_SLEEP_RETENTION
|
||||
|
||||
#if SOC_TEMPERATURE_SENSOR_SUPPORT_SLEEP_RETENTION && !SOC_TEMPERATURE_SENSOR_UNDER_PD_TOP_DOMAIN
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2023-2026 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -7,11 +7,16 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "soc/soc_caps.h"
|
||||
#include "hal/temperature_sensor_periph.h"
|
||||
#include "hal/temperature_sensor_types.h"
|
||||
#include "driver/temperature_sensor.h"
|
||||
#include "esp_intr_alloc.h"
|
||||
#include "sdkconfig.h"
|
||||
#if SOC_TEMPERATURE_SENSOR_SUPPORT_SLEEP_RETENTION
|
||||
#include "soc/regdma.h"
|
||||
#include "soc/retention_periph_defs.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -33,6 +38,18 @@ typedef enum {
|
||||
// Use retention link only when the target supports sleep retention and PM is enabled
|
||||
#define TEMPERATURE_SENSOR_USE_RETENTION_LINK (SOC_TEMPERATURE_SENSOR_SUPPORT_SLEEP_RETENTION && CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP && SOC_TEMPERATURE_SENSOR_UNDER_PD_TOP_DOMAIN)
|
||||
|
||||
#if SOC_TEMPERATURE_SENSOR_SUPPORT_SLEEP_RETENTION
|
||||
// Sleep-retention RegDMA link descriptor exported by per-target
|
||||
// `<target>/temperature_sensor_retention.c`.
|
||||
typedef struct {
|
||||
const regdma_entries_config_t *link_list;
|
||||
uint32_t link_num;
|
||||
periph_retention_module_t module_id;
|
||||
} temperature_sensor_reg_ctx_link_t;
|
||||
|
||||
extern const temperature_sensor_reg_ctx_link_t temperature_sensor_regs_retention;
|
||||
#endif // SOC_TEMPERATURE_SENSOR_SUPPORT_SLEEP_RETENTION
|
||||
|
||||
typedef struct temperature_sensor_obj_t temperature_sensor_obj_t;
|
||||
|
||||
struct temperature_sensor_obj_t {
|
||||
|
||||
@@ -3,10 +3,6 @@
|
||||
components/esp_driver_tsens/test_apps/temperature_sensor:
|
||||
disable:
|
||||
- if: SOC_TEMP_SENSOR_SUPPORTED != 1
|
||||
disable_test:
|
||||
- if: IDF_TARGET in ["esp32h4"]
|
||||
temporary: true
|
||||
reason: cannot pass # TODO: IDF-15617
|
||||
depends_components:
|
||||
- esp_driver_tsens
|
||||
- esp_hal_ana_conv
|
||||
|
||||
@@ -20,7 +20,6 @@ from pytest_embedded_idf.utils import soc_filtered_targets
|
||||
soc_filtered_targets('SOC_TEMP_SENSOR_SUPPORTED == 1 and IDF_TARGET not in ["esp32c5"]'),
|
||||
indirect=['target'],
|
||||
)
|
||||
@pytest.mark.temp_skip_ci(targets=['esp32h4'], reason='cannot pass') # TODO: IDF-15617
|
||||
def test_temperature_sensor_driver(dut: Dut) -> None:
|
||||
dut.run_all_single_board_cases()
|
||||
|
||||
@@ -51,7 +50,9 @@ def test_temperature_sensor_driver_esp32c5_rev1(dut: Dut) -> None:
|
||||
],
|
||||
indirect=True,
|
||||
)
|
||||
@idf_parametrize('target', ['esp32c6', 'esp32h2', 'esp32p4', 'esp32c5', 'esp32c61', 'esp32s31'], indirect=['target'])
|
||||
@idf_parametrize(
|
||||
'target', ['esp32c6', 'esp32h2', 'esp32p4', 'esp32c5', 'esp32c61', 'esp32s31', 'esp32h4'], indirect=['target']
|
||||
)
|
||||
def test_temperature_sensor_cbs(dut: Dut) -> None:
|
||||
dut.run_all_single_board_cases()
|
||||
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2025-2026 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "soc/regdma.h"
|
||||
#include "hal/temperature_sensor_periph.h"
|
||||
#include "soc/apb_saradc_reg.h"
|
||||
|
||||
const temperature_sensor_attribute_t temperature_sensor_attributes[TEMPERATURE_SENSOR_ATTR_RANGE_NUM] = {
|
||||
/*Offset reg_val min max error */
|
||||
@@ -17,26 +14,3 @@ const temperature_sensor_attribute_t temperature_sensor_attributes[TEMPERATURE_S
|
||||
{ 1, 11, -30, 50, 2},
|
||||
{ 2, 10, -40, 20, 3},
|
||||
};
|
||||
|
||||
// Temperature sensor sleep retention entries
|
||||
// Temperature sensor registers require set the reg_update bit to make the configuration take effect
|
||||
|
||||
/* Temperature sensor Registers Context
|
||||
Include: APB_SARADC_INT_ENA_REG /
|
||||
APB_SARADC_APB_TSENS_CTRL_REG / APB_SARADC_TSENS_CTRL2_REG / APB_TSENS_WAKE_REG / APB_TSENS_SAMPLE_REG
|
||||
*/
|
||||
#define TEMPERATURE_SENSOR_RETENTION_REGS_CNT 5
|
||||
#define TEMPERATURE_SENSOR_RETENTION_MAP_BASE APB_SARADC_INT_ENA_REG
|
||||
static const uint32_t temperature_sensor_regs_map[4] = {0x6c1, 0, 0, 0};
|
||||
static const regdma_entries_config_t temperature_sensor_regs_entries[] = {
|
||||
[0] = {
|
||||
.config = REGDMA_LINK_ADDR_MAP_INIT(REGDMA_TSENS_LINK(0x00), TEMPERATURE_SENSOR_RETENTION_MAP_BASE, TEMPERATURE_SENSOR_RETENTION_MAP_BASE, TEMPERATURE_SENSOR_RETENTION_REGS_CNT, 0, 0, temperature_sensor_regs_map[0], temperature_sensor_regs_map[1], temperature_sensor_regs_map[2], temperature_sensor_regs_map[3]), \
|
||||
.owner = ENTRY(0) | ENTRY(2)
|
||||
}, \
|
||||
};
|
||||
|
||||
const temperature_sensor_reg_ctx_link_t temperature_sensor_regs_retention = {
|
||||
.link_list = temperature_sensor_regs_entries,
|
||||
.link_num = ARRAY_SIZE(temperature_sensor_regs_entries),
|
||||
.module_id = SLEEP_RETENTION_MODULE_TEMP_SENSOR,
|
||||
};
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2022-2026 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "soc/regdma.h"
|
||||
#include "hal/temperature_sensor_periph.h"
|
||||
#include "soc/apb_saradc_reg.h"
|
||||
|
||||
const temperature_sensor_attribute_t temperature_sensor_attributes[TEMPERATURE_SENSOR_ATTR_RANGE_NUM] = {
|
||||
/*Offset reg_val min max error */
|
||||
@@ -17,26 +14,3 @@ const temperature_sensor_attribute_t temperature_sensor_attributes[TEMPERATURE_S
|
||||
{ 1, 11, -30, 50, 2},
|
||||
{ 2, 10, -40, 20, 3},
|
||||
};
|
||||
|
||||
// Temperature sensor sleep retention entries
|
||||
// Temperature sensor registers require set the reg_update bit to make the configuration take effect
|
||||
|
||||
/* Temperature sensor Registers Context
|
||||
Include: APB_SARADC_INT_ENA_REG /
|
||||
APB_SARADC_APB_TSENS_CTRL_REG / APB_SARADC_TSENS_CTRL2_REG / APB_TSENS_WAKE_REG / APB_TSENS_SAMPLE_REG
|
||||
*/
|
||||
#define TEMPERATURE_SENSOR_RETENTION_REGS_CNT 5
|
||||
#define TEMPERATURE_SENSOR_RETENTION_MAP_BASE APB_SARADC_INT_ENA_REG
|
||||
static const uint32_t temperature_sensor_regs_map[4] = {0x6c1, 0, 0, 0};
|
||||
static const regdma_entries_config_t temperature_sensor_regs_entries[] = {
|
||||
[0] = {
|
||||
.config = REGDMA_LINK_ADDR_MAP_INIT(REGDMA_TSENS_LINK(0x00), TEMPERATURE_SENSOR_RETENTION_MAP_BASE, TEMPERATURE_SENSOR_RETENTION_MAP_BASE, TEMPERATURE_SENSOR_RETENTION_REGS_CNT, 0, 0, temperature_sensor_regs_map[0], temperature_sensor_regs_map[1], temperature_sensor_regs_map[2], temperature_sensor_regs_map[3]), \
|
||||
.owner = ENTRY(0) | ENTRY(2)
|
||||
}, \
|
||||
};
|
||||
|
||||
const temperature_sensor_reg_ctx_link_t temperature_sensor_regs_retention = {
|
||||
.link_list = temperature_sensor_regs_entries,
|
||||
.link_num = ARRAY_SIZE(temperature_sensor_regs_entries),
|
||||
.module_id = SLEEP_RETENTION_MODULE_TEMP_SENSOR,
|
||||
};
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2025-2026 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "soc/regdma.h"
|
||||
#include "hal/temperature_sensor_periph.h"
|
||||
#include "soc/apb_saradc_reg.h"
|
||||
|
||||
const temperature_sensor_attribute_t temperature_sensor_attributes[TEMPERATURE_SENSOR_ATTR_RANGE_NUM] = {
|
||||
/*Offset reg_val min max error */
|
||||
@@ -17,26 +14,3 @@ const temperature_sensor_attribute_t temperature_sensor_attributes[TEMPERATURE_S
|
||||
{ 1, 11, -30, 50, 2},
|
||||
{ 2, 10, -40, 20, 3},
|
||||
};
|
||||
|
||||
// Temperature sensor sleep retention entries
|
||||
// Temperature sensor registers require set the reg_update bit to make the configuration take effect
|
||||
|
||||
/* Temperature sensor Registers Context
|
||||
Include: SARADC_INT_ENA_REG /
|
||||
APB_SARADC_APB_TSENS_CTRL_REG / APB_SARADC_TSENS_CTRL2_REG / APB_TSENS_WAKE_REG / APB_TSENS_SAMPLE_REG
|
||||
*/
|
||||
#define TEMPERATURE_SENSOR_RETENTION_REGS_CNT 5
|
||||
#define TEMPERATURE_SENSOR_RETENTION_MAP_BASE SARADC_INT_ENA_REG
|
||||
static const uint32_t temperature_sensor_regs_map[4] = {0x6c1, 0, 0, 0};
|
||||
static const regdma_entries_config_t temperature_sensor_regs_entries[] = {
|
||||
[0] = {
|
||||
.config = REGDMA_LINK_ADDR_MAP_INIT(REGDMA_TSENS_LINK(0x00), TEMPERATURE_SENSOR_RETENTION_MAP_BASE, TEMPERATURE_SENSOR_RETENTION_MAP_BASE, TEMPERATURE_SENSOR_RETENTION_REGS_CNT, 0, 0, temperature_sensor_regs_map[0], temperature_sensor_regs_map[1], temperature_sensor_regs_map[2], temperature_sensor_regs_map[3]), \
|
||||
.owner = ENTRY(0) | ENTRY(2)
|
||||
}, \
|
||||
};
|
||||
|
||||
const temperature_sensor_reg_ctx_link_t temperature_sensor_regs_retention = {
|
||||
.link_list = temperature_sensor_regs_entries,
|
||||
.link_num = ARRAY_SIZE(temperature_sensor_regs_entries),
|
||||
.module_id = SLEEP_RETENTION_MODULE_TEMP_SENSOR,
|
||||
};
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2019-2025 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2019-2026 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "soc/regdma.h"
|
||||
#include "hal/temperature_sensor_periph.h"
|
||||
#include "soc/apb_saradc_reg.h"
|
||||
|
||||
const temperature_sensor_attribute_t temperature_sensor_attributes[TEMPERATURE_SENSOR_ATTR_RANGE_NUM] = {
|
||||
/*Offset reg_val min max error */
|
||||
@@ -17,26 +14,3 @@ const temperature_sensor_attribute_t temperature_sensor_attributes[TEMPERATURE_S
|
||||
{ 1, 11, -30, 50, 2},
|
||||
{ 2, 10, -40, 20, 3},
|
||||
};
|
||||
|
||||
// Temperature sensor sleep retention entries
|
||||
// Temperature sensor registers require set the reg_update bit to make the configuration take effect
|
||||
|
||||
/* Temperature sensor Registers Context
|
||||
Include: APB_SARADC_INT_ENA_REG /
|
||||
APB_SARADC_APB_TSENS_CTRL_REG / APB_SARADC_TSENS_CTRL2_REG / APB_TSENS_WAKE_REG / APB_TSENS_SAMPLE_REG
|
||||
*/
|
||||
#define TEMPERATURE_SENSOR_RETENTION_REGS_CNT 5
|
||||
#define TEMPERATURE_SENSOR_RETENTION_MAP_BASE APB_SARADC_INT_ENA_REG
|
||||
static const uint32_t temperature_sensor_regs_map[4] = {0x6c1, 0, 0, 0};
|
||||
static const regdma_entries_config_t temperature_sensor_regs_entries[] = {
|
||||
[0] = {
|
||||
.config = REGDMA_LINK_ADDR_MAP_INIT(REGDMA_TSENS_LINK(0x00), TEMPERATURE_SENSOR_RETENTION_MAP_BASE, TEMPERATURE_SENSOR_RETENTION_MAP_BASE, TEMPERATURE_SENSOR_RETENTION_REGS_CNT, 0, 0, temperature_sensor_regs_map[0], temperature_sensor_regs_map[1], temperature_sensor_regs_map[2], temperature_sensor_regs_map[3]), \
|
||||
.owner = ENTRY(0) | ENTRY(2)
|
||||
}, \
|
||||
};
|
||||
|
||||
const temperature_sensor_reg_ctx_link_t temperature_sensor_regs_retention = {
|
||||
.link_list = temperature_sensor_regs_entries,
|
||||
.link_num = ARRAY_SIZE(temperature_sensor_regs_entries),
|
||||
.module_id = SLEEP_RETENTION_MODULE_TEMP_SENSOR,
|
||||
};
|
||||
|
||||
@@ -117,6 +117,7 @@ static inline void temperature_sensor_ll_clk_sel(temperature_sensor_clk_src_t cl
|
||||
*
|
||||
* @param tsens_dac ``reg_val`` in table ``temperature_sensor_attributes``
|
||||
*/
|
||||
__attribute__((always_inline))
|
||||
static inline void temperature_sensor_ll_set_range(uint32_t range)
|
||||
{
|
||||
REGI2C_WRITE_MASK(I2C_SAR_ADC, I2C_SARADC_TSENS_DAC, range);
|
||||
@@ -140,6 +141,7 @@ static inline uint32_t temperature_sensor_ll_get_raw_value(void)
|
||||
*
|
||||
* @return uint32_t offset value
|
||||
*/
|
||||
__attribute__((always_inline))
|
||||
static inline uint32_t temperature_sensor_ll_get_offset(void)
|
||||
{
|
||||
return REGI2C_READ_MASK(I2C_SAR_ADC, I2C_SARADC_TSENS_DAC);
|
||||
|
||||
@@ -4,10 +4,7 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "soc/regdma.h"
|
||||
#include "hal/temperature_sensor_periph.h"
|
||||
#include "soc/apb_saradc_reg.h"
|
||||
|
||||
const temperature_sensor_attribute_t temperature_sensor_attributes[TEMPERATURE_SENSOR_ATTR_RANGE_NUM] = {
|
||||
/*Offset reg_val min max error */
|
||||
|
||||
@@ -1,16 +1,11 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2025-2026 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "soc/regdma.h"
|
||||
#if SOC_TEMPERATURE_SENSOR_SUPPORT_SLEEP_RETENTION
|
||||
#include "soc/retention_periph_defs.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@@ -27,16 +22,6 @@ typedef struct {
|
||||
|
||||
extern const temperature_sensor_attribute_t temperature_sensor_attributes[TEMPERATURE_SENSOR_ATTR_RANGE_NUM];
|
||||
|
||||
#if SOC_TEMPERATURE_SENSOR_SUPPORT_SLEEP_RETENTION
|
||||
typedef struct {
|
||||
const regdma_entries_config_t *link_list;
|
||||
uint32_t link_num;
|
||||
periph_retention_module_t module_id;
|
||||
} temperature_sensor_reg_ctx_link_t;
|
||||
|
||||
extern const temperature_sensor_reg_ctx_link_t temperature_sensor_regs_retention;
|
||||
#endif // SOC_TEMPERATURE_SENSOR_SUPPORT_SLEEP_RETENTION
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1279,6 +1279,14 @@ config SOC_TEMPERATURE_SENSOR_INTR_SUPPORT
|
||||
bool
|
||||
default y
|
||||
|
||||
config SOC_TEMPERATURE_SENSOR_SUPPORT_SLEEP_RETENTION
|
||||
bool
|
||||
default y
|
||||
|
||||
config SOC_TEMPERATURE_SENSOR_UNDER_PD_TOP_DOMAIN
|
||||
bool
|
||||
default y
|
||||
|
||||
config SOC_TOUCH_SENSOR_VERSION
|
||||
int
|
||||
default 3
|
||||
|
||||
@@ -538,7 +538,8 @@
|
||||
#define SOC_TEMPERATURE_SENSOR_SUPPORT_FAST_RC (1)
|
||||
#define SOC_TEMPERATURE_SENSOR_SUPPORT_XTAL (1)
|
||||
#define SOC_TEMPERATURE_SENSOR_INTR_SUPPORT (1)
|
||||
// #define SOC_TEMPERATURE_SENSOR_SUPPORT_SLEEP_RETENTION (1)
|
||||
#define SOC_TEMPERATURE_SENSOR_SUPPORT_SLEEP_RETENTION (1)
|
||||
#define SOC_TEMPERATURE_SENSOR_UNDER_PD_TOP_DOMAIN (1)
|
||||
|
||||
/*-------------------------- TOUCH SENSOR CAPS -------------------------------*/
|
||||
#define SOC_TOUCH_SENSOR_VERSION (3) /*!< Hardware version of touch sensor */
|
||||
|
||||
Reference in New Issue
Block a user