1 // Copyright 2019 Espressif Systems (Shanghai) PTE LTD 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 /******************************************************************************* 16 * NOTICE 17 * The hal is not public api, don't use in application code. 18 * See readme.md in hal/include/hal/readme.md 19 ******************************************************************************/ 20 21 // The HAL layer for touch sensor (esp32 specific part) 22 23 #pragma once 24 25 #include "hal/touch_sensor_ll.h" 26 #include "hal/touch_sensor_types.h" 27 28 #include_next "hal/touch_sensor_hal.h" 29 30 #ifdef __cplusplus 31 extern "C" { 32 #endif 33 34 /** 35 * Set touch sensor measurement time. 36 * 37 * @param meas_time The duration of the touch sensor measurement. 38 * t_meas = meas_time / (8MHz), the maximum measure time is 0xffff / 8M = 8.19 ms. 39 */ 40 #define touch_hal_set_meas_time(meas_time) touch_ll_set_meas_time(meas_time) 41 42 /** 43 * Get touch sensor measurement time. 44 * 45 * @param meas_time Pointer to accept measurement cycle count. 46 */ 47 #define touch_hal_get_meas_time(meas_time) touch_ll_get_meas_time(meas_time) 48 49 /** 50 * Set touch sensor interrupt trigger mode. 51 * Interrupt can be triggered either when touch value is less than 52 * threshold or when touch value is more than threshold. 53 * 54 * @param mode Touch sensor interrupt trigger mode. 55 */ 56 #define touch_hal_set_trigger_mode(mode) touch_ll_set_trigger_mode(mode) 57 58 /** 59 * Get touch sensor interrupt trigger mode. 60 * Interrupt can be triggered either when touch value is less than 61 * threshold or when touch value is more than threshold. 62 * 63 * @param mode Touch sensor interrupt trigger mode. 64 */ 65 #define touch_hal_get_trigger_mode(mode) touch_ll_get_trigger_mode(mode) 66 67 /** 68 * Set touch sensor interrupt trigger source. There are two sets of touch signals. 69 * Set1 and set2 can be mapped to several touch signals. Either set will be triggered 70 * if at least one of its touch signal is 'touched'. The interrupt can be configured to be generated 71 * if set1 is triggered, or only if both sets are triggered. 72 * 73 * @param src Touch sensor interrupt trigger source. 74 */ 75 #define touch_hal_set_trigger_source(src) touch_ll_set_trigger_source(src) 76 77 /** 78 * Get touch sensor interrupt trigger source. 79 * 80 * @param src Pointer to accept touch sensor interrupt trigger source. 81 */ 82 #define touch_hal_get_trigger_source(src) touch_ll_get_trigger_source(src) 83 84 /** 85 * Set touch sensor group mask. 86 * Touch pad module has two sets of signals, 'Touched' signal is triggered only if 87 * at least one of touch pad in this group is "touched". 88 * This function will set the register bits according to the given bitmask. 89 * 90 * @param set1_mask bitmask of touch sensor signal group1, it's a 10-bit value 91 * @param set2_mask bitmask of touch sensor signal group2, it's a 10-bit value 92 */ 93 #define touch_hal_set_group_mask(group1_mask, group2_mask) touch_ll_set_group_mask(group1_mask, group2_mask) 94 95 /** 96 * Get touch sensor group mask. 97 * 98 * @param set1_mask pointer to accept bitmask of touch sensor signal group1, it's a 10-bit value 99 * @param set2_mask pointer to accept bitmask of touch sensor signal group2, it's a 10-bit value 100 */ 101 #define touch_hal_get_group_mask(group1_mask, group2_mask) touch_ll_get_group_mask(group1_mask, group2_mask) 102 103 /** 104 * Clear touch sensor group mask. 105 * 106 * @param set1_mask pointer to accept bitmask of touch sensor signal group1, it's a 10-bit value 107 * @param set2_mask pointer to accept bitmask of touch sensor signal group2, it's a 10-bit value 108 */ 109 #define touch_hal_clear_group_mask(group1_mask, group2_mask) touch_ll_clear_group_mask(group1_mask, group2_mask) 110 111 /** 112 * To enable touch pad interrupt. 113 */ 114 #define touch_hal_intr_enable() touch_ll_intr_enable() 115 116 /** 117 * To disable touch pad interrupt. 118 */ 119 #define touch_hal_intr_disable() touch_ll_intr_disable() 120 121 /** 122 * To clear touch pad interrupt. 123 */ 124 #define touch_hal_intr_clear() touch_ll_intr_clear() 125 126 /** 127 * Get the touch pad which caused wakeup from deep sleep. 128 * 129 * @param pad_num pointer to touch pad which caused wakeup. 130 */ 131 void touch_hal_get_wakeup_status(touch_pad_t *pad_num); 132 133 #ifdef __cplusplus 134 } 135 #endif 136