1 /* 2 * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 /** 8 * SAR related peripherals are interdependent. This file 9 * provides a united control to these registers, as multiple 10 * components require these controls. 11 * 12 * See target/sar_periph_ctrl.c to know involved peripherals 13 */ 14 15 #pragma once 16 17 #include <stdint.h> 18 #include <stdbool.h> 19 20 #ifdef __cplusplus 21 extern "C" { 22 #endif 23 24 /** 25 * Initialise SAR related peripheral register settings 26 * Should only be used when running into app stage 27 */ 28 void sar_periph_ctrl_init(void); 29 30 31 /*------------------------------------------------------------------------------ 32 * ADC Power 33 *----------------------------------------------------------------------------*/ 34 /** 35 * @brief Acquire the ADC oneshot mode power 36 */ 37 void sar_periph_ctrl_adc_oneshot_power_acquire(void); 38 39 /** 40 * @brief Release the ADC oneshot mode power 41 */ 42 void sar_periph_ctrl_adc_oneshot_power_release(void); 43 44 /** 45 * @brief Acquire the ADC continuous mode power 46 */ 47 void sar_periph_ctrl_adc_continuous_power_acquire(void); 48 49 /** 50 * @brief Release the ADC ADC continuous mode power 51 */ 52 void sar_periph_ctrl_adc_continuous_power_release(void); 53 54 55 /*------------------------------------------------------------------------------ 56 * PWDET Power 57 *----------------------------------------------------------------------------*/ 58 /** 59 * @brief Acquire the PWDET Power 60 */ 61 void sar_periph_ctrl_pwdet_power_acquire(void); 62 63 /** 64 * @brief Release the PWDET Power 65 */ 66 void sar_periph_ctrl_pwdet_power_release(void); 67 68 /** 69 * @brief Acquire the temperature sensor power 70 */ 71 void temperature_sensor_power_acquire(void); 72 73 /** 74 * @brief Release the temperature sensor power 75 */ 76 void temperature_sensor_power_release(void); 77 78 /** 79 * @brief Get the temperature value and choose the temperature sensor range. Will be both used in phy and peripheral. 80 * 81 * @param range_changed Pointer to whether range has been changed here. If you don't need this param, you can 82 * set NULL directly. 83 * 84 * @return temperature sensor value. 85 */ 86 int16_t temp_sensor_get_raw_value(bool *range_changed); 87 88 /** 89 * @brief Synchronize the tsens_idx between sar_periph and driver 90 * 91 * @param tsens_idx index value of temperature sensor attribute 92 */ 93 void temp_sensor_sync_tsens_idx(int tsens_idx); 94 95 /** 96 * @brief Enable SAR power when system wakes up 97 */ 98 void sar_periph_ctrl_power_enable(void); 99 100 /** 101 * @brief Disable SAR power when system goes to sleep 102 */ 103 void sar_periph_ctrl_power_disable(void); 104 105 #ifdef __cplusplus 106 } 107 #endif 108