| /***************************************************************************** |
| * Copyright Statement: |
| * -------------------- |
| * This software is protected by Copyright and the information contained |
| * herein is confidential. The software may not be copied and the information |
| * contained herein may not be used or disclosed except with the written |
| * permission of MediaTek Inc. (C) 2005 |
| * |
| * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES |
| * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") |
| * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON |
| * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, |
| * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF |
| * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. |
| * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE |
| * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR |
| * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH |
| * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO |
| * NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S |
| * SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. |
| * |
| * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE |
| * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, |
| * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, |
| * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO |
| * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. |
| * |
| * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE |
| * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF |
| * LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND |
| * RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER |
| * THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). |
| * |
| *****************************************************************************/ |
| |
| /***************************************************************************** |
| * |
| * Filename: |
| * --------- |
| * keypad_sw.h |
| * |
| * Project: |
| * -------- |
| * Maui_Software |
| * |
| * Description: |
| * ------------ |
| * This file is intends for keypad driver and adaption. |
| * |
| * Author: |
| * ------- |
| * ------- |
| * |
| *============================================================================ |
| * HISTORY |
| * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!! |
| *------------------------------------------------------------------------------ |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| * removed! |
| *------------------------------------------------------------------------------ |
| * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! |
| *============================================================================ |
| ****************************************************************************/ |
| #ifndef _KEYPAD_H |
| #define _KEYPAD_H |
| |
| #include "drv_features.h" |
| #include "intrCtrl.h" |
| #include "drv_comm.h" |
| #include "kal_general_types.h" |
| #include "kal_public_defs.h" |
| #include "kal_public_api.h" |
| #include "keypad_sw.h" |
| #include "dcl.h" |
| |
| |
| typedef enum { |
| kbd_1_key_det_mode = 0, |
| kbd_2_keys_det_mode, |
| kbd_3_keys_det_mode |
| } kbd_key_det_mode; |
| |
| |
| |
| |
| |
| #define __DCL_KBD_SUPPORT__ |
| |
| #if defined(__EXTEND_QWERTY_KEYPAD__) |
| |
| #define KBD_MASKIRQ SetINTMask(IRQ_KPAD_CODE) |
| #define KBD_UNMASKIRQ RestoreINTMask(IRQ_KPAD_CODE) |
| #else |
| |
| #define KBD_MASKIRQ IRQMask(IRQ_KPAD_CODE) |
| #define KBD_UNMASKIRQ IRQUnmask(IRQ_KPAD_CODE) |
| |
| #endif //#if defined(__EXTEND_QWERTY_KEYPAD__) |
| |
| #ifdef __EXTRA_A_B_KEY_SUPPORT__ |
| #define KBD_EX_GPT_HDL_CNT 2 |
| #else |
| #define KBD_EX_GPT_HDL_CNT 0 |
| #endif |
| |
| #if defined(__TWO_KEY_DETECTION_SWITCHABLE__) |
| #define KBD_KEY_DETECTION_CNT 2 |
| #elif defined(__THREE_KEY_DETECTION_SWITCHABLE__) |
| #define KBD_KEY_DETECTION_CNT 3 |
| #else |
| #define KBD_KEY_DETECTION_CNT 1 |
| #endif |
| |
| #define KBD_GPT_HDL_CNT (KBD_EX_GPT_HDL_CNT + KBD_KEY_DETECTION_CNT) |
| |
| #define EVENT_REQUESTED (KBD_STATUS_CHANGE_EVENT|KBD_SWITCH_DETCTION_MODE_EVENT |KEY_UP_EVENT| KEY_DOWN_EVENT| KEY_RIGHT_EVENT | KEY_LEFT_EVENT) |
| |
| #if defined(TWO_KEY_ENABLE) |
| #if defined(__TWO_KEY_DETECTION_SWITCHABLE__) || defined(__THREE_KEY_DETECTION_SWITCHABLE__) |
| #error " kbd config conflicts!!" |
| #endif |
| #endif |
| |
| |
| typedef struct |
| { |
| kal_uint32 kbdmap_reg; |
| kal_uint32 kbdmap_reg1; |
| kal_uint32 kbdmap_reg2; |
| }kbd_map_reg_struct; |
| |
| typedef enum |
| { |
| KEY_DIRECTION_EVENT_NUll, |
| KBD_STATUS_CHANGE_EVENT = 0x01, /*keypad status changes event id */ |
| KBD_SWITCH_DETCTION_MODE_EVENT = 0x02, /*keypad switch detection mode event id*/ |
| |
| KEY_UP_EVENT = 0x10, |
| KEY_DOWN_EVENT = 0x20, |
| KEY_LEFT_EVENT = 0x40, |
| KEY_RIGHT_EVENT = 0x80, |
| KEY_DIRECTION_EVENT_ALL = 0xF0 |
| }kbd_task_event; |
| |
| |
| typedef struct |
| { |
| kal_eventgrpid event; |
| DCL_HANDLE gpthandle[KBD_GPT_HDL_CNT]; |
| |
| #ifdef __EXTRA_A_B_KEY_SUPPORT__ |
| kal_bool ext_status[2]; |
| #endif/*__EXTRA_A_B_KEY_SUPPORT__*/ |
| |
| #ifdef __KBD_2STEP_KEY_SUPPORT__ |
| DCL_HANDLE kbd_2key_handle; |
| #endif |
| #if defined(__EXTEND_QWERTY_KEYPAD__) |
| DCL_HANDLE kbd_extend_gpthandle; |
| kal_uint32 polling_timeout; |
| #endif //#if defined(__EXTEND_QWERTY_KEYPAD__) |
| kal_uint32 longpress_timeout; |
| kal_uint32 repeat_time; |
| } kbd_struct; |
| |
| |
| #if defined(__EXTEND_QWERTY_KEYPAD__) |
| |
| typedef struct |
| { |
| kal_bool key_column_all_low_GND[KBD_COLUMN]; //column all low cause by GND_ROW |
| kal_bool key_column_all_low_GPO[KBD_COLUMN]; //column all low cause by GPO_ROW |
| }keypad_Ext_QwertyKey_Status; |
| typedef struct |
| { |
| kal_bool key_column_all_low_GND[KBD_COLUMN]; //column all low cause by GND_ROW |
| kal_bool key_column_all_low_GPO[KBD_COLUMN]; //column all low cause by GPO_ROW |
| |
| kal_uint8 kbd_press_GND_column[KBD_KEY_DETECTION_CNT]; // which column pressed |
| kal_uint8 kbd_press_GPO_column[KBD_KEY_DETECTION_CNT]; // which column pressed |
| }keypad_Ext_QwertyKey_detect_info_struct; |
| |
| #endif |
| |
| /*keypad detect keys result during one key event*/ |
| typedef struct |
| { |
| #if defined(__EXTEND_QWERTY_KEYPAD__) |
| keypad_Ext_QwertyKey_detect_info_struct kbd_Ext_Qwerty_key_info; |
| #endif |
| kal_uint8 key_presscount; |
| kal_uint8 key_releasecount; |
| kal_uint8 key_total_count; |
| |
| kal_uint8 kbd_press_key[KBD_KEY_DETECTION_CNT]; |
| kal_uint8 kbd_release_key[KBD_KEY_DETECTION_CNT]; |
| |
| } keypad_detect_info_struct; |
| |
| typedef enum |
| { |
| Normal_ROW = 0, |
| Ext_GPO_ROW, |
| Ext_GND_ROW |
| }Keypad_ROW_Type; |
| |
| /*every key information*/ |
| typedef struct |
| { |
| kal_bool bKeyStatus; /*0: press; 1: release */ |
| kal_uint16 key_index; /*key index defined during customization*/ |
| |
| #if defined(__EXTEND_QWERTY_KEYPAD__) |
| kal_uint8 key_column; /*extend keys in which column*/ |
| Keypad_ROW_Type Row_Type; |
| #endif |
| }keypad_key_info; |
| |
| typedef struct |
| { |
| kbd_map_reg_struct kbd_map_reg; |
| #if defined(__EXTEND_QWERTY_KEYPAD__) |
| kal_bool key_column_all_low_GND[KBD_COLUMN]; //column all low cause by GND_ROW |
| kal_bool key_column_all_low_GPO[KBD_COLUMN]; //column all low cause by GPO_ROW |
| kal_bool extend_switch_mode_key;//when switch mode, the extend key is pressed |
| kal_uint8 extend_key_switch_pressed_num; |
| kal_uint8 kbd_switch_mode_extend_press_key[KBD_KEY_DETECTION_CNT]; |
| |
| #endif |
| |
| }keypad_status_struct; |
| |
| #if !defined(KBD_DETECT_ONLY_ONE_KEY) && defined(__EXTRA_A_B_KEY_SUPPORT__) |
| extern const kal_uint8 EXTRA_A_KEY_EINT_NO; |
| extern const kal_uint8 EXTRA_B_KEY_EINT_NO; |
| #define EINT_A_KEY EXTRA_A_KEY_EINT_NO |
| #define EINT_B_KEY EXTRA_B_KEY_EINT_NO |
| #endif |
| |
| #if defined(__TC01__) |
| #define kbd_push_time_stamp() \ |
| {\ |
| kal_get_time(&(kbd_buffer.kbd_data_buffer[kbd_buffer.kbd_data_buffer_windex].keytimestamp));\ |
| } |
| |
| #define kbd_pop_time_stamp(_key_data) \ |
| {\ |
| kbd_data* key_data = (kbd_data*)(_key_data);\ |
| key_data->keytimestamp = kbd_buffer.kbd_data_buffer[kbd_buffer.kbd_data_buffer_rindex].keytimestamp;\ |
| } |
| |
| #else |
| #define kbd_push_time_stamp() ; |
| #define kbd_pop_time_stamp(_key_data) ; |
| #endif |
| |
| extern void kbdbuffer_get_roomleft_(kal_uint8* pleft); |
| |
| #define kbdbuffer_get_roomleft(_left) \ |
| {\ |
| kbdbuffer_get_roomleft_(&(_left));\ |
| } |
| |
| |
| extern void Kbd_Initiaze(void); |
| extern kal_bool Kbd_GetDetectionMode(kal_uint8 *pmode); |
| extern kal_bool kbd_SetDetectionMode(kbd_key_det_mode mode); |
| extern kal_bool kbd_IsKeySupported(kal_uint8 key); |
| extern kal_bool kbd_IsKeymutiple(kal_uint8 key); |
| extern kal_uint32 Kbd_GetKeyCount(void); |
| extern kal_bool Kbd_GetKeyDatas(kbd_data *keydata); |
| extern kal_bool Kbd_PeekKeyDatas(kbd_data *keydata, kal_bool specify_read, |
| kal_uint32 read_pointer,kal_uint32* current_read_pointer); |
| extern kal_uint32 kbd_SendKey(kal_uint8 key); |
| extern void Kbd_SetLongPreTime(kal_uint32 ticks); |
| extern void Kbd_SetRepeatPreTime(kal_uint32 ticks); |
| |
| |
| //#include "us_timer.h" |
| extern kal_uint32 L1I_GetTimeStamp(void); |
| #define KBD_GetTimeStamp L1I_GetTimeStamp |
| #if defined(__MTK_INTERNAL__) && !defined(__MAUI_BASIC__) && defined(__DRV_DBG_MEMORY_TRACE_SUPPORT__) && defined(__EXTEND_QWERTY_KEYPAD__) |
| #define DRV_KBD_MEMORY_TRACE |
| typedef struct{ |
| kal_uint16 tag; |
| kal_uint32 time; |
| kal_uint32 data1; |
| kal_uint32 data2; |
| }KBD_DRV_DBG_DATA; |
| #define MAX_KBD_DRV_DBG_INFO_SIZE 512 |
| typedef struct{ |
| KBD_DRV_DBG_DATA dbg_data[MAX_KBD_DRV_DBG_INFO_SIZE]; |
| kal_uint16 dbg_data_idx; |
| }KBD_DRV_DBG_STRUCT; |
| extern void kbd_drv_dbg_trace(kal_uint16 index, kal_uint32 time, kal_uint32 data1, kal_uint32 data2); |
| #define KBD_DBG(a,b,c,d) kbd_drv_dbg_trace(a,b,c,d); |
| #else //#if defined(__MTK_INTERNAL__) && !defined(LOW_COST_SUPPORT) |
| #define KBD_DBG(a,b,c,d) ; |
| #endif //#if defined(__MTK_INTERNAL__) && !defined(LOW_COST_SUPPORT) |
| |
| |
| #if defined(__DRV_COMM_REG_DBG__) && defined(__DRV_KBD_REG_DBG__) |
| #define DRV_KBD_WriteReg(addr,data) DRV_DBG_WriteReg(addr,data) |
| #define DRV_KBD_Reg(addr) DRV_DBG_Reg(addr) |
| #define DRV_KBD_WriteReg32(addr,data) DRV_DBG_WriteReg32(addr,data) |
| #define DRV_KBD_Reg32(addr) DRV_DBG_Reg32(addr) |
| #define DRV_KBD_WriteReg8(addr,data) DRV_DBG_WriteReg8(addr,data) |
| #define DRV_KBD_Reg8(addr) DRV_DBG_Reg8(addr) |
| #define DRV_KBD_ClearBits(addr,data) DRV_DBG_ClearBits(addr,data) |
| #define DRV_KBD_SetBits(addr,data) DRV_DBG_SetBits(addr,data) |
| #define DRV_KBD_SetData(addr, bitmask, value) DRV_DBG_SetData(addr, bitmask, value) |
| #define DRV_KBD_ClearBits32(addr,data) DRV_DBG_ClearBits32(addr,data) |
| #define DRV_KBD_SetBits32(addr,data) DRV_DBG_SetBits32(addr,data) |
| #define DRV_KBD_SetData32(addr, bitmask, value) DRV_DBG_SetData32(addr, bitmask, value) |
| #define DRV_KBD_ClearBits8(addr,data) DRV_DBG_ClearBits8(addr,data) |
| #define DRV_KBD_SetBits8(addr,data) DRV_DBG_SetBits8(addr,data) |
| #define DRV_KBD_SetData8(addr, bitmask, value) DRV_DBG_SetData8(addr, bitmask, value) |
| #else |
| #define DRV_KBD_WriteReg(addr,data) DRV_WriteReg(addr,data) |
| #define DRV_KBD_Reg(addr) DRV_Reg(addr) |
| #define DRV_KBD_WriteReg32(addr,data) DRV_WriteReg32(addr,data) |
| #define DRV_KBD_Reg32(addr) DRV_Reg32(addr) |
| #define DRV_KBD_WriteReg8(addr,data) DRV_WriteReg8(addr,data) |
| #define DRV_KBD_Reg8(addr) DRV_Reg8(addr) |
| #define DRV_KBD_ClearBits(addr,data) DRV_ClearBits(addr,data) |
| #define DRV_KBD_SetBits(addr,data) DRV_SetBits(addr,data) |
| #define DRV_KBD_SetData(addr, bitmask, value) DRV_SetData(addr, bitmask, value) |
| #define DRV_KBD_ClearBits32(addr,data) DRV_ClearBits32(addr,data) |
| #define DRV_KBD_SetBits32(addr,data) DRV_SetBits32(addr,data) |
| #define DRV_KBD_SetData32(addr, bitmask, value) DRV_SetData32(addr, bitmask, value) |
| #define DRV_KBD_ClearBits8(addr,data) DRV_ClearBits8(addr,data) |
| #define DRV_KBD_SetBits8(addr,data) DRV_SetBits8(addr,data) |
| #define DRV_KBD_SetData8(addr, bitmask, value) DRV_SetData8(addr, bitmask, value) |
| #endif //#if defined(__DRV_COMM_REG_DBG__) && defined(__DRV_KBD_REG_DBG__) |
| |
| #endif |
| |
| |
| |
| |
| |