esp32s3如何通过IDF设置触摸唤醒,

Aristarrow
Posts: 2
Joined: Thu Oct 31, 2024 4:18 am

esp32s3如何通过IDF设置触摸唤醒,

Postby Aristarrow » Fri Nov 01, 2024 4:10 am

我的代码如下,一进入睡眠就直接被唤醒。我的触摸引脚是IO1

void touch_sleep_init() {
// gpio_reset_pin(SLEEP_GPIO);
touch_pad_fsm_stop();


touch_pad_init();
touch_pad_io_init(TOUCH_PIN);
// uint16_t enable_mask = BIT(14);
// touch_pad_set_channel_mask(BIT(14));

// touch_pad_set_voltage(TOUCH_HVOLT_2V7, TOUCH_LVOLT_0V5, TOUCH_HVOLT_ATTEN_1V);
touch_pad_config(TOUCH_PIN);
//touch_pad_filter_enble();
// touch_pad_set_thresh(TOUCH_PIN,400);
// uint32_t benchmark_value;
// touch_pad_read_benchmark(TOUCH_PIN, &benchmark_value);
// touch_pad_set_thresh(TOUCH_PIN,300);
// ESP_LOGI("benmark", "GPIO %d level: %lu",GPIO_NUM_1, benchmark_value);
uint16_t enable_mask_get;

touch_pad_get_channel_mask(&enable_mask_get);
ESP_LOGI("_enable_mark", "enable_mask: %u",enable_mask_get);
// touch_filter_config_t filter_info={
// .jitter_step=8,

// };
// touch_pad_filter_set_config(&filter_info);

//touch_pad_set_thresh(TOUCH_PIN,100000);
// touch_pad_fsm_start();

// touch_pad_isr_register(isr_touch_handle, NULL,TOUCH_PAD_INTR_MASK_DONE);
// touch_pad_intr_enable(TOUCH_PAD_INTR_MASK_SCAN_DONE);

touch_pad_isr_register(isr_touch_handle, NULL,TOUCH_PAD_INTR_MASK_SCAN_DONE);
touch_pad_set_measurement_interval(150);
touch_pad_intr_enable(TOUCH_PAD_INTR_MASK_SCAN_DONE);
touch_pad_set_fsm_mode(TOUCH_FSM_MODE_TIMER);
touch_pad_fsm_start();


esp_err_t ret = esp_sleep_enable_touchpad_wakeup();
if (ret == ESP_OK) {
ESP_LOGI("touch_wakeup_enable","OK");
} else if (ret == ESP_ERR_NOT_SUPPORTED) {
ESP_LOGI("touch_wakeup_enable","ESP_PD_OPTION_ON");
} else if (ret == ESP_ERR_INVALID_STATE) {
ESP_LOGI("touch_wakeup_enable","Other wakeup source existed");
}
}

Who is online

Users browsing this forum: No registered users and 66 guests