keil_examples/I2C/i2c.c
/*****************************************************************************
** Function name:		I2CInit
**
** Descriptions:		Initialize I2C controller as a master
**
** parameters:			None
** Returned value:		None
** 
*****************************************************************************/
Function name:         I2CInit
Descriptions:          Initialize I2C controller as a master

None
Returned value:                None
Function name : I2CInit Descriptions : Initialize I2C controller as a master None Returned value : None
void I2C0Init( void ) 
{
  LPC_SC->PCONP |= (1 << 7);
  LPC_PINCON->PINSEL1 &= ~((0x03<<22)|(0x03<<24));
  LPC_PINCON->PINSEL1 |= ((0x01<<22)|(0x01<<24));	
  LPC_I2C0->CONCLR = I2CONCLR_AAC | I2CONCLR_SIC | I2CONCLR_STAC | I2CONCLR_I2ENC;    
#if FAST_MODE_PLUS
  LPC_PINCON->I2CPADCFG |= ((0x1<<0)|(0x1<<2));
  LPC_I2C0->SCLL   = I2SCLL_HS_SCLL;
  LPC_I2C0->SCLH   = I2SCLH_HS_SCLH;
#else
  LPC_PINCON->I2CPADCFG &= ~((0x1<<0)|(0x1<<2));
  LPC_I2C0->SCLL   = I2SCLL_SCLL;
  LPC_I2C0->SCLH   = I2SCLH_SCLH;
#endif
  NVIC_EnableIRQ(I2C0_IRQn);
  LPC_I2C0->CONSET = I2CONSET_I2EN;
  return;
}
void I2C0Init ( void ) { LPC_SC -> PCONP |= ( 1 << 7 ) ; LPC_PINCON -> PINSEL1 &= ~ ( ( 0x03 << 22 ) | ( 0x03 << 24 ) ) ; LPC_PINCON -> PINSEL1 |= ( ( 0x01 << 22 ) | ( 0x01 << 24 ) ) ; LPC_I2C0 -> CONCLR = I2CONCLR_AAC | I2CONCLR_SIC | I2CONCLR_STAC | I2CONCLR_I2ENC ; #if FAST_MODE_PLUS LPC_PINCON -> I2CPADCFG |= ( ( 0x1 << 0 ) | ( 0x1 << 2 ) ) ; LPC_I2C0 -> SCLL = I2SCLL_HS_SCLL ; LPC_I2C0 -> SCLH = I2SCLH_HS_SCLH ; #else LPC_PINCON -> I2CPADCFG &= ~ ( ( 0x1 << 0 ) | ( 0x1 << 2 ) ) ; LPC_I2C0 -> SCLL = I2SCLL_SCLL ; LPC_I2C0 -> SCLH = I2SCLH_SCLH ; #endif NVIC_EnableIRQ ( I2C0_IRQn ) ; LPC_I2C0 -> CONSET = I2CONSET_I2EN ; return ; }
Function name:         I2CInit
Descriptions:          Initialize I2C controller as a master
Function name : I2CInit Descriptions : Initialize I2C controller as a master
/* set PIO0.27 and PIO0.28 to I2C0 SDA and SCL */ /* function to 01 on both SDA and SCL. */ /*--- Clear flags ---*/ /*--- Reset registers ---*/ /* Install interrupt handler */