mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
12717cbc00
https://www.viva64.com/en/b/0790/#ID369075A8F4 https://www.viva64.com/en/b/0790/#IDF03E449184 Reported in https://github.com/espressif/esp-idf/issues/6440
45 lines
1.2 KiB
C
45 lines
1.2 KiB
C
/*
|
|
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
// The HAL layer for Touch sensor (common part)
|
|
|
|
#include "hal/touch_sensor_hal.h"
|
|
#include "hal/touch_sensor_types.h"
|
|
|
|
void touch_hal_init(void)
|
|
{
|
|
touch_ll_stop_fsm();
|
|
touch_ll_intr_disable();
|
|
touch_ll_intr_clear();
|
|
touch_ll_clear_channel_mask(TOUCH_PAD_BIT_MASK_ALL);
|
|
touch_ll_clear_group_mask(TOUCH_PAD_BIT_MASK_ALL, TOUCH_PAD_BIT_MASK_ALL);
|
|
touch_ll_set_trigger_mode(TOUCH_TRIGGER_MODE_DEFAULT);
|
|
touch_ll_set_trigger_source(TOUCH_TRIGGER_SOURCE_DEFAULT);
|
|
touch_ll_clear_trigger_status_mask();
|
|
touch_ll_set_meas_time(TOUCH_PAD_MEASURE_CYCLE_DEFAULT);
|
|
touch_ll_set_sleep_time(TOUCH_PAD_SLEEP_CYCLE_DEFAULT);
|
|
touch_ll_set_fsm_mode(TOUCH_FSM_MODE_DEFAULT);
|
|
touch_ll_start_fsm();
|
|
}
|
|
|
|
void touch_hal_deinit(void)
|
|
{
|
|
touch_ll_stop_fsm();
|
|
touch_ll_clear_trigger_status_mask();
|
|
touch_ll_intr_disable();
|
|
}
|
|
|
|
void touch_hal_get_wakeup_status(touch_pad_t *pad_num)
|
|
{
|
|
uint32_t touch_mask = 0;
|
|
touch_ll_read_trigger_status_mask(&touch_mask);
|
|
if (touch_mask == 0) {
|
|
*pad_num = -1;
|
|
} else {
|
|
*pad_num = (touch_pad_t)(__builtin_ffs(touch_mask) - 1);
|
|
}
|
|
}
|