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

📄 kbd.c

📁 wince.net板级支持包BSP for EP9315
💻 C
📖 第 1 页 / 共 2 页
字号:
    // set the results
    KBD_PutRegisterValue(KBD_SCANINIT,nResult);
#endif // 0    

    return;
}


//****************************************************************************
// GKBD_Is3KeyResetEnabled
//****************************************************************************
// Use this method to query the current state of the 3-key reset feature.
// Refer to GKBD_Enable3KeyReset() for more  info on this feature.
//

unsigned char GKBD_Is3KeyResetEnabled(void)
{
    //
    // since on the hardware the bit is oposite to what we need (a 0
    // means that it is enabled) we invert it.
    //
    return (!(*KEYBOARD_SCANINIT & SCANINIT_DIS3KY));
}

//****************************************************************************
// GKBD_SetPreScale
//****************************************************************************
// Use theis method to set the Row/Column counter pre-scaler load value. 
// The prescale down counter counts the number of  1mhz clocks for every step 
// of the RC counter. When the  pre-scale counter reaches 0, the RC counter 
// steps. A pre-load  value of 0x002 will cause the RC counter to step every 
// three  clocks. The prescale value should never bet set to 0x00 or 
// 0x01, except for high speed counter tests as the key state 
// machine will not resolve keys properly for these values. 
//
void GKBD_SetPreScale
(
    unsigned short nScale // presale setting in 1mhz counts, will only use 10bits of data
                          // nScale must be a value greater then 1
)
{
    unsigned long nResult = *KEYBOARD_SCANINIT;

    // if a invalid scale value is set, break out of function
    if (nScale<=1)
        return;

    // mask out un-needed bits
    nScale &= SCANINIT_PRSCL_MASK;
    
    // mask out lower 10 bts
    nResult &= ~SCANINIT_PRSCL_MASK;

    // load 16 bit value into 32 bit
    nResult |= nScale;

    // set the results
    *KEYBOARD_SCANINIT = nResult;

    return;
}

//****************************************************************************
// GKBD_GetPreScale
//****************************************************************************
// Used to determine the current pre-scale counter setting. refer
// to GKBD_SetPreScale() for a complete expaination of this value 
//
unsigned short GKBD_GetPreScale( void)
{
    unsigned long nResult = *KEYBOARD_SCANINIT;

    // mask out any unneeded bits
    nResult &= SCANINIT_PRSCL_MASK;

    return ((unsigned short)nResult);
}


//****************************************************************************
// KBD_IsIrqActive
//****************************************************************************
// Use the method to determine if a keystate change was signaled by an 
// interrupt. This method is passed the result value because the "result" 
// value read by  KBD_GetRegisterValue(KBD_KEYS_REG) usually gets used again 
// by another method.
//
unsigned char KBD_IsIrqActive
(
    unsigned long result // pass a result from KBD_GetRegisterValue(KBD_KEYS_REG) 
)
{
#if 0
    // mask out anything we do not need
    result &= KBD_IRQ_ENABLED;

    // report the state of the IRQ bit;
    if (result == KBD_IRQ_ENABLED)
        return (TRUE);
    
    return (FALSE);
#endif // 0    
    return (TRUE);
}

//****************************************************************************
// KBD_IsOneKey
//****************************************************************************
// Use this method to query a result of a scan of the key state
// register for a one key hit.
//
unsigned char KBD_IsOneKey
(
    unsigned long result // pass the results of a KBD_GetRegisterValue(KBD_KEYS_REG)
)
{
    //
    // check the state of the bit
    //
    if (result & KEYREG_1KEY)
    {
        return (TRUE);
    }
    
    return (FALSE);
}

//****************************************************************************
// KBD_IsTwoKey
//****************************************************************************
// Use this method to query a result of a scan of the key state register 
// for a two key hit.
//
unsigned char KBD_IsTwoKey
(
    unsigned long result // pass the results of a KBD_GetRegisterValue(KBD_KEYS_REG)
)
{

    //
    // return the state of the bit
    //
    if (result & KEYREG_2KEYS)
    {
        return (TRUE);
    }
    
    return (FALSE);
}

//****************************************************************************
// KBD_GetFirstRow
//****************************************************************************
// Use this method to query the row of the key state  register for a single 
// key, or the first of a two-key hit.
//
unsigned char KBD_GetFirstRow
(
    unsigned long result // pass the results of a KBD_GetRegisterValue(KBD_KEYS_REG)
)
{

    return ((unsigned char)((result & KEYREG_KEY1ROW_MASK)>>KEYREG_KEY1ROW_SHIFT));

}


//****************************************************************************
// KBD_GetFirstCol
//****************************************************************************
// Use this method to query the column of the key state
// register for a single key, or the first of a two-key hit.
//
unsigned char KBD_GetFirstCol
(
    unsigned long result // pass the results of a KBD_GetRegisterValue(KBD_KEYS_REG)
)
{
    return ((unsigned char)((result & KEYREG_KEY1COL_MASK)>>KEYREG_KEY1COL_SHIFT));
}

//****************************************************************************
// KBD_GetSecondRow
//****************************************************************************
// Use this method to query the row of the key state register for the second 
// key of a two-key hit.
// 
//
unsigned char KBD_GetSecondRow
(
    unsigned long result // pass the results of a KBD_GetRegisterValue(KBD_KEYS_REG)
)
{
    return ((unsigned char)((result & KEYREG_KEY2ROW_MASK)>>KEYREG_KEY2ROW_SHIFT));
}


//****************************************************************************
// KBD_GetSecondCol
//****************************************************************************
// Use this method to query the column of the key state  register for the 
// second key of a two-key hit.
//
unsigned char KBD_GetSecondCol
(
    unsigned long result // pass the results of a KBD_GetRegisterValue(KBD_KEYS_REG)
)
{
    return ((unsigned char)((result & KEYREG_KEY2COL_MASK)>>KEYREG_KEY2COL_SHIFT));
}


//****************************************************************************
// GKBD_GetLastR1
//****************************************************************************
// Gets global row of the first or only key last pressed.
// 
//
unsigned char  GKBD_GetLastR1(void)
{
    return (g_nFirstRow);
}


//****************************************************************************
// GKBD_GetLastC1
//****************************************************************************
// Gets global column of the first or only key last pressed
// 
//
unsigned char GKBD_GetLastC1(void)
{
    return (g_nFirstCol);
}

//****************************************************************************
// GKBD_GetLastR2
//****************************************************************************
// Gets global row of the second key's last press of a 2-key press
// 
//
unsigned char GKBD_GetLastR2(void)
{
    return (g_nSecondRow);
}

//****************************************************************************
// GKBD_GetLastC2
//****************************************************************************
// Gets global column of the second key's last press of a 2-key press
// 
//
unsigned char GKBD_GetLastC2(void)
{
    return (g_nSecondCol);
}


//****************************************************************************
// GKBD_GetLastKeyStatus
//****************************************************************************
// 
// 
//
unsigned char GKBD_GetLastKeyStatus(void)
{
    return (!g_bNoKey);
}

⌨️ 快捷键说明

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