| 
									
										
										
										
											2022-08-08 21:56:49 +08:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2024-09-27 19:11:30 +08:00
										 |  |  |  * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD | 
					
						
							| 
									
										
										
										
											2022-08-08 21:56:49 +08:00
										 |  |  |  * | 
					
						
							|  |  |  |  * SPDX-License-Identifier: Apache-2.0 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-09-27 19:11:30 +08:00
										 |  |  | #include <stdint.h>
 | 
					
						
							|  |  |  | #include "soc/regdma.h"
 | 
					
						
							| 
									
										
										
										
											2022-08-08 21:56:49 +08:00
										 |  |  | #include "soc/temperature_sensor_periph.h"
 | 
					
						
							| 
									
										
										
										
											2024-09-27 19:11:30 +08:00
										 |  |  | #include "soc/apb_saradc_reg.h"
 | 
					
						
							| 
									
										
										
										
											2022-08-08 21:56:49 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-05 19:58:39 +08:00
										 |  |  | const temperature_sensor_attribute_t temperature_sensor_attributes[TEMPERATURE_SENSOR_ATTR_RANGE_NUM] = { | 
					
						
							| 
									
										
										
										
											2022-08-08 21:56:49 +08:00
										 |  |  |     /*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}, | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2024-09-27 19:11:30 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | // 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[] = { | 
					
						
							| 
									
										
										
										
											2024-11-22 10:55:08 +08:00
										 |  |  |     [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) | 
					
						
							|  |  |  |     }, \ | 
					
						
							| 
									
										
										
										
											2024-09-27 19:11:30 +08:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 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, | 
					
						
							|  |  |  | }; |