使用芯旺微KF32A156的芯片做预研项目,使用了I2C1外设,根据芯片规格书中的描述进行了配置:
/* I2c mode */
I2C_InitConfig.m_Mode = I2C_MODE_I2C;
/* I2c clock */
I2C_InitConfig.m_ClockSource = I2C_CLK_HFCLK;
/* Configure slave address width */
I2C_InitConfig.m_BADR10 = I2C_BUFRADDRESS_7BIT;
/* SMBus type */
I2C_InitConfig.m_MasterSlave = I2C_MODE_SMBUSDEVICE;
/* I2c baud rate low level time */
I2C_InitConfig.m_BaudRateL = 40;
/* I2c baud rate high level time */
I2C_InitConfig.m_BaudRateH = 40;
/* Enable ACK */
I2C_InitConfig.m_AckEn = TRUE;
/* Select the response signal as ACK */
I2C_InitConfig.m_AckData = I2C_ACKDATA_ACK;
I2C_Reset(I2C1_SFR);
/* Configue I2C */
I2C_Configuration(I2C1_SFR, &I2C_InitConfig);
/* Set slave address */
I2C_ADDR_Config(I2C1_SFR, 0, I2c_Address);
I2C_ADDR_Config(I2C1_SFR, 1, I2c_Address);
I2C_ADDR_Config(I2C1_SFR, 2, I2c