typedef struct
{
unsigned char b7 :1; /*!< byte<7> */
unsigned char b6 :1; /*!< byte<6> */
unsigned char b5 :1; /*!< byte<5> */
unsigned char b4 :1; /*!< byte<4> */
unsigned char b3 :1; /*!< byte<3> */
unsigned char b2 :1; /*!< byte<2> */
unsigned char b1 :1; /*!< byte<1> */
unsigned char b0 :1; /*!< byte<0> */
} BIT8_t; /*!< 8bit structure */
typedef struct
{
unsigned int b15:1; /*!< word<15> */
unsigned int b14:1; /*!< word<14> */
unsigned int b13:1; /*!< word<13> */
unsigned int b12:1; /*!< word<12> */
unsigned int b11:1; /*!< word<11> */
unsigned int b10:1; /*!< word<10> */
unsigned int b9 :1; /*!< word<9> */
unsigned int b8 :1; /*!< word<8> */
unsigned int b7 :1; /*!< word<7> */
unsigned int b6 :1; /*!< word<6> */
unsigned int b5 :1; /*!< word<5> */
unsigned int b4 :1; /*!< word<4> */
unsigned int b3 :1; /*!< word<3> */
unsigned int b2 :1; /*!< word<2> */
unsigned int b1 :1; /*!< word<1> */
unsigned int b0 :1; /*!< word<0> */
} BIT16_t; /*!< 16bit structure */
typedef struct
{
unsigned long b31:1; /*!< dword<31> */
unsigned long b30:1; /*!< dword<30> */
unsigned long b29:1; /*!< dword<29> */
unsigned long b28:1; /*!< dword<28> */
unsigned long b27:1; /*!< dword<27> */
unsigned long b26:1; /*!< dword<26> */
unsigned long b25:1; /*!< dword<25> */
unsigned long b24:1; /*!< dword<24> */
unsigned long b23:1; /*!< dword<23> */
unsigned long b22:1; /*!< dword<22> */
unsigned long b21:1; /*!< dword<21> */
unsigned long b20:1; /*!< dword<20> */
unsigned long b19:1; /*!< dword<19> */
unsigned long b18:1; /*!< dword<18> */
unsigned long b17:1; /*!< dword<17> */
unsigned long b16:1; /*!< dword<16> */
unsigned long b15:1; /*!< dword<15> */
unsigned long b14:1; /*!< dword<14> */
unsigned long b13:1; /*!< dword<13> */
unsigned long b12:1; /*!< dword<12> */
unsigned long b11:1; /*!< dword<11> */
unsigned long b10:1; /*!< dword<10> */
unsigned long b9 :1; /*!< dword<9> */
unsigned long b8 :1; /*!< dword<8> */
unsigned long b7 :1; /*!< dword<7> */
unsigned long b6 :1; /*!< dword<6> */
unsigned long b5 :1; /*!< dword<5> */
unsigned long b4 :1; /*!< dword<4> */
unsigned long b3 :1; /*!< dword<3> */
unsigned long b2 :1; /*!< dword<2> */
unsigned long b1 :1; /*!< dword<1> */
unsigned long b0 :1; /*!< dword<0> */
} BIT32_t; /*!< 32bit structure */
typedef union
{
unsigned char byte;
BIT8_t BIT;
} UINT8u_t; /*!< 8bit union structure */
typedef union
{
unsigned int word;
unsigned char byte[2];
BIT16_t BIT;
} UINT16u_t; /*!< 16bit union structure */
typedef union
{
unsigned long dword;
unsigned int word[2];
unsigned char byte[4];
BIT32_t BIT;
}UINT32u_t; /*!< 32bit union structure */
UINT32u_t KeyInTempBuffer,KeyBuff;
void KeyInDetect(void)
{
KeyBuff.byte[ucScanPosition]=PINC & 0x1f;
if(KeyInTempBuffer.dword== KeyBuff.dword){
if(KeyInCount== 5) {
KeyInCount=6;
InputCurKey=KeyInTempBuffer.dword;
ucKeyIndex=GetKeyIndex(InputCurKey);
}
else{
if(KeyInCount<5){
KeyInCount++;
}
else{
if(KeyStatus.Usable == DISABLE) {
KEY_CheckValidKey();
}
}
}
}
else{
KeyInTempBuffer.dword = KeyBuff.dword;
KeyInCount=0;
InputCurKey = KEY_NO_INPUT;
}
if(++ucScanPosition>3){
ucScanPosition=0;
}
PORTA=(PINA & 0xf0) | TblKeyScan[ucScanPosition];
}