1 /* 2 * Copyright (c) 2022 Winner Microelectronics Co., Ltd. All rights reserved. 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 /** 17 * @file wm_touchsensor.h 18 * 19 * @brief touchsensor Driver Module 20 * 21 * @author 22 * 23 * Copyright (c) 2021 Winner Microelectronics Co., Ltd. 24 */ 25 #ifndef DRIVER_WM_TOUCHSENSOR_H 26 #define DRIVER_WM_TOUCHSENSOR_H 27 28 #include "wm_type_def.h" 29 30 /** 31 * @brief This function is used to initialize touch sensor. 32 * 33 * @param[in] sensorno is the touch sensor number from 1-15 34 * @param[in] scan_period is scan period for per touch sensor ,unit:16ms, >0 35 * @param[in] window is count window, window must be greater than 2.Real count window is window - 2. 36 * @param[in] enable is touch sensor enable bit. 37 * 38 * @retval 0:success 39 * 40 * @note if use touch sensor, user must configure the IO multiplex by API wm_touch_sensor_config. 41 */ 42 int tls_touchsensor_init_config(u32 sensorno, u8 scan_period, u8 window, u32 enable); 43 44 /** 45 * @brief This function is used to deinit touch sensor's selection and disable touch. 46 * 47 * @param[in] sensorno is the touch sensor number from 1-15 48 * 49 * @retval 0:success 50 * 51 * @note if do not use touch sensor, user can deinit by this interface and configure this touch sensor as GPIO. 52 */ 53 int tls_touchsensor_deinit(u32 sensorno); 54 55 /** 56 * @brief This function is used to set threshold per touch sensor. 57 * 58 * @param[in] sensorno is the touch sensor number from 1-15 59 * @param[in] threshold is the sensorno's touch sensor threshold,max value is 127. 60 * 61 * @retval 0:success. minus value: parameter wrong. 62 * 63 * @note None 64 */ 65 int tls_touchsensor_threshold_config(u32 sensorno, u8 threshold); 66 67 /** 68 * @brief This function is used to get touch sensor's count number. 69 * 70 * @param[in] sensorno is the touch sensor number from 1 to 15. 71 * 72 * @retval sensorno's count number . 73 * 74 * @note None 75 */ 76 int tls_touchsensor_countnum_get(u32 sensorno); 77 78 /** 79 * @brief This function is used to enable touch sensor's irq. 80 * 81 * @param[in] sensorno is the touch sensor number from 1 to 15. 82 * 83 * @retval 0:successfully enable irq, -1:parameter wrong. 84 * 85 * @note None 86 */ 87 int tls_touchsensor_irq_enable(u32 sensorno); 88 89 /** 90 * @brief This function is used to disable touch sensor's irq. 91 * 92 * @param[in] sensorno is the touch sensor number from 1 to 15. 93 * 94 * @retval 0:successfully disable irq, -1:parameter wrong. 95 * 96 * @note None 97 */ 98 int tls_touchsensor_irq_disable(u32 sensorno); 99 100 /** 101 * @brief This function is used to register touch sensor's irq callback. 102 * 103 * @param[in] callback is call back for user's application. 104 * 105 * @retval None. 106 * 107 * @note None 108 */ 109 void tls_touchsensor_irq_register(void (*callback)(u32 status)); 110 111 /** 112 * @brief This function is used to get touch sensor's irq status. 113 * 114 * @param[in] sensorno is the touch sensor number from 1 to 15. 115 * 116 * @retval >=0:irq status, -1:parameter wrong. 117 * 118 * @note None 119 */ 120 int tls_touchsensor_irq_status_get(u32 sensorno); 121 122 #endif