rjw | 6c1fd8f | 2022-11-30 14:33:01 +0800 | [diff] [blame] | 1 | #ifndef DCL_HTS_H_ |
| 2 | #define DCL_HTS_H_ |
| 3 | |
| 4 | #include "dcl.h" |
| 5 | |
| 6 | #define DCL_HTS_MAGIC_NUM 0x40000000 |
| 7 | |
| 8 | typedef DCL_UINT32 HTS_DEV; |
| 9 | typedef enum |
| 10 | { |
| 11 | TOUCH_PANEL_R=1 |
| 12 | }HTS_DEV_T; |
| 13 | |
| 14 | typedef DCL_UINT32 HTS_EVENT; |
| 15 | typedef enum |
| 16 | { |
| 17 | DCL_EVENT_HTS_PEN_DOWN=1, |
| 18 | DCL_EVENT_HTS_PEN_UP, |
| 19 | DCL_EVENT_HTS_MAX |
| 20 | }HTS_EVENT_T; |
| 21 | |
| 22 | //touch panel driver command of hardware layer. |
| 23 | typedef DCL_UINT32 HTS_CMD; |
| 24 | |
| 25 | typedef enum |
| 26 | { |
| 27 | HTS_CMD_GET_TP_ADC, |
| 28 | HTS_CMD_TS_READ_ADC, |
| 29 | HTS_CMD_GET_TP_LEVEL, |
| 30 | HTS_CMD_GET_TP_LEVEL_PRESSURE, |
| 31 | HTS_CMD_TP_UPDATENOTIFY, |
| 32 | HTS_CMD_GET_TP_PRESSURE, |
| 33 | HTS_CMD_TP_PRESSURE_VALUE, |
| 34 | HTS_CMD_SET_CONFIG, |
| 35 | HTS_CMD_GET_TP_POINT, |
| 36 | HTS_CMD_GET_TP_POINT_NUM, |
| 37 | HTS_CMD_GET_TP_TYPE, |
| 38 | HTS_CMD_SET_CALI_VALUE, |
| 39 | HTS_CMD_GET_CALI_VALUE, |
| 40 | HTS_CMD_SET_DEBOUNCE_TIME, |
| 41 | HTS_CMD_GET_DEBOUNCE_TIME, |
| 42 | HTS_CMD_SET_SPL_NUM, |
| 43 | HTS_CMD_GET_SPL_NUM |
| 44 | }HTS_CMD_T; |
| 45 | |
| 46 | //HTS_CMD_SET_DEBOUNCE_TIME |
| 47 | typedef struct |
| 48 | { |
| 49 | DCL_UINT32 u4DebounceTime; |
| 50 | }HTS_CTRL_DT_T; |
| 51 | |
| 52 | |
| 53 | //HTS_CMD_TP_SET_PARAMETERS |
| 54 | typedef struct |
| 55 | { |
| 56 | DCL_UINT32 u4SampleResolution; |
| 57 | DCL_UINT32 u4ModeSelection; |
| 58 | } HTS_CTRL_CONFIG_T; |
| 59 | typedef enum { |
| 60 | //Not use the same values as ts_hw.h |
| 61 | //Otherwise it easy to cause bug if change ts_hw.h, but forget to change these |
| 62 | DCL_TS_CMD_DIFFERENTIAL, |
| 63 | DCL_TS_CMD_SINGLE_END, |
| 64 | DCL_TS_CMD_MODE_8BIT, |
| 65 | DCL_TS_CMD_MODE_10BIT, |
| 66 | DCL_TS_CMD_MODE_12BIT |
| 67 | } HTS_PARAMETER_T; |
| 68 | |
| 69 | //HTS_CMD_TP_LEVEL, |
| 70 | typedef struct |
| 71 | { |
| 72 | DCL_BOOL fgIsUP; |
| 73 | DCL_UINT32 pressure_value; |
| 74 | } HTS_CTRL_TL_T; |
| 75 | |
| 76 | |
| 77 | //HTS_CMD_TP_READ_ADC |
| 78 | typedef struct |
| 79 | { |
| 80 | DCL_INT16 *pi2x; |
| 81 | DCL_INT16 *pi2y; |
| 82 | } HTS_CTRL_TPRA_T; |
| 83 | |
| 84 | //HTS_CMD_TS_READ_ADC |
| 85 | typedef enum { |
| 86 | TS_COORD_HTS_ADDR_Y, |
| 87 | TS_COORD_HTS_ADDR_Z1, |
| 88 | TS_COORD_HTS_ADDR_Z2, |
| 89 | TS_COORD_HTS_ADDR_X |
| 90 | } TS_COORD_ENUM; |
| 91 | typedef struct |
| 92 | { |
| 93 | DCL_INT16 i2AdcValue; |
| 94 | TS_COORD_ENUM uCoord; |
| 95 | } HTS_CTRL_TSRA_T; |
| 96 | |
| 97 | //HTS_CMD_TP_PRESSURE |
| 98 | typedef struct |
| 99 | { |
| 100 | DCL_BOOL fgIsPressed; |
| 101 | } HTS_CTRL_TPP_T; |
| 102 | |
| 103 | //HTS_CMD_TP_PRESSURE_VALUE |
| 104 | typedef struct |
| 105 | { |
| 106 | DCL_INT32 fgPressureValue; |
| 107 | } HTS_CTRL_TPPV_T; |
| 108 | //HTS_CMD_READ_ADC |
| 109 | typedef struct |
| 110 | { |
| 111 | DCL_INT16 *pi2x; |
| 112 | DCL_INT16 *pi2y; |
| 113 | } HTS_CTRL_RA_T; |
| 114 | |
| 115 | //HTS_CMD_ADC_TO_COORDINATE |
| 116 | typedef struct |
| 117 | { |
| 118 | DCL_BOOL fgValid; |
| 119 | DCL_INT16 *pi2x; |
| 120 | DCL_INT16 *pi2y; |
| 121 | } HTS_CTRL_ATC_T; |
| 122 | |
| 123 | //HTS_CMD_GET_SPL_NUM |
| 124 | typedef struct |
| 125 | { |
| 126 | DCL_UINT32 u4SPLNum; |
| 127 | }HTS_CTRL_SN_T; |
| 128 | |
| 129 | typedef union |
| 130 | { |
| 131 | HTS_CTRL_TL_T rTSCtrlTL; |
| 132 | HTS_CTRL_TPRA_T rTSCtrlTPRA; |
| 133 | HTS_CTRL_TSRA_T rTSCtrlTSRA; |
| 134 | HTS_CTRL_TPP_T rTSCtrlTPP; |
| 135 | HTS_CTRL_TPPV_T rTSCtrlTPPV; |
| 136 | HTS_CTRL_RA_T rTSCtrlRA; |
| 137 | HTS_CTRL_ATC_T rTSCtrlATC; |
| 138 | HTS_CTRL_CONFIG_T rTSCtrlConfig; |
| 139 | HTS_CTRL_DT_T rTSCtrlDebouncetime; |
| 140 | HTS_CTRL_SN_T rTSCtrlSPLNum; |
| 141 | }HTS_CTRL_DATA_T; |
| 142 | |
| 143 | |
| 144 | /************************************************************************* |
| 145 | * FUNCTION |
| 146 | * DclHTS_Close |
| 147 | * |
| 148 | * DESCRIPTION |
| 149 | * This function is to close the HW TS module. |
| 150 | * |
| 151 | * CALLS |
| 152 | * It is called to close HW TS module |
| 153 | * |
| 154 | * PARAMETERS |
| 155 | * None |
| 156 | * |
| 157 | * RETURNS |
| 158 | * DCL_STATUS_OK |
| 159 | * STATUS_INVALID_ARGUMENT: invalid arguments |
| 160 | * |
| 161 | * GLOBALS AFFECTED |
| 162 | * external_global |
| 163 | *************************************************************************/ |
| 164 | extern DCL_STATUS DclHTS_Close(DCL_HANDLE handle); |
| 165 | /************************************************************************* |
| 166 | * FUNCTION |
| 167 | * DclHTS_Configure |
| 168 | * |
| 169 | * DESCRIPTION |
| 170 | * This function is to configure the HW TS module. |
| 171 | * |
| 172 | * CALLS |
| 173 | * It is called to configure of the HW TS module. |
| 174 | * |
| 175 | * PARAMETERS |
| 176 | * handle - a valid handle return by DclHTS_Open() |
| 177 | * configure - a structure which include the TS configuration. |
| 178 | * |
| 179 | * RETURNS |
| 180 | * STATUS_OK: command is executed successfully. |
| 181 | * STATUS_FAIL: not open yet. |
| 182 | * STATUS_INVALID_ARGUMENT: not a valid handle. |
| 183 | * |
| 184 | * GLOBALS AFFECTED |
| 185 | * external_global |
| 186 | *************************************************************************/ |
| 187 | //extern DCL_STATUS DclHTS_Configure(DCL_HANDLE handle, DCL_CONFIGURE_T *configure); |
| 188 | /************************************************************************* |
| 189 | * FUNCTION |
| 190 | * DclHTS_Control |
| 191 | * |
| 192 | * DESCRIPTION |
| 193 | * This function is to send command to control the TS module. |
| 194 | * |
| 195 | * CALLS |
| 196 | * It is called to send command to control the TS module. |
| 197 | * |
| 198 | * PARAMETERS |
| 199 | * handle - a valid handle return by DclHTS_Open() |
| 200 | * cmd - a control command for TS module |
| 201 | * 1. HTS_CMD_TP_LEVEL :to detect whether TP is touched or NOT |
| 202 | * 2. HTS_CMD_TP_UPDATE_NOTIFY :to set a event to TP task to indicate we are at UP state |
| 203 | * 3. HTS_CMD_TP_READ_ADC :to read x and y adc value from AUXADC HW. (with touch_panel_filter_thresold which avoid detect error) |
| 204 | * 4. HTS_CMD_TP_PRESSURE :to check is touch panel pressed. |
| 205 | * 5. HTS_CMD_TS_DRV_INIT :to initial HW driver and switch on work around funciton |
| 206 | * 6. HTS_CMD_READ_ADC :to read adc from touch panel module. (with Landscape support, compile option: __PORTRAIT_LCM_SIMULATE_LANDSCAPE_LCM__) |
| 207 | * 7. HTS_CMD_TS_READ_ADC :to read x or y adc value from AUXADC HW. |
| 208 | * |
| 209 | * data - a union of DCL_CTRL_DATA_T |
| 210 | * rTSCtrlTL; //HTS_CTRL_TL_T |
| 211 | * rTSCtrlTPRA; //HTS_CTRL_TPRA_T |
| 212 | * rTSCtrlTPP; //HTS_CTRL_TPP_T |
| 213 | * rTSCtrlRA; //HTS_CTRL_RA_T |
| 214 | * rTSCtrlTSRA //HTS_CMD_TS_READ_ADC |
| 215 | * |
| 216 | * RETURNS |
| 217 | * STATUS_OK: command is executed successfully. |
| 218 | * STATUS_FAIL: command is failed. |
| 219 | * STATUS_INVALID_CMD: It's a invalid command. |
| 220 | * STATUS_INVALID_ARGUMENT: not a valid handle. |
| 221 | * |
| 222 | * GLOBALS AFFECTED |
| 223 | * external_global |
| 224 | *************************************************************************/ |
| 225 | extern DCL_STATUS DclHTS_Control(DCL_HANDLE handle, HTS_CMD cmd, HTS_CTRL_DATA_T *data); |
| 226 | /************************************************************************* |
| 227 | * FUNCTION |
| 228 | * DclHTS_Initialize |
| 229 | * |
| 230 | * DESCRIPTION |
| 231 | * This function is to initialize HW TS module |
| 232 | * |
| 233 | * CALLS |
| 234 | * It is called to initialize HW TS module |
| 235 | * |
| 236 | * PARAMETERS |
| 237 | * None |
| 238 | * |
| 239 | * RETURNS |
| 240 | * DCL_STATUS_OK |
| 241 | * |
| 242 | * GLOBALS AFFECTED |
| 243 | * external_global |
| 244 | *************************************************************************/ |
| 245 | extern DCL_STATUS DclHTS_Initialize(void); |
| 246 | /************************************************************************* |
| 247 | * FUNCTION |
| 248 | * DclHTS_Open |
| 249 | * |
| 250 | * DESCRIPTION |
| 251 | * This function is to open the TS HW module and return a handle |
| 252 | * |
| 253 | * CALLS |
| 254 | * It is called to open HW TS module |
| 255 | * |
| 256 | * PARAMETERS |
| 257 | * dev - valid for DCL_TS |
| 258 | * flags - no sepcial flags is needed. Please use FLAGS_NONE |
| 259 | * |
| 260 | * RETURNS |
| 261 | * DCL_HANDLE_INVALID - Open failed. |
| 262 | * Other value - a valid handle |
| 263 | * |
| 264 | * GLOBALS AFFECTED |
| 265 | * external_global |
| 266 | *************************************************************************/ |
| 267 | extern DCL_HANDLE DclHTS_Open(HTS_DEV dev, DCL_FLAGS flags); |
| 268 | /************************************************************************* |
| 269 | * FUNCTION |
| 270 | * DclHTS_ReadData |
| 271 | * |
| 272 | * DESCRIPTION |
| 273 | * This function unsupported. |
| 274 | * |
| 275 | * CALLS |
| 276 | * It is unsupported. |
| 277 | * |
| 278 | * PARAMETERS |
| 279 | * handle |
| 280 | * buff |
| 281 | * buf_len |
| 282 | * options |
| 283 | * |
| 284 | * RETURNS |
| 285 | * STATUS_UNSUPPORTED: command unsupported |
| 286 | * |
| 287 | * GLOBALS AFFECTED |
| 288 | * external_global |
| 289 | *************************************************************************/ |
| 290 | extern DCL_STATUS DclHTS_ReadData(DCL_HANDLE handle, DCL_BUFF *buff, DCL_BUFF_LEN *buf_len, DCL_OPTIONS options); |
| 291 | /************************************************************************* |
| 292 | * FUNCTION |
| 293 | * DclHTS_RegisterCallback |
| 294 | * |
| 295 | * DESCRIPTION |
| 296 | * This function is to register HW TS call back funciton. |
| 297 | * |
| 298 | * CALLS |
| 299 | * It is called to register HW TS call back funciton. |
| 300 | * |
| 301 | * PARAMETERS |
| 302 | * event - a valid event indicate register which event's call back funciton |
| 303 | * 1. DCL_EVENT_HTS_PEN_DOWN, |
| 304 | * 2. DCL_EVENT_HTS_PEN_UP |
| 305 | * callback - a call back funciton |
| 306 | * |
| 307 | * RETURNS |
| 308 | * STATUS_OK: register is executed successfully. |
| 309 | * STATUS_FAIL: register is failed. |
| 310 | * STATUS_INVALID_CMD: It's a invalid command. |
| 311 | * |
| 312 | * GLOBALS AFFECTED |
| 313 | * external_global |
| 314 | *************************************************************************/ |
| 315 | extern DCL_STATUS DclHTS_RegisterCallback(DCL_HANDLE handle, DCL_EVENT event, PFN_DCL_CALLBACK callback); |
| 316 | |
| 317 | |
| 318 | |
| 319 | |
| 320 | |
| 321 | |
| 322 | #endif |
| 323 | |
| 324 | |
| 325 | |
| 326 | |
| 327 | |
| 328 | |
| 329 | |
| 330 | |
| 331 | |