Select one of the symbols to view example projects that use it.
 
Outline
#include "sdkconfig.h"
#include "esp_log.h"
#include "freertos/FreeRTOS.h"
#include "esp_private/sar_periph_ctrl.h"
#include "hal/sar_ctrl_ll.h"
TAG
sar_periph_ctrl_init()
sar_periph_ctrl_power_enable()
sar_periph_ctrl_power_disable()
s_sar_power_on_cnt
s_sar_power_acquire()
s_sar_power_release()
sar_periph_ctrl_pwdet_power_acquire()
sar_periph_ctrl_pwdet_power_release()
sar_periph_ctrl_adc_oneshot_power_acquire()
sar_periph_ctrl_adc_oneshot_power_release()
sar_periph_ctrl_adc_continuous_power_acquire()
sar_periph_ctrl_adc_continuous_power_release()
Files
ESP-IDF
components
app_trace
app_update
bootloader_support
bt
cmock
console
cxx
driver
efuse
esp_adc
esp_app_format
esp_bootloader_format
esp_coex
esp_common
esp_driver_ana_cmpr
esp_driver_cam
esp_driver_dac
esp_driver_gpio
esp_driver_gptimer
esp_driver_i2c
esp_driver_i2s
esp_driver_jpeg
esp_driver_ledc
esp_driver_mcpwm
esp_driver_parlio
esp_driver_pcnt
esp_driver_rmt
esp_driver_sdio
esp_driver_sdm
esp_driver_sdmmc
esp_driver_sdspi
esp_driver_spi
esp_driver_tsens
esp_driver_uart
esp_driver_usb_serial_jtag
esp_eth
esp_event
esp_gdbstub
esp_hid
esp_http_client
esp_http_server
esp_https_ota
esp_https_server
esp_hw_support
dma
include
ldo
port
esp32
include
include
esp_lcd
esp_local_ctrl
esp_mm
esp_netif
esp_partition
esp_phy
esp_pm
esp_psram
esp_ringbuf
esp_rom
esp_security
esp_system
esp_timer
esp_vfs_console
esp_wifi
esp-tls
espcoredump
hal
heap
http_parser
ieee802154
log
mqtt
newlib
nvs_flash
nvs_sec_provider
openthread
perfmon
protobuf-c
protocomm
pthread
rt
sdmmc
soc
spi_flash
spiffs
tcp_transport
ulp
unity
vfs
wear_levelling
wifi_provisioning
wpa_supplicant
xtensa
examples
lwIP
FreeRTOS
cJSON
mbedTLS
SourceVuESP-IDF Framework and ExamplesESP-IDFcomponents/esp_hw_support/port/esp32/sar_periph_ctrl.c
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/* * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 *//* ... */ /** * SAR related peripherals are interdependent. This file * provides a united control to these registers, as multiple * components require these controls. * * Related peripherals are: * - ADC * - PWDET *//* ... */ #include "sdkconfig.h" #include "esp_log.h" #include "freertos/FreeRTOS.h" #include "esp_private/sar_periph_ctrl.h" #include "hal/sar_ctrl_ll.h"5 includes static const char *TAG = "sar_periph_ctrl"; extern portMUX_TYPE rtc_spinlock; void sar_periph_ctrl_init(void) { //Put SAR control mux to ON state sar_ctrl_ll_set_power_mode(SAR_CTRL_LL_POWER_ON); //Add other periph power control initialisation here }{ ... } void sar_periph_ctrl_power_enable(void) { portENTER_CRITICAL_SAFE(&rtc_spinlock); sar_ctrl_ll_set_power_mode(SAR_CTRL_LL_POWER_ON); portEXIT_CRITICAL_SAFE(&rtc_spinlock); }{ ... } void sar_periph_ctrl_power_disable(void) { portENTER_CRITICAL_SAFE(&rtc_spinlock); sar_ctrl_ll_set_power_mode(SAR_CTRL_LL_POWER_OFF); portEXIT_CRITICAL_SAFE(&rtc_spinlock); }{ ... } /** * This gets incremented when s_sar_power_acquire() is called, * and decremented when s_sar_power_release() is called. * PWDET is powered down when the value reaches zero. * Should be modified within critical section. *//* ... */ static int s_sar_power_on_cnt; static void s_sar_power_acquire(void) { portENTER_CRITICAL_SAFE(&rtc_spinlock); s_sar_power_on_cnt++; if (s_sar_power_on_cnt == 1) { sar_ctrl_ll_set_power_mode(SAR_CTRL_LL_POWER_ON); }{...} portEXIT_CRITICAL_SAFE(&rtc_spinlock); }{ ... } static void s_sar_power_release(void) { portENTER_CRITICAL_SAFE(&rtc_spinlock); s_sar_power_on_cnt--; if (s_sar_power_on_cnt < 0) { portEXIT_CRITICAL(&rtc_spinlock); ESP_LOGE(TAG, "%s called, but s_sar_power_on_cnt == 0", __func__); abort(); }{...} else if (s_sar_power_on_cnt == 0) { sar_ctrl_ll_set_power_mode(SAR_CTRL_LL_POWER_FSM); }{...} portEXIT_CRITICAL_SAFE(&rtc_spinlock); }{ ... } /*------------------------------------------------------------------------------ * PWDET Power *----------------------------------------------------------------------------*//* ... */ void sar_periph_ctrl_pwdet_power_acquire(void) { s_sar_power_acquire(); }{ ... } void sar_periph_ctrl_pwdet_power_release(void) { s_sar_power_release(); }{ ... } /*------------------------------------------------------------------------------ * ADC Power *----------------------------------------------------------------------------*//* ... */ void sar_periph_ctrl_adc_oneshot_power_acquire(void) { s_sar_power_acquire(); }{ ... } void sar_periph_ctrl_adc_oneshot_power_release(void) { s_sar_power_release(); }{ ... } void sar_periph_ctrl_adc_continuous_power_acquire(void) { s_sar_power_acquire(); }{ ... } void sar_periph_ctrl_adc_continuous_power_release(void) { s_sar_power_release(); }{ ... }
Details