一、IIC初始化,用于与EEPROM通讯
/*************************************************************************/
/* Name : I2C_Init */
/* */
/* Init IIC */
/* */
/* In : none */
/* Out : none */
/* Return: none */
/*************************************************************************/
void I2C_Init(void)
{
// Initialize I2C
I2caRegs.I2CMDR.bit.IRS = 0;
I2caRegs.I2CSAR = 0x0050; // Setup slave address
I2caRegs.I2CPSC.all = 7; // Prescaler - need 7-12 Mhz on module clk
I2caRegs.I2CCLKL = 30; // NOTE: must be non zero
I2caRegs.I2CCLKH = 30; // NOTE: must be non zero
I2caRegs.I2CIER.all = 0x00;
I2caRegs.I2CMDR.all = 0x0020; // Take I2C out of reset
// Stop I2C when suspended
I2caRegs.I2CFFTX.all = 0x0000; // Enable FIFO mode and TXFIFO
I2caRegs.I2CFFRX.all = 0x0000; // Enable RXFIFO, clear RXFFINT,
return;
}
二、EQEP初始化
/*************************************************************************/
/* Name : Init_EQEP */
/* */
/* Init EQEP */
/*