⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cdr15key.c

📁 keypad驱动程序
💻 C
📖 第 1 页 / 共 2 页
字号:
/* FUNCTIONAL DESCRIPTION * * Checks the key press duration and sends the key code to the MMI for  * the long pressed keys. * * It relies on being called every 10ms while G_u8_dr05_KeyActive. * * INTERFACE DECLARATION: ****************************************************/void p_dr15_Keypad(void){  if(G_u8_dr05_KeyActive)  {      u8_dr15_KeyScanCnt++;      /* prevent overflow */      if(u8_dr15_KeyScanCnt == 0)      {          u8_dr15_KeyScanCnt--;      }#ifdef DR05_FREE_MODE      if((u8_dr15_KeyScanCnt == DR15_KEY_LONG) &&          (u8_dr15_KeypadMode == DR05_NORMAL_MODE))      {          /* send LP meaning (driver remains active until key released) */          p_dr15_KeySend(DR15_MODE_LONG_PRESS);      }      else if((u8_dr15_KeypadMode == DR05_FREE_RELEASE_MODE) &&          (u8_dr15_KeyScanCnt == DR15_KEY_FREE_DELAY))      {          /* send SP meaning in FREE_RELEASE_MODE (driver remains active          until key released) */          p_dr15_KeySend(DR15_MODE_SHORT_PRESS);      }#else      if(u8_dr15_KeyScanCnt == DR15_KEY_LONG)      {          /* send LP meaning (driver remains active until key released) */          p_dr15_KeySend(DR15_MODE_LONG_PRESS);      }#endif  }} /* p_dr15_Keypad *//* FUNCTIONAL DESCRIPTION * * Converts u8_dr15_KeyCode value supplied by KBS to the G_u8_dr05_ActKey code * which is understood by the MMI. * The event DR_KEYPAD_IND is sent to the MMI and the driver is prepared * for another keypress. * * PARAMETER * u8_Modifier  DR15_MODE_SHORT_PRESS lower part of u8_dr15_KeyCodes table will be used *              DR15_MODE_LONG_PRESS  upper part of u8_dr15_KeyCodes table will be used * * INTERFACE DECLARATION: ****************************************************/void p_dr15_KeySend(u8 u8_Modifier){#ifdef PT_MODULE#if (VDSW_FEATURES & VDSW_MMS_PRO)   int Key;#endif#endif     /* set the key to the shared data */  if (u16_dr15_KeyCode == 0xFFFF)  {      return; /* should not happen */  }    G_u8_dr05_ActKey= u8_dr15_KeyCodes[u16_dr15_KeyCode+ u8_Modifier];  /* send the key also in act_xinfo */#ifdef PT_MODULE#ifndef WDCT_BMP  p_os10_PutMsg(PTRM_ID,0,MI_MAC_PREPARE_REQ);  #endif# if (VDSW_FEATURES & VDSW_TRAIN_LEC)   /* the next features are used to train the modem                           */   /* in the base they will result in a PS_DIAL_IND to the MMI and the FTMMI  */   /* then has to take some actions                                           */  if(G_u8_dr05_ActKey == DR05_KEY_LP_8)  {      /* send escape sequence to the base to signal that the outgoing call is */      /* a modem call. Some functionality in the DSP will be disabled then    */      /* Ensure that G_u8_hl00_Keypad is empty and send release keys to FT */      G_u8_hl00_KeyWIndex = 4; /* write ESC key directly to buffer */      G_u8_hl00_KeyRIndex = 0;      G_u8_hl00_Keypad[0]= AP03_KEY_ESCAPE;      G_u8_hl00_Keypad[1]= AP03_KEY_ASCII_M;  /* modem                        */        G_u8_hl00_Keypad[2]= AP03_KEY_ASCII_I;  /* initialize                   */        G_u8_hl00_Keypad[3]= AP03_KEY_ASCII_C;  /* call                         */        p_os10_PutMsg(PTCC_ID,0,MI_KEYPAD_REQ);  }  if(G_u8_dr05_ActKey == DR05_KEY_LP_9)  {      /* send esc sequence to begin training of the LEC in the base           */      /* Ensure that G_u8_hl00_Keypad is empty and send release keys to FT    */      G_u8_hl00_KeyWIndex = 4;    /* write ESC key directly to buffer         */      G_u8_hl00_KeyRIndex = 0;      G_u8_hl00_Keypad[0]= AP03_KEY_ESCAPE;      G_u8_hl00_Keypad[1]= AP03_KEY_ASCII_M;  /* modem                        */        G_u8_hl00_Keypad[2]= AP03_KEY_ASCII_T;  /* training                     */        G_u8_hl00_Keypad[3]= AP03_KEY_ASCII_B;  /* begin                        */        p_os10_PutMsg(PTCC_ID,0,MI_KEYPAD_REQ);  }  if(G_u8_dr05_ActKey == DR05_KEY_LP_0)  {      /* Send esc sequence that training session for LEC ends and store       */      /* the actual value in the base                                         */      /* Ensure that G_u8_hl00_Keypad is empty and send release keys to FT */      G_u8_hl00_KeyWIndex = 4; /* write ESC key directly to buffer */      G_u8_hl00_KeyRIndex = 0;      G_u8_hl00_Keypad[0]= AP03_KEY_ESCAPE;      G_u8_hl00_Keypad[1]= AP03_KEY_ASCII_M;  /* modem                        */        G_u8_hl00_Keypad[2]= AP03_KEY_ASCII_T;  /* training                     */        G_u8_hl00_Keypad[3]= AP03_KEY_ASCII_E;  /* end                          */        p_os10_PutMsg(PTCC_ID,0,MI_KEYPAD_REQ);  }  else  # endif /*(VDSW_FEATURES & VDSW_TRAIN_LEC)*/#if (VDSW_FEATURES & VDSW_MMS_PRO)    Key = (int) G_u8_dr05_ActKey;  GUI_StoreKeyMsg(Key,1); //key pressed  p_os10_PutMsgInfo(PTMI_ID,0,DR_KEYPAD_IND,G_u8_dr05_ActKey); // eco on the B&W display#else  p_os10_PutMsgInfo(PTMI_ID,0,DR_KEYPAD_IND,G_u8_dr05_ActKey);#endif  //   MMS_PRO#else  {      p_os10_PutMsgInfo(FTMI_ID,0,DR_KEYPAD_IND,(u16) G_u8_dr05_ActKey);  }#endif  /* reinitialize driver */  p_dr15_KeyInit(DR05_KEY_INIT_IRQ);} /* p_dr15_KeySend */#ifdef DR05_FREE_MODE/* FUNCTIONAL DESCRIPTION * * Enables either normal of freestyle key detection * * INTERFACE DECLARATION: ****************************************************/void p_dr15_KeypadMode(t_en_dr05_KeypadMode en_NewMode){  SYS5_DISABLE_IRQ;  if((u8_dr15_KeypadMode != DR05_NORMAL_MODE) &&      (en_NewMode == DR05_NORMAL_MODE))  {      /* Send another KEYPAD_RELEASE_IND so MMI cannot get stuck */      p_os10_PutMsg(PTMI_ID,0,DR_KEYPAD_RELEASE_IND);      u8_dr15_KeyScanCnt = 0xFF;      u8_dr15_KeypadMode = DR05_NORMAL_MODE;  }  else if((u8_dr15_KeypadMode == DR05_NORMAL_MODE) &&      (en_NewMode == DR05_FREE_RELEASE_MODE))  {      u8_dr15_KeypadMode = DR05_FREE_RELEASE_MODE/* _PENDING */;  }  SYS5_ENABLE_IRQ;}#endif /* DR05_FREE_MODE *//* FUNCTIONAL DESCRIPTION * * Initialises the keypad driver and prepares the driver for the * detection of the next keypress. * * It is called during system startup and also from inside the driver  * after a key is accepted or after an error conditions has been detected. * * INTERFACE DECLARATION: ****************************************************/void p_dr15_KeyInit(u8 u8_CalledFrom){  /* Set memory to default values */  G_u8_dr05_KeyActive = 0;         /* driver in idle mode                    */  u8_dr15_KeyScanCnt  = 0;         /* scan counter reset                     */  u16_dr15_KeyCode    = 0xFFFF;    /* impossible value                       */#if !defined(VegaPro)  /* if the keyboard scanner not yet active */  if(!(sys0_SCU.pb_pstat & SYS0_SCU_KBS_POWER_MASK))  {      /* activate KBS */      sys0_SCU.pb_pcon_on |= SYS0_SCU_KBS_POWER_MASK;      /* wait until powered on */      while(!(VOLATILE(sys0_SCU.pb_pstat,u32) & SYS0_SCU_KBS_POWER_MASK));      /* block reset */      sys2_KBS.global |= SYS2_BLRES_KBS;      /* wait until completed */      while(VOLATILE(sys2_KBS.global,u16) & SYS2_BLRES_KBS);  }#endif    /* Setup/reset KBS hardware (this example keeps the reset values */  sys2_KBS.con= 0 * SYS2_KBS_RLSMODE  /* RLSMODE  (0=>KBSERR for multi press) */          +   0 * SYS2_KBS_KBSLOOPS         /* KBSLOOPS (0=>no extra debounce loop) */          +   0 * SYS2_KBS_FKSCLK           /* FKSCLK   (0=>slow scanning during press) */          +   0 * SYS2_KBS_SKSCLK180ms      /* SKSCLK   (0=>fastest scanning) */          ;  sys2_KBS.stat= 0;        /* clear all flags */  /* the settings for mux2 and up2 already done in cdr10int.c*/  /* GPIO 15 is output */  sys2_GPIO.dir1 |= SYS2_GPIO1_15_KBIO0;  sys2_GPIO.dir2 &= ~DR15_GPIO2_AS_KP_INPUT;  /* output a '0' */  sys2_GPIO.dat1 &= ~SYS2_GPIO1_15_KBIO0;  sys2_GPIO.dat2 &= ~DR15_GPIO2_AS_KP_INPUT;  /* disable GPIO interrupt generation on the KBS  pins */  sys2_GPIO.cfg2 &= ~DR15_GPIO2_AS_KP_INPUT;  /* clear all pending requests */  sys2_GPIO.stat2 &= ~DR15_GPIO2_AS_KP_INPUT;  if(u8_CalledFrom == DR05_KEY_INIT_STARTUP)  {      sys0_ICU.irq_enbs= SYS0_ICU_INT_KBS_IRQ; /* enable irq */  }} /* p_dr15_KeyInit *//* FUNCTIONAL DESCRIPTION * * Disables all keys by masking the KBS interrupt. * * INTERFACE DECLARATION: ****************************************************/void p_dr15_KeyDisable(void){  sys0_ICU.irq_enbc= SYS0_ICU_INT_KBS_IRQ; /* disable irq */} /* p_dr15_KeyDisable *//* FUNCTIONAL DESCRIPTION * * Enables any key press to issue the wakeup event. * * Note: it is assumed, that interrupts are disabled, when this function * is called. * * INTERFACE DECLARATION: ****************************************************/void p_dr15_KeyEnablePon(void){  /* DESIGN   *   * also see PCD801X objective specification   *    * 1.Disable the keypad scanner.   * 2.GPIO[15] is set to output a 0.   * 3.Interrupt polarity for GPIO[24:16] to 1.   * 4.Configure GPIO[24:16] to be level sensitive.   * 5.Enable pull-up resistors to be connected to GPIO[24:16].   * 6.GPIO[24:16] can cause an interrupt (ext_startup).   * 7.Enable GPIO as a wakeup source.   */  /* Keep RFSIGs as output */  sys2_GPIO.mux1 &= (     SYS2_GPIO1_RFSIG7_SEL_RF7 |     SYS2_GPIO1_RFSIG6_SEL     |     SYS2_GPIO1_RFSIG5_SEL     |     SYS2_GPIO1_RFSIG4_SEL     );  sys2_GPIO.mux2 = 0;  /* dir: GPIO15 out, others in */  sys2_GPIO.dir1 = SYS2_GPIO1_15_KBIO0;  sys2_GPIO.dir2 = 0;    /* dat: all low, including GPIO15 */  sys2_GPIO.dat1 = 0;  sys2_GPIO.dat2 = 0;  /* pol, int, up, cfg: GPIO[24:16] to 1 */  sys2_GPIO.pol1 = 0;  sys2_GPIO.int1 = 0;  sys2_GPIO.up1 = 0;  sys2_GPIO.cfg1 = 0;    sys2_GPIO.pol2 = sys2_GPIO.int2 = sys2_GPIO.up2 =    sys2_GPIO.cfg2 = DR15_GPIO2_AS_KP_INPUT;    /* stat: clear all pending requests */  sys2_GPIO.stat1 = 0;  sys2_GPIO.stat2 = 0;    /* wake_up_enbs: only GPIO */  sys0_ICU.wake_up_enbc = ~0;         /* clear all other wakeup sources */  sys0_ICU.wake_up_enbs = SYS0_ICU_INT_GPIO_WAKE;  } /* p_dr15_KeyEnablePon */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -