I2C_Write(MHD_F,0x01);
I2C_Write(NHD_F,0x01);
I2C_Write(NCL_F,0xFF);
I2C_Write(FDL_F,0x02);
//SectionC
//Thisgroupsetstouchandreleasethresholdsforeachelectrode
I2C_Write(ELE0_T,TOU_THRESH);
I2C_Write(ELE0_R,REL_THRESH);
I2C_Write(ELE1_T,TOU_THRESH);
I2C_Write(ELE1_R,REL_THRESH);
I2C_Write(ELE2_T,TOU_THRESH);
I2C_Write(ELE2_R,REL_THRESH);
I2C_Write(ELE3_T,TOU_THRESH);
I2C_Write(ELE3_R,REL_THRESH);
I2C_Write(ELE4_T,TOU_THRESH);
I2C_Write(ELE4_R,REL_THRESH);
I2C_Write(ELE5_T,TOU_THRESH);
I2C_Write(ELE5_R,REL_THRESH);
I2C_Write(ELE6_T,TOU_THRESH);
I2C_Write(ELE6_R,REL_THRESH);
I2C_Write(ELE7_T,TOU_THRESH);
I2C_Write(ELE7_R,REL_THRESH);
I2C_Write(ELE8_T,TOU_THRESH);
I2C_Write(ELE8_R,REL_THRESH);
I2C_Write(ELE9_T,TOU_THRESH);
I2C_Write(ELE9_R,REL_THRESH);
I2C_Write(ELE10_T,TOU_THRESH);
I2C_Write(ELE10_R,REL_THRESH);
I2C_Write(ELE11_T,TOU_THRESH);
I2C_Write(ELE11_R,REL_THRESH);
//SectionD
//SettheFilterConfiguration
//SetESI2
I2C_Write(FIL_CFG,0x04);
//SectionE
//ElectrodeConfiguration
//Enable6Electrodesandsettorunmode
//SetELE_CFGto0x00toreturntostandbymode
//I2C_Write(ELE_CFG,0x0C);//Enablesall12Electrodes
I2C_Write(ELE_CFG,0x06);//Enablefirst6electrodes
//SectionF
//EnableAutoConfigandautoReconfig
I2C_Write(ATO_CFG0,0x0B);
I2C_Write(ATO_CFGU,0xC9);//USL=(Vdd-0.7)/vdd*256=0xC9@3.3VI2C_Write(ATO_CFGL,0x82);//LSL=0.65*USL=0x82@3.3V
I2C_Write(ATO_CFGL,0x82);
I2C_Write(ATO_CFGT,0xB5);//Target=0.9*USL=0xB5@3.3V
}
intmain(void)
{
init_uart(9600);//串口0初始化
/*************IO初始化**************/
DDRC|=0x30;SCL_H;SDA_H;
DDRC&=0xf7;//PC3input
PORTC|=0x08;
DDRD&=0xEF;PORTD|=0x10;
mpr121QuickConfig();
while(PIND&0x10);//PD4isAkeyIfpressed,continue
send_date(0xAA);
while
(1)
{
while(IRQ);
//send_date(0x55);
//send_date(I2C_ReadB(0x01));
send_date(I2C_ReadB(0x00));//sendthetouch_value
delay_nms(500);
}
}