feat(tsens): graduate temperature sensor hal component

This commit is contained in:
laokaiyao
2026-01-29 10:05:47 +08:00
parent 7c1e88e3d4
commit 2cb958a9e3
35 changed files with 126 additions and 91 deletions
@@ -0,0 +1,44 @@
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include <stdint.h>
#include <stdbool.h>
#include "soc/soc_caps.h"
#ifdef __cplusplus
extern "C" {
#endif
#if SOC_TEMP_SENSOR_SUPPORTED
/**
* @brief Get raw temperature value with range management
*
* @param range_changed Pointer to store whether range was changed (can be NULL)
*
* @return Temperature sensor raw value
*/
int16_t temperature_sensor_hal_get_degree(bool *range_changed);
/**
* @brief Initialize temperature sensor HAL
*/
void temperature_sensor_hal_init(void);
/**
* @brief Sync temperature sensor index from main layer to HAL layer
*
* @param tsens_idx Temperature sensor index to sync
*/
void temperature_sensor_hal_sync_tsens_idx(uint8_t tsens_idx);
#endif // SOC_TEMP_SENSOR_SUPPORTED
#ifdef __cplusplus
}
#endif
@@ -0,0 +1,42 @@
/*
* SPDX-FileCopyrightText: 2020-2025 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
#define TEMPERATURE_SENSOR_ATTR_RANGE_NUM (5)
typedef struct {
int offset;
int reg_val;
int range_min;
int range_max;
int error_max;
} temperature_sensor_attribute_t;
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
@@ -0,0 +1,44 @@
/*
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include "soc/clk_tree_defs.h"
#include "soc/soc_caps.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief temperature sensor clock source
*/
#if SOC_TEMP_SENSOR_SUPPORTED
typedef soc_periph_temperature_sensor_clk_src_t temperature_sensor_clk_src_t;
#else
typedef int temperature_sensor_clk_src_t;
#endif // SOC_TEMP_SENSOR_SUPPORTED
/**
* @brief temperature sensor event types enum
*/
typedef enum {
TEMPERATURE_SENSOR_EVENT_OVER_LIMIT, /*!< Temperature sensor over limit event */
TEMPERATURE_SENSOR_EVENT_MAX, /*!< Maximum number of temperature sensor events */
} temperature_sensor_etm_event_type_t;
/**
* @brief temperature sensor task types enum
*/
typedef enum {
TEMPERATURE_SENSOR_TASK_START, /*!< Temperature sensor start task */
TEMPERATURE_SENSOR_TASK_STOP, /*!< Temperature sensor stop task */
TEMPERATURE_SENSOR_TASK_MAX, /*!< Maximum number of temperature sensor tasks */
} temperature_sensor_etm_task_type_t;
#ifdef __cplusplus
}
#endif