📄 cdr15key.c
字号:
/* == IDENTIFICATION ================================================== * * Copyright (C) 2004, Philips Semiconductors Nuernberg * * System : Vega Family * Component : PT * Module : DRIVER * Unit : Keypad Driver for KBS * File : cdr15key.c * * @(#) %filespec: cdr15key.c-23 % * * *//* == HISTORY ========================================================= * * Name Date V. Action * -------------------------------------------------------------------- * tcmc_thc 16-Sep-2005 23 corrected SMS1-switch to VDSW_TRAIN_LEC * and removed " #if 0 " * tcmc_spv 26-Aug-2005 MMS.2 Merge MMS.1 and 22 (exclude SMS1PLUS) * tcmc_spv 04-Jul-2005 MMS_1 Add MMS_PRO switch for MMS project * (emWin keyboard function) * * tcmc_thc 05-Jul-2005 22 added test keys for modem tests * tcmc_ore 10-May-2004 21 PR358: Some GPIOs don't exist on 64pin chips * tcmc_ore 05-May-2004 20 Add Pin80onDemoBlue * tcmc_ore 16-Apr-2004 19 Replace XSonDemoBlue with Pin64OnDemoBlue * tcmc_ore 22-Mar-2004 18 XSonDemoBlue switch * tcmc_ore 08-May-2003 17 Update default settings for KBS.con in * p_dr15_Key_init() * tcmc_ore 21-Mar-2003 16 Remove send of PREPARE_REQ for WDCT and * get rid of compiler warning * tcmc_ore 13-Feb-2003 Add Keypad mode and sending of * DR_KEYPAD_RELEASE_IND (DR05_FREE_MODE) * tcmc_ore 06-Dec-2002 KeyInit with parameter * tcmc_dbm 27-Nov-2002 add Switch for VegaLite * tcmc_hyu 21-Aug-2002 update for VegaXS 64pin * tcmc_hyu 03-May-2002 update for VegaXS * tcmc_ore 11-Apr-2002 change KeyEnablePon to keep RFSIGs * tcmc_hyu 14-Mar-2002 updated to be used on the VegaTB system board * tcmc_hyu 06-Nov-2001 rework after crosscheck * tcmc_hyu 02-Aug-2001 implement the wakeup mechanism * tcmc_hyu 31-Jul-2001 key mapping table for test purpose * tcmc_hyu 31-May-2001 code change for the 45-key version * tcmc_asa 11-May-2001 changed hsd07ddl.h to hsd09ddl.h * tcmc_asa 30-Nov-2000 created, copied from D47/D51 dr_key.c * changed SYS0_ICU_INT_KBS(_IRQ) * *//*MPM:::DRIVER::Keypad ================================================= * * ABSTRACT: * * The Keypad driver delivers keypad events to the MMI. * * There are two meanings for each key: * - short press meaning: the key is released before the long press * limit is reached * - long press meaning: the key is still held down when the * long press limit expires * * The MMI is informed by the DR_KEYPAD_IND event after the key * is released or after the long press limit, whichever occurs first. * * * Global functions to be called by other layers: * ---------------------------------------------- * - none * * Layer-local functions to be called from inside the DRIVER layer: * --------------------------------------------------------------- * - p_dr15_Keypad checks for long presses * - p_dr15_KeyDisable disables the driver * - p_dr15_KeyEnablePon enables the wake up event * - p_dr15_KeyInit * - p_dr15_KeypadMode * * Module-local functions to be called from inside this module: * ------------------------------------------------------------ * - p_dr15_KeyInterrupt handles the KBS events * - p_dr15_KeySend */#define cdr15_c/* == GLOBAL DECLARATIONS ======================================= */ #include "cg0type.h"#include "csys0reg.h"#include "csys2vpb.h"#include "csys5os.h"#ifdef PT_MODULE# include "hsd09cnf.h"# include "hsd09ddl.h" /* messages and processes */#else# include "bsd09cnf.h"# include "bsd09ddl.h" /* messages and processes */#endif /* PT_MODULE */#include "cos00int.h"#include "cos01dat.h" #ifdef PT_MODULE# include "hdr02aud.h" /* DR02_KEYCLICK */# if (VDSW_FEATURES & VDSW_TRAIN_LEC)# include "hhl00int.h"# include "cap03def.h"# endif /*(VDSW_FEATURES & VDSW_TRAIN_LEC)*/#else# include "bdr02aud.h" /* DR02_KEYCLICK */#endif /* PT_MODULE */#include "cdr05key.h"#ifdef PT_MODULE#if (VDSW_FEATURES & VDSW_MMS_PRO)#include "GUI.h"#endif#endif/* == DEFINITION OF LOCAL CONSTANTS ======================================== */#if defined(VegaXS) || defined(Pin64onDemoBlue) || defined(Pin80onDemoBlue)#define DR15_GPIO2_AS_KP_INPUT (SYS2_GPIO2_16_KBIO1 |\ SYS2_GPIO2_17_KBIO2 |\ SYS2_GPIO2_18_KBIO3 |\ SYS2_GPIO2_19_KBIO4 |\ SYS2_GPIO2_20_KBIO5 |\ SYS2_GPIO2_24_KBIO9 )#else#define DR15_GPIO2_AS_KP_INPUT (SYS2_GPIO2_16_KBIO1 |\ SYS2_GPIO2_17_KBIO2 |\ SYS2_GPIO2_18_KBIO3 |\ SYS2_GPIO2_19_KBIO4 |\ SYS2_GPIO2_20_KBIO5 |\ SYS2_GPIO2_21_KBIO6 |\ SYS2_GPIO2_22_KBIO7 |\ SYS2_GPIO2_23_KBIO8 |\ SYS2_GPIO2_24_KBIO9 )#endif /* Pin64/80onDemoBlue */# define DR15_NUM_OF_KEYS 45# define DR15_MODE_SHORT_PRESS 0# define DR15_MODE_LONG_PRESS DR15_NUM_OF_KEYS# define DR15_KEY_LONG 100 /* 1000ms = long press */# define DR15_KEY_FREE_DELAY 2 /* wait 20ms until free key is rec'd *//* == DECLARATION OF LOCAL FUNCTION PROTOTYPES ============================= */void p_dr15_KeySend(u8 u8_Modifier);/* == DECLARATION OF LOCAL DATA =========================================== */static u8 u8_dr15_KeyScanCnt; /* scan counter (*10ms) */static u16 u16_dr15_KeyCode; /* key code from KBS */#ifdef DR05_FREE_MODEstatic t_en_dr05_KeypadMode u8_dr15_KeypadMode;#endif/* The physical keyboard layout is shown in format key(scanner code): S1(0) S5(10) S21(35) S35(40) S11(4) S16(5) S22(6) S29(7) S37(8) S2(1) S8(11) S27(36) S43(41) S12(12) S17(13) S23(14) S30(15) S38(16) S4(2) S6(17) S34(37) S36(42) S13(19) S18(20) S24(21) S31(22) S39(23) S7(3) S9(18) S42(38) S44(43) S14(25) S19(26) S25(27) S32(28) S40(29) S3(9) S10(24) S28(39) S45(44) S15(30) S20(31) S26(32) S33(33) S41(34) Each key corresponds to a keyboard scanner code in the range 0...44. The code is used as the access index to array u8_dr15_KeyCodes. This way the user can specify a specific meaning (e.g. a DECT character) for each key by changing the array definition. */#if defined(VegaXS) || defined(VegaLite) || (defined(VegaBB) && defined(Pin80onDemoBlue))#ifdef VegaXS56pin#error Not yet checked for 56pin VegaXS version#else/* This is for the 64 pin VegaXS: */#if defined(Pin64onDemoBlue) || defined(Pin80onDemoBlue)/* This is for the 64 pin VegaXS: */static const u8 u8_dr15_KeyCodes[DR15_NUM_OF_KEYS*2] ={/*00*/ DR05_KEY_1, DR05_KEY_2, DR05_KEY_3, DR05_KEY_4, DR05_KEY_5,/*05*/ 0xff, 0xff, 0xff, DR05_KEY_INTERN, DR05_KEY_6,/*10*/ DR05_KEY_7, DR05_KEY_8, DR05_KEY_9, 0xff, 0xff,/*15*/ 0xff, DR05_KEY_F, DR05_KEY_0, DR05_KEY_STAR, DR05_KEY_HASH,/*20*/ 0xff, 0xff, 0xff, DR05_KEY_MEM, DR05_KEY_HOOK,/*25*/ DR05_KEY_LNR, 0xff, 0xff, 0xff, DR05_KEY_CLEAR,/*30*/ 0xff, 0xff, 0xff, 0xff, 0xff,/*35*/ 0xff, 0xff, 0xff, 0xff, 0xff,/*40*/ 0xff, 0xff, 0xff, 0xff, 0xff,/*45*/ DR05_KEY_LP_1, DR05_KEY_LP_2, DR05_KEY_LP_3, DR05_KEY_LP_4, DR05_KEY_LP_5,/*50*/ 0xff, 0xff, 0xff, DR05_KEY_LP_INTERN, DR05_KEY_LP_5,/*55*/ DR05_KEY_LP_7, DR05_KEY_LP_8, DR05_KEY_LP_9, 0xff, 0xff,/*60*/ 0xff, DR05_KEY_LP_F, DR05_KEY_LP_0, DR05_KEY_LP_STAR, DR05_KEY_LP_HASH,/*65*/ 0xff, 0xff, 0xff, DR05_KEY_LP_MEM, DR05_KEY_LP_HOOK,/*70*/ DR05_KEY_LP_LNR,0xff, 0xff, 0xff, DR05_KEY_LP_CLEAR,/*75*/ 0xff, 0xff, 0xff, 0xff, 0xff,/*80*/ 0xff, 0xff, 0xff, 0xff, 0xff,/*85*/ 0xff, 0xff, 0xff, 0xff, 0xff};#elsestatic const u8 u8_dr15_KeyCodes[DR15_NUM_OF_KEYS*2] ={/*00*/ DR05_KEY_F, DR05_KEY_CLEAR, DR05_KEY_MEM, 0xff, DR05_KEY_2,/*05*/ DR05_KEY_3, 0xff, 0xff, 0xff, 0xff,/*10*/ DR05_KEY_1, DR05_KEY_4, DR05_KEY_5, DR05_KEY_6, 0xff,/*15*/ 0xff, 0xff, DR05_KEY_7, DR05_KEY_STAR, DR05_KEY_8,/*20*/ DR05_KEY_9, 0xff, 0xff, 0xff, DR05_KEY_INTERN,/*25*/ DR05_KEY_0, DR05_KEY_HASH, 0xff, 0xff, 0xff,/*30*/ DR05_KEY_HOOK, DR05_KEY_LNR, 0xff, 0xff, 0xff,/*35*/ 0xff, 0xff, 0xff, 0xff, 0xff,/*40*/ 0xff, 0xff, 0xff, 0xff, 0xff,/*45*/ DR05_KEY_LP_F, DR05_KEY_LP_CLEAR, DR05_KEY_LP_MEM, 0xff, DR05_KEY_LP_2,/*50*/ DR05_KEY_LP_3, 0xff, 0xff, 0xff, 0xff,/*55*/ DR05_KEY_LP_1, DR05_KEY_LP_4, DR05_KEY_LP_5, DR05_KEY_LP_6, 0xff,/*60*/ 0xff, 0xff, DR05_KEY_LP_7, DR05_KEY_LP_STAR, DR05_KEY_LP_8,/*65*/ DR05_KEY_LP_9, 0xff, 0xff, 0xff, DR05_KEY_LP_INTERN,/*70*/ DR05_KEY_LP_0, DR05_KEY_LP_HASH, 0xff, 0xff, 0xff,/*75*/ DR05_KEY_LP_HOOK,DR05_KEY_LP_LNR, 0xff, 0xff, 0xff,/*80*/ 0xff, 0xff, 0xff, 0xff, 0xff,/*85*/ 0xff, 0xff, 0xff, 0xff, 0xff };#endif /* Pin64onDemoBlue */#endif#else/* This is for the 100 pin VegaTB: */static const u8 u8_dr15_KeyCodes[DR15_NUM_OF_KEYS*2] ={/*00*/ 0xff, 0xff, 0xff, 0xff, 0xff,/*05*/ DR05_KEY_F, DR05_KEY_1, DR05_KEY_2, DR05_KEY_3, 0xff,/*10*/ 0xff, 0xff, 0xff, DR05_KEY_CLEAR, DR05_KEY_4,/*15*/ DR05_KEY_5, DR05_KEY_6, 0xff, 0xff, 0xff,/*20*/ DR05_KEY_MEM, DR05_KEY_7, DR05_KEY_8, DR05_KEY_9, 0xff,/*25*/ 0xff, 0xff, DR05_KEY_STAR, DR05_KEY_0, DR05_KEY_HASH,/*30*/ 0xff, 0xff, DR05_KEY_INTERN, DR05_KEY_HOOK, DR05_KEY_LNR,/*35*/ 0xff, 0xff, 0xff, 0xff, 0xff,/*40*/ 0xff, 0xff, 0xff, 0xff, 0xff, /*45*/ 0xff, 0xff, 0xff, 0xff, 0xff,/*50*/ DR05_KEY_LP_F, DR05_KEY_LP_1, DR05_KEY_LP_2, DR05_KEY_LP_3, 0xff,/*55*/ 0xff, 0xff, 0xff, DR05_KEY_LP_CLEAR, DR05_KEY_LP_4,/*60*/ DR05_KEY_LP_5, DR05_KEY_LP_6, 0xff, 0xff, 0xff,/*65*/ DR05_KEY_LP_MEM,DR05_KEY_LP_7, DR05_KEY_LP_8, DR05_KEY_LP_9, 0xff,/*70*/ 0xff, 0xff, DR05_KEY_LP_STAR, DR05_KEY_LP_0, DR05_KEY_LP_HASH,/*75*/ 0xff, 0xff, DR05_KEY_LP_INTERN, DR05_KEY_LP_HOOK, DR05_KEY_LP_LNR,/*80*/ 0xff, 0xff, 0xff, 0xff, 0xff,/*85*/ 0xff, 0xff, 0xff, 0xff, 0xff };#endif/* FUNCTIONAL DESCRIPTION * * Handles the KBS events. * * If a key is pressed, the scan counter is activated. * If a key is released, the scan counter is stopped and * the key code is sent to the MMI for short pressed keys * * As multiple key presses are not supported, any other * condition lead to reinitialization. * * INTERFACE DECLARATION: ****************************************************/void p_dr15_KeyInterrupt(void){ u16 u16_State, u16_Code; u16_State = sys2_KBS.stat; u16_Code = sys2_KBS.code; sys2_KBS.stat= 0; // clear all flags if (u16_State == SYS2_KBS_KP && !G_u8_dr05_KeyActive) { /* press down in idle: activate scan counter */ u16_dr15_KeyCode= u16_Code; /* store code */ G_u8_dr05_KeyActive= 1; G_u8_os00_SystemActive= 1; /* set driver & os to active */ DR02_KEYCLICK; } else if (((u16_State == SYS2_KBS_KR) && G_u8_dr05_KeyActive && (u8_dr15_KeyScanCnt < DR15_KEY_LONG) && (u16_Code == u16_dr15_KeyCode))#ifdef DR05_FREE_MODE && (u8_dr15_KeypadMode == DR05_NORMAL_MODE)#endif ) { /* release of short press (long press handled by p_dr15_Keypad) */ p_dr15_KeySend(DR15_MODE_SHORT_PRESS); } else { /* anything else (e.g. long press release): reset driver */#ifdef DR05_FREE_MODE if (u8_dr15_KeypadMode == DR05_FREE_RELEASE_MODE) { p_os10_PutMsg(PTMI_ID,0,DR_KEYPAD_RELEASE_IND); }#endif p_dr15_KeyInit(DR05_KEY_INIT_IRQ); }} /* p_dr15_KeyInterrupt */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -