void I2C_Init() { /* Initialize I2C * - enable I2C clock via SYSAHBCLKCTRL * - resets I2C peripheral via clocking I2C pin in PRESETCTRL */ Chip_I2CM_Init(LPC_I2C); /* * Sets SCLH and SCLL based on PCLK (which is same as core clock) * and given speed */ Chip_I2CM_SetBusSpeed(LPC_I2C, SPEED_100KHZ); /* * Clears SI, STO, STA and AA bits * via CONCLR */ Chip_I2CM_ResetControl(LPC_I2C); /* * clears I2EN bit via CONCLR * Chip_I2CM_SendStart() will set I2EN bit */ Chip_I2CM_Disable(LPC_I2C); } |
void I2C_Init() { LPC_I2C_T *lpcI2C = LPC_I2C; Chip_I2CM_Init(lpcI2C); Chip_I2CM_SetBusSpeed(lpcI2C, SPEED_100KHZ); Chip_I2CM_ResetControl(lpcI2C); Chip_I2CM_Disable(lpcI2C); } |