Chapter 2. API Reference
• ESP_ERR_INVALID_ARG parameter is NULL
Parameters
• pad_num: Set touch channel number for sleep pad. Only one touch sensor channel is supported in
deep sleep mode.
• proximity_cnt: pointer to accept touch sensor proximity count value
esp_err_t
touch_pad_sleep_channel_set_work_time(uint16_t
Change the operating frequency of touch pad in deep sleep state. Reducing the operating frequency can ef-
fectively reduce power consumption. If this function is not called, the working frequency of touch in the deep
sleep state is the same as that in the wake-up state.
Return
• ESP_OK Success
Parameters
• sleep_cycle: The touch sensor will sleep after each measurement. sleep_cycle decide the in-
terval between each measurement. t_sleep = sleep_cycle / (RTC_SLOW_CLK frequency). The ap-
proximate frequency value of RTC_SLOW_CLK can be obtained using rtc_clk_slow_freq_get_hz
function.
• meas_times: The times of charge and discharge in each measure process of touch channels. The
timer frequency is 8Mhz. Range: 0 ~ 0xffff. Recommended typical value: Modify this value to
make the measurement time around 1ms.
Header File
•
components/driver/include/driver/touch_sensor_common.h
Functions
esp_err_t
touch_pad_init(void)
Initialize touch module.
Note If default parameter don't match the usage scenario, it can be changed after this function.
Return
• ESP_OK Success
• ESP_ERR_NO_MEM Touch pad init error
• ESP_ERR_NOT_SUPPORTED Touch pad is providing current to external XTAL
esp_err_t
touch_pad_deinit(void)
Un-install touch pad driver.
Note After this function is called, other touch functions are prohibited from being called.
Return
• ESP_OK Success
• ESP_FAIL Touch pad driver not initialized
esp_err_t touch_pad_io_init(touch_pad_t
Initialize touch pad GPIO.
Return
• ESP_OK on success
• ESP_ERR_INVALID_ARG if argument is wrong
Parameters
• touch_num: touch pad index
esp_err_t touch_pad_set_voltage(touch_high_volt_t
Set touch sensor high voltage threshold of chanrge. The touch sensor measures the channel capacitance value
by charging and discharging the channel. So the high threshold should be less than the supply voltage.
Return
• ESP_OK on success
• ESP_ERR_INVALID_ARG if argument is wrong
Parameters
Espressif Systems
touch_num)
refh,
atten)
408
Submit Document Feedback
sleep_cycle,
meas_times)
touch_low_volt_t
refl,
touch_volt_atten_t
uint16_t
Release v4.4
Need help?
Do you have a question about the ESP32-S2 and is the answer not in the manual?