mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-10 04:43:33 +00:00
feat(temperature_sensor): Add temperature sensor support on esp32c61
This commit is contained in:
@@ -39,6 +39,10 @@ config SOC_ASYNC_MEMCPY_SUPPORTED
|
||||
bool
|
||||
default y
|
||||
|
||||
config SOC_TEMP_SENSOR_SUPPORTED
|
||||
bool
|
||||
default y
|
||||
|
||||
config SOC_PHY_SUPPORTED
|
||||
bool
|
||||
default y
|
||||
@@ -1119,6 +1123,26 @@ config SOC_CLK_ANA_I2C_MST_HAS_ROOT_GATE
|
||||
bool
|
||||
default y
|
||||
|
||||
config SOC_TEMPERATURE_SENSOR_SUPPORT_FAST_RC
|
||||
bool
|
||||
default y
|
||||
|
||||
config SOC_TEMPERATURE_SENSOR_SUPPORT_XTAL
|
||||
bool
|
||||
default y
|
||||
|
||||
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_WIFI_HW_TSF
|
||||
bool
|
||||
default y
|
||||
|
@@ -69,8 +69,9 @@ typedef enum {
|
||||
ETS_SYSTIMER_TARGET0_INTR_SOURCE,
|
||||
ETS_SYSTIMER_TARGET1_INTR_SOURCE,
|
||||
ETS_SYSTIMER_TARGET2_INTR_SOURCE,
|
||||
ETS_APB_ADC_INTR_SOURCE,
|
||||
ETS_DMA_IN_CH0_INTR_SOURCE,
|
||||
ETS_APB_ADC_INTR_SOURCE = 53,
|
||||
ETS_TEMPERATURE_SENSOR_INTR_SOURCE = ETS_APB_ADC_INTR_SOURCE,
|
||||
ETS_DMA_IN_CH0_INTR_SOURCE = 54,
|
||||
ETS_DMA_IN_CH1_INTR_SOURCE,
|
||||
ETS_DMA_OUT_CH0_INTR_SOURCE,
|
||||
ETS_DMA_OUT_CH1_INTR_SOURCE,
|
||||
|
@@ -38,6 +38,7 @@ typedef enum periph_retention_module {
|
||||
SLEEP_RETENTION_MODULE_GPSPI2 = 17,
|
||||
SLEEP_RETENTION_MODULE_LEDC = 18,
|
||||
SLEEP_RETENTION_MODULE_I2S0 = 19,
|
||||
SLEEP_RETENTION_MODULE_TEMP_SENSOR = 20,
|
||||
|
||||
/* Modem module, which includes WiFi, BLE and 802.15.4 */
|
||||
SLEEP_RETENTION_MODULE_WIFI_MAC = 26,
|
||||
@@ -73,6 +74,7 @@ typedef enum periph_retention_module_bitmap {
|
||||
SLEEP_RETENTION_MODULE_BM_GPSPI2 = BIT(SLEEP_RETENTION_MODULE_GPSPI2),
|
||||
SLEEP_RETENTION_MODULE_BM_LEDC = BIT(SLEEP_RETENTION_MODULE_LEDC),
|
||||
SLEEP_RETENTION_MODULE_BM_I2S0 = BIT(SLEEP_RETENTION_MODULE_I2S0),
|
||||
SLEEP_RETENTION_MODULE_BM_TEMP_SENSOR = BIT(SLEEP_RETENTION_MODULE_TEMP_SENSOR),
|
||||
/* modem module, which includes WiFi, BLE and 802.15.4 */
|
||||
SLEEP_RETENTION_MODULE_BM_WIFI_MAC = BIT(SLEEP_RETENTION_MODULE_WIFI_MAC),
|
||||
SLEEP_RETENTION_MODULE_BM_WIFI_BB = BIT(SLEEP_RETENTION_MODULE_WIFI_BB),
|
||||
@@ -96,6 +98,7 @@ typedef enum periph_retention_module_bitmap {
|
||||
| SLEEP_RETENTION_MODULE_BM_GPSPI2 \
|
||||
| SLEEP_RETENTION_MODULE_BM_LEDC \
|
||||
| SLEEP_RETENTION_MODULE_BM_I2S0 \
|
||||
| SLEEP_RETENTION_MODULE_BM_TEMP_SENSOR \
|
||||
| SLEEP_RETENTION_MODULE_BM_NULL \
|
||||
)
|
||||
|
||||
|
@@ -27,7 +27,7 @@
|
||||
// \#define SOC_IEEE802154_SUPPORTED 1
|
||||
#define SOC_USB_SERIAL_JTAG_SUPPORTED 1
|
||||
#define SOC_ASYNC_MEMCPY_SUPPORTED 1
|
||||
// \#define SOC_TEMP_SENSOR_SUPPORTED 1 //TODO: [ESP32C61] IDF-9322
|
||||
#define SOC_TEMP_SENSOR_SUPPORTED 1
|
||||
#define SOC_PHY_SUPPORTED 1
|
||||
#define SOC_WIFI_SUPPORTED 1
|
||||
#define SOC_SUPPORTS_SECURE_DL_MODE 1
|
||||
@@ -469,9 +469,11 @@
|
||||
#define SOC_CLK_ANA_I2C_MST_HAS_ROOT_GATE (1) /*!< Any regi2c operation needs enable the analog i2c master clock first */
|
||||
|
||||
/*-------------------------- Temperature Sensor CAPS -------------------------------------*/
|
||||
// #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_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_UNDER_PD_TOP_DOMAIN (1)
|
||||
|
||||
/*------------------------------------ WI-FI CAPS ------------------------------------*/
|
||||
#define SOC_WIFI_HW_TSF (1) /*!< Support hardware TSF */
|
||||
|
40
components/soc/esp32c61/temperature_sensor_periph.c
Normal file
40
components/soc/esp32c61/temperature_sensor_periph.c
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "soc/regdma.h"
|
||||
#include "soc/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 */
|
||||
{-2, 5, 50, 125, 3},
|
||||
{-1, 7, 20, 100, 2},
|
||||
{ 0, 15, -10, 80, 1},
|
||||
{ 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,
|
||||
};
|
Reference in New Issue
Block a user