void IrTherm_Init(void){ /* Enable clocks to SWM and IOCON to save power */ Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_SWM); Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_IOCON); Chip_SWM_MovablePinAssign(SWM_I2C_SDA_IO, 11); Chip_SWM_MovablePinAssign(SWM_I2C_SCL_IO, 10); #if (I2C_BITRATE > 400000) /* Enable Fast Mode Plus for I2C pins */ Chip_IOCON_PinSetI2CMode(LPC_IOCON, IOCON_PIO10, PIN_I2CMODE_FASTPLUS); Chip_IOCON_PinSetI2CMode(LPC_IOCON, IOCON_PIO11, PIN_I2CMODE_FASTPLUS); #else Chip_IOCON_PinSetI2CMode(LPC_IOCON, IOCON_PIO10, PIN_I2CMODE_STDFAST); Chip_IOCON_PinSetI2CMode(LPC_IOCON, IOCON_PIO11, PIN_I2CMODE_STDFAST); #endif /* Enable I2C clock and reset I2C peripheral - the boot ROM does not do this */ Chip_I2C_Init(); /* Setup the I2C handle */ i2cHandleMaster = LPC_I2CD_API->i2c_setup(LPC_I2C_BASE, i2cMasterHandleMEM); /* Set I2C bitrate */ LPC_I2CD_API->i2c_set_bitrate(i2cHandleMaster, Chip_Clock_GetSystemClockRate(), I2C_BITRATE); /* Disable the interrupt for the I2C */ NVIC_DisableIRQ(I2C_IRQn); /* Disable clocks to SWM and IOCON to save power */ Chip_Clock_DisablePeriphClock(SYSCTL_CLOCK_SWM); Chip_Clock_DisablePeriphClock(SYSCTL_CLOCK_IOCON); }
/* Initializes clock and pin muxing for I2C interface */ void Board_I2C_Init(void) { /* Enable the clock to the Switch Matrix */ Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_SWM); /* Connect the I2C_SDA and I2C_SCL signals to port pins(P0.10, P0.11) */ Chip_SWM_MovablePinAssign(SWM_I2C_SDA_IO, PIO10); Chip_SWM_MovablePinAssign(SWM_I2C_SCL_IO, PIO11); /* Enable Fast Mode Plus for I2C pins */ Chip_IOCON_PinSetI2CMode(LPC_IOCON, PIO10, PIN_I2CMODE_FASTPLUS); Chip_IOCON_PinSetI2CMode(LPC_IOCON, PIO11, PIN_I2CMODE_FASTPLUS); }
/* Initializes pin muxing for I2C interface - note that SystemInit() may already setup your pin muxing at system startup */ static void Init_I2C_PinMux(void) { #if (defined(BOARD_NXP_XPRESSO_812) || defined(BOARD_LPC812MAX)) /* Enable the clock to the Switch Matrix */ Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_SWM); /* Connect the I2C_SDA and I2C_SCL signals to port pins(P0.10, P0.11) */ Chip_SWM_MovablePinAssign(SWM_I2C_SDA_IO, 10); Chip_SWM_MovablePinAssign(SWM_I2C_SCL_IO, 11); /* Enable Fast Mode Plus for I2C pins */ Chip_IOCON_PinSetI2CMode(LPC_IOCON, IOCON_PIO10, PIN_I2CMODE_FASTPLUS); Chip_IOCON_PinSetI2CMode(LPC_IOCON, IOCON_PIO11, PIN_I2CMODE_FASTPLUS); /* Disable the clock to the Switch Matrix to save power */ Chip_Clock_DisablePeriphClock(SYSCTL_CLOCK_SWM); #else /* Configure your own I2C pin muxing here if needed */ #warning "No I2C pin muxing defined" #endif }