MT7687 API Reference  LinkIt SDK v4
hal_keypad.h
1 /* Copyright Statement:
2  *
3  * (C) 2005-2016 MediaTek Inc. All rights reserved.
4  *
5  * This software/firmware and related documentation ("MediaTek Software") are
6  * protected under relevant copyright laws. The information contained herein
7  * is confidential and proprietary to MediaTek Inc. ("MediaTek") and/or its licensors.
8  * Without the prior written permission of MediaTek and/or its licensors,
9  * any reproduction, modification, use or disclosure of MediaTek Software,
10  * and information contained herein, in whole or in part, shall be strictly prohibited.
11  * You may only use, reproduce, modify, or distribute (as applicable) MediaTek Software
12  * if you have agreed to and been bound by the applicable license agreement with
13  * MediaTek ("License Agreement") and been granted explicit permission to do so within
14  * the License Agreement ("Permitted User"). If you are not a Permitted User,
15  * please cease any access or use of MediaTek Software immediately.
16  * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
17  * THAT MEDIATEK SOFTWARE RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES
18  * ARE PROVIDED TO RECEIVER ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL
19  * WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
20  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
21  * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
22  * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
23  * SUPPLIED WITH MEDIATEK SOFTWARE, AND RECEIVER AGREES TO LOOK ONLY TO SUCH
24  * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. RECEIVER EXPRESSLY ACKNOWLEDGES
25  * THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES
26  * CONTAINED IN MEDIATEK SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK
27  * SOFTWARE RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
28  * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND
29  * CUMULATIVE LIABILITY WITH RESPECT TO MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
30  * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE MEDIATEK SOFTWARE AT ISSUE,
31  * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY RECEIVER TO
32  * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
33  */
34 
35 #ifndef __HAL_KEYPAD_H__
36 #define __HAL_KEYPAD_H__
37 
38 #include "hal_platform.h"
39 
40 
41 #ifdef HAL_KEYPAD_MODULE_ENABLED
42 #include "hal_keypad_table.h"
43 
74 #ifdef HAL_KEYPAD_FEATURE_POWERKEY
75 
87 #endif
88 
146 #ifdef HAL_KEYPAD_FEATURE_POWERKEY
147 
197 #endif
198 
213 #ifdef HAL_KEYPAD_FEATURE_POWERKEY
214 
225 #endif
226 
227 #ifdef HAL_KEYPAD_FEATURE_POWERKEY
228 
242 #else
243 
256 #endif
257 
258 
266 #ifdef __cplusplus
267 extern "C" {
268 #endif
269 
279 typedef void (*hal_keypad_callback_t)(void *user_data);
280 
281 #ifdef HAL_KEYPAD_FEATURE_POWERKEY
282 
287 typedef void (*hal_powerkey_callback_t)(void *user_data);
288 #endif
289 
299 typedef enum {
300  HAL_KEYPAD_MODE_SINGLE_KEY = 0,
301  HAL_KEYPAD_MODE_DOUBLE_KEY = 1
302 } hal_keypad_mode_t;
303 
305 typedef enum {
306  HAL_KEYPAD_STATUS_ERROR = -2,
307  HAL_KEYPAD_INVALID_PARAMETER = -1,
308  HAL_KEYPAD_STATUS_OK = 0
309 } hal_keypad_status_t;
310 
312 typedef enum {
313  HAL_KEYPAD_KEY_RELEASE = 0,
314  HAL_KEYPAD_KEY_PRESS = 1,
315  HAL_KEYPAD_KEY_LONG_PRESS = 2,
316  HAL_KEYPAD_KEY_REPEAT = 3,
317  HAL_KEYPAD_KEY_PMU_LONG_PRESS = 4
318 } hal_keypad_key_state_t;
328 typedef struct {
329  uint8_t column_bitmap;
330  uint8_t row_bitmap;
331 } hal_keypad_column_row_t;
332 
333 
335 typedef struct {
336  hal_keypad_mode_t mode;
337  hal_keypad_column_row_t key_map;
338  uint32_t debounce;
339  uint32_t repeat_time;
340  uint32_t longpress_time;
341 } hal_keypad_config_t;
342 
343 
345 typedef struct {
346  uint8_t column_high_pulse;
347  uint8_t row_high_pulse;
348  uint8_t column_scan_div;
349  uint8_t row_scan_div;
350 } hal_keypad_scan_timing_t;
351 
353 typedef struct {
354  hal_keypad_key_state_t state;
355  uint32_t key_data;
356  uint32_t time_stamp;
357 } hal_keypad_event_t;
358 
359 #ifdef HAL_KEYPAD_FEATURE_POWERKEY
360 
361 typedef struct {
362  hal_keypad_key_state_t state;
363  uint32_t key_data;
364  uint32_t time_stamp;
365 } hal_keypad_powerkey_event_t;
366 #endif
367 
380 hal_keypad_status_t hal_keypad_init(const hal_keypad_config_t *keypad_config);
381 
382 
383 #ifdef HAL_KEYPAD_FEATURE_POWERKEY
384 
392 hal_keypad_status_t hal_keypad_powerkey_init(uint32_t powerkey_data);
393 #endif
394 
395 
403 hal_keypad_status_t hal_keypad_deinit(void);
404 
405 #ifdef HAL_KEYPAD_FEATURE_POWERKEY
406 
413 hal_keypad_status_t hal_keypad_powerkey_deinit(void);
414 #endif
415 
423 hal_keypad_status_t hal_keypad_set_debounce(const uint32_t *keypad_debounce);
424 
431 hal_keypad_status_t hal_keypad_get_debounce(uint32_t *keypad_debounce);
432 
433 
439 hal_keypad_status_t hal_keypad_enable(void);
440 
447 hal_keypad_status_t hal_keypad_disable(void);
448 
457 hal_keypad_status_t hal_keypad_set_scan_timing(const hal_keypad_scan_timing_t *keypad_scan_timing);
458 
459 
468 hal_keypad_status_t hal_keypad_get_scan_timing(hal_keypad_scan_timing_t *keypad_scan_timing);
469 
470 
481 hal_keypad_status_t hal_keypad_register_callback(hal_keypad_callback_t callback, void *user_data);
482 
483 #ifdef HAL_KEYPAD_FEATURE_POWERKEY
484 
498 hal_keypad_status_t hal_keypad_powerkey_register_callback(hal_powerkey_callback_t callback, void *user_data);
499 #endif
500 
508 hal_keypad_status_t hal_keypad_get_key(hal_keypad_event_t *keypad_event);
509 
510 #ifdef HAL_KEYPAD_FEATURE_POWERKEY
511 
518 hal_keypad_status_t hal_keypad_powerkey_get_key(hal_keypad_powerkey_event_t *powerkey_event);
519 #endif /* HAL_KEYPAD_FEATURE_POWERKEY */
520 
521 #ifdef __cplusplus
522 }
523 #endif
524 
529 #endif /* HAL_KEYPAD_MODULE_ENABLED */
530 #endif /* __HAL_KEYPAD_H__ */
531 
532