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

None
Returned value:                None
Function name : I2C1Init Descriptions : Initialize I2C controller as a master None Returned value : None
void I2C1Init( void ) 
{
  LPC_SC->PCONP |= (1 << 19);
#if 0
  LPC_PINCON->PINSEL0 &= ~((0x3<<0)|(0x3<<2));
  LPC_PINCON->PINSEL0 |= ((0x3<<0)|(0x3<<2));
  LPC_PINCON->PINMODE0 &= ~((0x3<<0)|(0x3<<2));
  LPC_PINCON->PINMODE0 |= ((0x2<<0)|(0x2<<2));		
  LPC_PINCON->PINMODE_OD0 |= ((0x01<<0)|(0x1<<1));		
#endif
#if 1
  LPC_PINCON->PINSEL1 &= ~((0x3<<6)|(0x3<<8));
  LPC_PINCON->PINSEL1 |= ((0x3<<6)|(0x3<<8));
  LPC_PINCON->PINMODE1 &= ~((0x3<<6)|(0x3<<8));
  LPC_PINCON->PINMODE1 |= ((0x2<<6)|(0x2<<8));	
  LPC_PINCON->PINMODE_OD0 |= ((0x1<<19)|(0x1<<20));	
#endif
  LPC_I2C1->CONCLR = I2CONCLR_AAC | I2CONCLR_SIC | I2CONCLR_STAC | I2CONCLR_I2ENC;    
  LPC_I2C1->SCLL   = I2SCLL_SCLL;
  LPC_I2C1->SCLH   = I2SCLH_SCLH;
  NVIC_EnableIRQ(I2C1_IRQn);
  LPC_I2C1->CONSET = I2CONSET_I2EN;
  return;
}
void I2C1Init ( void ) { LPC_SC -> PCONP |= ( 1 << 19 ) ; #if 0 LPC_PINCON -> PINSEL0 &= ~ ( ( 0x3 << 0 ) | ( 0x3 << 2 ) ) ; LPC_PINCON -> PINSEL0 |= ( ( 0x3 << 0 ) | ( 0x3 << 2 ) ) ; LPC_PINCON -> PINMODE0 &= ~ ( ( 0x3 << 0 ) | ( 0x3 << 2 ) ) ; LPC_PINCON -> PINMODE0 |= ( ( 0x2 << 0 ) | ( 0x2 << 2 ) ) ; LPC_PINCON -> PINMODE_OD0 |= ( ( 0x01 << 0 ) | ( 0x1 << 1 ) ) ; #endif #if 1 LPC_PINCON -> PINSEL1 &= ~ ( ( 0x3 << 6 ) | ( 0x3 << 8 ) ) ; LPC_PINCON -> PINSEL1 |= ( ( 0x3 << 6 ) | ( 0x3 << 8 ) ) ; LPC_PINCON -> PINMODE1 &= ~ ( ( 0x3 << 6 ) | ( 0x3 << 8 ) ) ; LPC_PINCON -> PINMODE1 |= ( ( 0x2 << 6 ) | ( 0x2 << 8 ) ) ; LPC_PINCON -> PINMODE_OD0 |= ( ( 0x1 << 19 ) | ( 0x1 << 20 ) ) ; #endif LPC_I2C1 -> CONCLR = I2CONCLR_AAC | I2CONCLR_SIC | I2CONCLR_STAC | I2CONCLR_I2ENC ; LPC_I2C1 -> SCLL = I2SCLL_SCLL ; LPC_I2C1 -> SCLH = I2SCLH_SCLH ; NVIC_EnableIRQ ( I2C1_IRQn ) ; LPC_I2C1 -> CONSET = I2CONSET_I2EN ; return ; }
Function name:         I2C1Init
Descriptions:          Initialize I2C controller as a master
Function name : I2C1Init Descriptions : Initialize I2C controller as a master
/* set PIO0.0 and PIO0.1 to I2C1 SDA and SCL */ /* function to 11 on both SDA and SCL. */ /* No pull-up no pull-down */ /* Open drain */ /* set PIO0.19 and PIO0.20 to I2C1 SDA and SCL */ /* function to 11 on both SDA and SCL. */ /* No pull-up no pull-down */ /*--- Clear flags ---*/ /*--- Reset registers ---*/ /* Install interrupt handler */