mirror of
				https://github.com/espressif/esp-idf.git
				synced 2025-11-04 00:51:42 +01:00 
			
		
		
		
	feat(temperature_sensor): Add temperature sensor support on esp32p4
This commit is contained in:
		@@ -55,6 +55,10 @@ config SOC_ASYNC_MEMCPY_SUPPORTED
 | 
			
		||||
    bool
 | 
			
		||||
    default y
 | 
			
		||||
 | 
			
		||||
config SOC_TEMP_SENSOR_SUPPORTED
 | 
			
		||||
    bool
 | 
			
		||||
    default y
 | 
			
		||||
 | 
			
		||||
config SOC_SUPPORTS_SECURE_DL_MODE
 | 
			
		||||
    bool
 | 
			
		||||
    default y
 | 
			
		||||
@@ -1327,11 +1331,11 @@ config SOC_PERIPH_CLK_CTRL_SHARED
 | 
			
		||||
    bool
 | 
			
		||||
    default y
 | 
			
		||||
 | 
			
		||||
config SOC_TEMPERATURE_SENSOR_SUPPORT_FAST_RC
 | 
			
		||||
config SOC_TEMPERATURE_SENSOR_SUPPORT_LP_PLL
 | 
			
		||||
    bool
 | 
			
		||||
    default y
 | 
			
		||||
 | 
			
		||||
config SOC_TEMPERATURE_SENSOR_SUPPORT_XTAL
 | 
			
		||||
config SOC_TEMPERATURE_SENSOR_INTR_SUPPORT
 | 
			
		||||
    bool
 | 
			
		||||
    default y
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -636,6 +636,21 @@ typedef enum {
 | 
			
		||||
    SDMMC_CLK_SRC_PLL200M = SOC_MOD_CLK_PLL_F200M,  /*!< Select PLL_200M as the source clock */
 | 
			
		||||
} soc_periph_sdmmc_clk_src_t;
 | 
			
		||||
 | 
			
		||||
//////////////////////////////////////////////////Temp Sensor///////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief Array initializer for all supported clock sources of Temperature Sensor
 | 
			
		||||
 */
 | 
			
		||||
#define SOC_TEMP_SENSOR_CLKS {SOC_MOD_CLK_LP_PLL}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief Type of Temp Sensor clock source
 | 
			
		||||
 */
 | 
			
		||||
typedef enum {
 | 
			
		||||
    TEMPERATURE_SENSOR_CLK_SRC_LP_PLL = SOC_MOD_CLK_LP_PLL,     /*!< Select LP_PLL as the source clock */
 | 
			
		||||
    TEMPERATURE_SENSOR_CLK_SRC_DEFAULT = SOC_MOD_CLK_LP_PLL,    /*!< Select LP_PLL as the default choice */
 | 
			
		||||
} soc_periph_temperature_sensor_clk_src_t;
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 
 | 
			
		||||
@@ -31,7 +31,8 @@ typedef enum {
 | 
			
		||||
    ETS_LP_SPI_INTR_SOURCE,
 | 
			
		||||
    ETS_LP_TOUCH_INTR_SOURCE,
 | 
			
		||||
    ETS_LP_TSENS_INTR_SOURCE,
 | 
			
		||||
    ETS_LP_UART_INTR_SOURCE,
 | 
			
		||||
    ETS_TEMPERATURE_SENSOR_INTR_SOURCE = ETS_LP_TSENS_INTR_SOURCE,
 | 
			
		||||
    ETS_LP_UART_INTR_SOURCE = 16,
 | 
			
		||||
    ETS_LP_EFUSE_INTR_SOURCE,
 | 
			
		||||
    ETS_LP_SW_INTR_SOURCE,
 | 
			
		||||
    ETS_LP_SYSREG_INTR_SOURCE,
 | 
			
		||||
 
 | 
			
		||||
@@ -15,7 +15,8 @@
 | 
			
		||||
#define I2C_MST_BBPLL_CAL_DONE         (BIT(24))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#define ANA_CONFIG_REG  0x600AF81C
 | 
			
		||||
 | 
			
		||||
#define ANA_CONFIG_REG  0x5012401C
 | 
			
		||||
#define ANA_CONFIG_S    (8)
 | 
			
		||||
#define ANA_CONFIG_M    (0x3FF)
 | 
			
		||||
 | 
			
		||||
@@ -23,7 +24,7 @@
 | 
			
		||||
#define ANA_I2C_BBPLL_M      BIT(17) /* Clear to enable BBPLL */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#define ANA_CONFIG2_REG  0x600AF820
 | 
			
		||||
#define ANA_CONFIG2_REG  0x50124020
 | 
			
		||||
#define ANA_CONFIG2_M    BIT(18)
 | 
			
		||||
 | 
			
		||||
#define ANA_I2C_SAR_FORCE_PU BIT(16)
 | 
			
		||||
 
 | 
			
		||||
@@ -14,3 +14,10 @@
 | 
			
		||||
 * bus. These definitions are used via macros defined in regi2c_ctrl.h, by
 | 
			
		||||
 * function in adc_ll.h.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#define I2C_SAR_ADC            0X69
 | 
			
		||||
#define I2C_SAR_ADC_HOSTID     0
 | 
			
		||||
 | 
			
		||||
#define I2C_SARADC_TSENS_DAC 0x6
 | 
			
		||||
#define I2C_SARADC_TSENS_DAC_MSB 3
 | 
			
		||||
#define I2C_SARADC_TSENS_DAC_LSB 0
 | 
			
		||||
 
 | 
			
		||||
@@ -36,7 +36,7 @@
 | 
			
		||||
#define SOC_ASYNC_MEMCPY_SUPPORTED      1
 | 
			
		||||
// disable usb serial jtag for esp32p4, current image does not support
 | 
			
		||||
// #define SOC_USB_SERIAL_JTAG_SUPPORTED   1  //TODO: IDF-7496
 | 
			
		||||
// #define SOC_TEMP_SENSOR_SUPPORTED       1  //TODO: IDF-7482
 | 
			
		||||
#define SOC_TEMP_SENSOR_SUPPORTED       1
 | 
			
		||||
#define SOC_SUPPORTS_SECURE_DL_MODE     1
 | 
			
		||||
#define SOC_ULP_SUPPORTED               1
 | 
			
		||||
#define SOC_LP_CORE_SUPPORTED           1
 | 
			
		||||
@@ -571,8 +571,8 @@
 | 
			
		||||
#define SOC_PERIPH_CLK_CTRL_SHARED                (1)     /*!< Peripheral clock control (e.g. set clock source) is shared between various peripherals */
 | 
			
		||||
 | 
			
		||||
/*-------------------------- Temperature Sensor CAPS -------------------------------------*/
 | 
			
		||||
#define SOC_TEMPERATURE_SENSOR_SUPPORT_FAST_RC                (1)
 | 
			
		||||
#define SOC_TEMPERATURE_SENSOR_SUPPORT_XTAL                (1)
 | 
			
		||||
#define SOC_TEMPERATURE_SENSOR_SUPPORT_LP_PLL                (1)
 | 
			
		||||
#define SOC_TEMPERATURE_SENSOR_INTR_SUPPORT                  (1)
 | 
			
		||||
 | 
			
		||||
/*-------------------------- Memory CAPS --------------------------*/
 | 
			
		||||
#define SOC_MEM_TCM_SUPPORTED    (1)
 | 
			
		||||
 
 | 
			
		||||
@@ -222,6 +222,7 @@ typedef struct {
 | 
			
		||||
    volatile tsens_sample_rate_reg_t sample_rate;
 | 
			
		||||
} tsens_dev_t;
 | 
			
		||||
 | 
			
		||||
extern tsens_dev_t LP_TSENS;
 | 
			
		||||
 | 
			
		||||
#ifndef __cplusplus
 | 
			
		||||
_Static_assert(sizeof(tsens_dev_t) == 0x2c, "Invalid size of tsens_dev_t structure");
 | 
			
		||||
 
 | 
			
		||||
@@ -85,6 +85,7 @@ PROVIDE ( AHB_DMA      =  0x50085000 );
 | 
			
		||||
PROVIDE ( AXI_DMA      =  0x5008a000 );
 | 
			
		||||
PROVIDE ( LCD_CAM      = 0x500dc000 );
 | 
			
		||||
PROVIDE ( LP_IOMUX      = 0x5012B000 );
 | 
			
		||||
PROVIDE ( LP_TSENS     = 0x5012f000 );
 | 
			
		||||
 | 
			
		||||
PROVIDE ( MIPI_CSI_BRIDGE    = 0x5009F800 );
 | 
			
		||||
PROVIDE ( MIPI_CSI_HOST      = 0x5009F000 );
 | 
			
		||||
 
 | 
			
		||||
@@ -7,5 +7,10 @@
 | 
			
		||||
#include "soc/temperature_sensor_periph.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},
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user