Hi team,
The customer is using TCA8418. The schematic and their code is in the attachment. Please check the attachment.
1. Their design is as below:
(1). COL0-COL4 and ROW0-ROW3 combined to a 4*5 KEYPAD;
Best Wishes,
Mickey Zhang
Asia Customer Support Center
Texas Instruments
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 <temp;temp_cycle++) { readbytefrom_TCA8418(KEY_EVENT_A); } } } else if(0x02 == int_stat) { temp = readbytefrom_TCA8418(GPIO_INT_STAT1); if(0x10 == temp) { temp = readbytefrom_TCA8418(GPIO_INT_LVL1); if(0x10 == temp) { MSG_DRV_SEND(MOD_KEY_ID,0x65); set_low_extio0_int( ); } else { MSG_DRV_SEND(MOD_KEY_ID,0x65|0x80); set_high_extio0_int(); } } readbytefrom_TCA8418(GPIO_DAT_STAT1); readbytefrom_TCA8418(GPIO_DAT_STAT1); readbytefrom_TCA8418(GPIO_DAT_STAT2); readbytefrom_TCA8418(GPIO_DAT_STAT2); readbytefrom_TCA8418(GPIO_DAT_STAT3); readbytefrom_TCA8418(GPIO_DAT_STAT3); } else { } sendbyteto_TCA8418(INT_STAT,0x1F); } unsigned char ext_status = 0x00; void set_high_extio0_int(void) { ext_status |= 0x10; sendbyteto_TCA8418(GPIO_INT_LVL1,ext_status); } void set_low_extio0_int(void) { ext_status &= 0xef; sendbyteto_TCA8418(GPIO_INT_LVL1,ext_status); }