回调函数:
static void key_1_callback(void){
static int i = 0;
KEY_status_t keyGroup = {0};
if(i == 65534){
i = 0;
}
if(Set == EXINT_Irq**Get(ExtiCh01)){
do{
keyGroup.keys.key1 = PORT_GetBit(KEY1_PORT, KEY1_Pin);
keyGroup.keys.key2 = PORT_GetBit(KEY2_PORT, KEY2_Pin);
keyGroup.keys.key3 = PORT_GetBit(KEY3_PORT, KEY3_Pin);
if(keyGroup.status != 7) break;
}while(1);
Ddl_Delay1ms(40);
if((keyGroup.keys.key1 == Reset) && (Reset == PORT_GetBit(KEY1_PORT, KEY1_Pin))){
if(i%2== 1){
PORT_ResetBits(LED1_PORT,LED1_Pin);
}else{
PORT_SetBits(LED1_PORT,LED1_Pin);
}
logDebug("key1Press! cnt:%d\n",i);
i++;
}else if((keyGroup.keys.key2 == Reset) && (Reset == PORT_GetBit(KEY2_PORT, KEY2_Pin))){
if(i%2== 1){
PORT_ResetBits(LED2_PORT,LED2_Pin);
}else{
PORT_SetBits(LED2_PORT,LED2_Pin);
}
logDebug("key2Press! cnt:%d\n",i);
i++;
}else if((keyGroup.keys.key3 == Reset) && (Reset == PORT_GetBit(KEY3_PORT, KEY3_Pin))){
if(i%2== 1){
PORT_ResetBits(LED3_PORT,LED3_Pin);
}else{
PORT_SetBits(LED3_PORT,LED3_Pin);
}
logDebug("key3Press! cnt:%d\n",i);
i++;
}
/* clear int request flag */
EXINT_Irq**Clr(ExtiCh01);
}
}
|