haolaishi 发表于 2014-6-2 23:19 
上初始化程序图
void I2C_Init(void)
{
SYS->IPRSTC2 |= SYS_IPRSTC2_I2C1_RST_Msk; //C: Peripheral Reset Control Resister 2: I2C-bit = 1 => controller reset
SYS->IPRSTC2 &= ~SYS_IPRSTC2_I2C1_RST_Msk;//C: Peripheral Reset Control Resister 2: I2C-bit = 0 => set controller to normal mode
I2C1->I2CON |= I2C_I2CON_ENS1_Msk;
I2C1->I2CLK = I2C_I2CLK_DIV4(120); /* 48000000Hz / 4 / 120 = 100000Hz */
_I2C_ENABLE_TIMEOUT_COUNTER(I2C1);
}
|