// Copyright 2019 Espressif Systems (Shanghai) PTE LTD // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /******************************************************************************* * NOTICE * The hal is not public api, don't use in application code. * See readme.md in soc/include/hal/readme.md ******************************************************************************/ // The HAL layer for touch sensor (common part) #pragma once #include "hal/touch_sensor_ll.h" #include "hal/touch_sensor_types.h" #ifdef __cplusplus extern "C" { #endif typedef struct { touch_high_volt_t refh; touch_low_volt_t refl; touch_volt_atten_t atten; } touch_hal_volt_t; typedef struct { touch_cnt_slope_t slope; /*! BIT(1) * @return * - ESP_OK on success */ #define touch_hal_set_channel_mask(enable_mask) touch_ll_set_channel_mask(enable_mask) /** * Get touch sensor channel mask. * * @param enable_mask bitmask of touch sensor scan group. * e.g. TOUCH_PAD_NUM1 -> BIT(1) */ #define touch_hal_get_channel_mask(enable_mask) touch_ll_get_channel_mask(enable_mask) /** * Disable touch sensor channel by bitmask. * * @param enable_mask bitmask of touch sensor scan group. * e.g. TOUCH_PAD_NUM1 -> BIT(1) */ #define touch_hal_clear_channel_mask(disable_mask) touch_ll_clear_channel_mask(disable_mask) /** * Get the touch sensor status, usually used in ISR to decide which pads are 'touched'. * * @param status_mask The touch sensor status. e.g. Touch1 trigger status is `status_mask & (BIT1)`. */ #define touch_hal_read_trigger_status_mask(status_mask) touch_ll_read_trigger_status_mask(status_mask) /** * Clear all touch sensor status. */ #define touch_hal_clear_trigger_status_mask() touch_ll_clear_trigger_status_mask() /** * Get touch sensor raw data (touch sensor counter value) from register. No block. * * @param touch_num touch pad index. * @return touch_value pointer to accept touch sensor value. */ #define touch_hal_read_raw_data(touch_num) touch_ll_read_raw_data(touch_num) /** * Get touch sensor measure status. No block. * * @return * - If touch sensors measure done. */ #define touch_hal_meas_is_done() touch_ll_meas_is_done() /** * Initialize touch module. * * @note If default parameter don't match the usage scenario, it can be changed after this function. */ void touch_hal_init(void); /** * Un-install touch pad driver. * * @note After this function is called, other touch functions are prohibited from being called. */ void touch_hal_deinit(void); /** * Configure touch sensor for each channel. */ void touch_hal_config(touch_pad_t touch_num); #ifdef __cplusplus } #endif