void iic_delay(void) { unsigend char delaytime = 125; while(delaytime--); } void TCA8418_reset(void) { GPIO_ResetBits(GPIOC,GPIO_Pin_10); //Pull down reset pin iic_delay( ); iic_delay( ); iic_delay( ); iic_delay( ); GPIO_SetBits(GPIOC,GPIO_Pin_10); //Pull up reset pin } sendbyteto_TCA8418(xxx,xx);//write to the xx data to the xxx register readbytefrom_TCA8418(xxx);//read the xxx register value void TCA8418_init(void) { TCA8418_reset()£» iic_delay( ); iic_delay( ); iic_delay( ); iic_delay( ); sendbyteto_TCA8418(KP_GPIO1,0x0F); //write 0x0F to the KP_GPIO1 register iic_delay( ); sendbyteto_TCA8418(KP_GPIO2,0x1F); iic_delay( ); sendbyteto_TCA8418(GPIO_DIR1,0x80); iic_delay( ); sendbyteto_TCA8418(GPIO_DIR2,0x60); iic_delay( ); sendbyteto_TCA8418(GPIO_INT_EN1,0x70); iic_delay( ); sendbyteto_TCA8418(GPIO_INT_EN2,0x80); iic_delay( ); sendbyteto_TCA8418(GPIO_INT_EN3,0x01); iic_delay( ); sendbyteto_TCA8418(GPIO_DAT_OUT1,0x00); iic_delay( ); sendbyteto_TCA8418(GPIO_DAT_OUT2,0x00); iic_delay( ); sendbyteto_TCA8418(GPIO_DAT_OUT3,0x00); iic_delay( ); sendbyteto_TCA8418(CFG,0x53);//CFG = 0x01 iic_delay( ); } void hand_tca8418_event(void) { unsigned char int_stat = 0x00; unsigned char key_lck_ec = 0x00; unsigned char key_event_a = 0x00; unsigned char temp = 0x00; unsigned char temp_cycle = 0x00; int_stat = readbytefrom_TCA8418(INT_STAT); //read the INT_STAT register value if(0x01 == int_stat) { key_lck_ec =readbytefrom_TCA8418(KEY_LCK_EC); temp = key_lck_ec &0x0f; if(0x01 == temp) { key_event_a = readbytefrom_TCA8418(KEY_EVENT_A); MSG_DRV_SEND(MOD_KEY_ID,key_event_a); //Send the key events and parameters to middleware } else { if(temp >10) temp = 10; for(temp_cycle = 0;temp_cycle