MT2523 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 {
303 
305 typedef enum {
310 
312 typedef enum {
328 typedef struct {
329  uint8_t column_bitmap;
330  uint8_t row_bitmap;
332 
333 
335 typedef struct {
338  uint32_t debounce;
339  uint32_t repeat_time;
340  uint32_t longpress_time;
342 
343 
345 typedef struct {
347  uint8_t row_high_pulse;
348  uint8_t column_scan_div;
349  uint8_t row_scan_div;
351 
353 typedef struct {
355  uint32_t key_data;
356  uint32_t time_stamp;
358 
359 #ifdef HAL_KEYPAD_FEATURE_POWERKEY
360 
361 typedef struct {
363  uint32_t key_data;
364  uint32_t time_stamp;
366 #endif
367 
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 
404 
405 #ifdef HAL_KEYPAD_FEATURE_POWERKEY
406 
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 
440 
448 
458 
459 
469 
470 
482 
483 #ifdef HAL_KEYPAD_FEATURE_POWERKEY
484 
499 #endif
500 
509 
510 #ifdef HAL_KEYPAD_FEATURE_POWERKEY
511 
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 
hal_keypad_key_state_t state
Specifies the key status, such as released, pressed, longpressed, etc.
Definition: hal_keypad.h:354
hal_keypad_mode_t
This enum defines keypad mode selection.
Definition: hal_keypad.h:299
hal_keypad_mode_t mode
Specifies the keypad single or double key mode.
Definition: hal_keypad.h:336
This structure defines key event data.
Definition: hal_keypad.h:353
hal_keypad_status_t hal_keypad_register_callback(hal_keypad_callback_t callback, void *user_data)
This function registers a callback function when in a normal key mode.
uint32_t longpress_time
Specifies the keypad longpress event time, the unit is millisecond.
Definition: hal_keypad.h:340
PMU hardware powerkey is long pressed.
Definition: hal_keypad.h:317
uint8_t row_high_pulse
Specifies the high level of row pulses will stay clocks.
Definition: hal_keypad.h:347
A key is pressed.
Definition: hal_keypad.h:314
A key is released.
Definition: hal_keypad.h:313
uint8_t column_bitmap
Specifies the keypad column bitmap [2:0].
Definition: hal_keypad.h:329
A key is repeat pressed.
Definition: hal_keypad.h:316
This structure defines keypad scan timing.
Definition: hal_keypad.h:345
uint32_t key_data
Specifies the powerkey data.
Definition: hal_keypad.h:363
hal_keypad_status_t hal_keypad_get_key(hal_keypad_event_t *keypad_event)
This function gets the key event.
A key is long pressed.
Definition: hal_keypad.h:315
hal_keypad_status_t
This enum defines keypad status.
Definition: hal_keypad.h:305
hal_keypad_status_t hal_keypad_powerkey_deinit(void)
This function de-initializes the powerkey base environment.
hal_keypad_status_t hal_keypad_powerkey_register_callback(hal_powerkey_callback_t callback, void *user_data)
This function registers a callback function when in a powerkey mode.
uint32_t repeat_time
Specifies the keypad repeat event time, the unit is millisecond.
Definition: hal_keypad.h:339
uint8_t column_scan_div
Specifies the period of column pulses will stay clocks.
Definition: hal_keypad.h:348
hal_keypad_status_t hal_keypad_init(const hal_keypad_config_t *keypad_config)
This function initialize the keypad module.
hal_keypad_status_t hal_keypad_disable(void)
This function disables the keypad module.
An invalid parameter.
Definition: hal_keypad.h:307
hal_keypad_status_t hal_keypad_get_debounce(uint32_t *keypad_debounce)
This function gets the keypad debounce time, the unit is in milliseconds.
hal_keypad_status_t hal_keypad_get_scan_timing(hal_keypad_scan_timing_t *keypad_scan_timing)
Get the keypad scan timing.
void(* hal_powerkey_callback_t)(void *user_data)
This function registers a callback function when in a powerkey mode.
Definition: hal_keypad.h:287
hal_keypad_status_t hal_keypad_set_debounce(const uint32_t *keypad_debounce)
This function sets the keypad debounce time, the unit is in milliseconds.
hal_keypad_status_t hal_keypad_deinit(void)
This function deinitializes the keypad module.
hal_keypad_column_row_t key_map
Specifies the keypad column and row bitmaps.
Definition: hal_keypad.h:337
uint32_t time_stamp
Specifies the time stamp of event on the keypad.
Definition: hal_keypad.h:356
uint8_t column_high_pulse
Specifies the high level of column pulses will stay clocks.
Definition: hal_keypad.h:346
This structure defines keypad configuration.
Definition: hal_keypad.h:335
hal_keypad_status_t hal_keypad_enable(void)
This function enables the keypad module.
No error occurred during the function call.
Definition: hal_keypad.h:308
uint32_t time_stamp
Specifies the time stamp of event on the keypad.
Definition: hal_keypad.h:364
hal_keypad_status_t hal_keypad_set_scan_timing(const hal_keypad_scan_timing_t *keypad_scan_timing)
Set the keypad scan timing.
hal_keypad_status_t hal_keypad_powerkey_init(uint32_t powerkey_data)
This function initializes the powerkey base environment.
This structure defines powerkey key data.
Definition: hal_keypad.h:361
void(* hal_keypad_callback_t)(void *user_data)
This function registers a callback function when in a normal key mode.
Definition: hal_keypad.h:279
A keypad function error.
Definition: hal_keypad.h:306
hal_keypad_key_state_t
This enum defines key status.
Definition: hal_keypad.h:312
This structure defines keypad column and row parameter.
Definition: hal_keypad.h:328
Sets the keypad single key mode.
Definition: hal_keypad.h:300
uint32_t debounce
Specifies the keypad debounce time, the unit is millisecond.
Definition: hal_keypad.h:338
uint8_t row_bitmap
Specifies the keypad row bitmap [2:0].
Definition: hal_keypad.h:330
hal_keypad_status_t hal_keypad_powerkey_get_key(hal_keypad_powerkey_event_t *powerkey_event)
This function gets the powerkey event.
uint32_t key_data
Specifies the key position number on the keypad.
Definition: hal_keypad.h:355
uint8_t row_scan_div
Specifies the period of row pulses will stay clocks.
Definition: hal_keypad.h:349
hal_keypad_key_state_t state
Specifies the powerkey state is pressed or released.
Definition: hal_keypad.h:362
Sets the keypad double key mode.
Definition: hal_keypad.h:301