msp430硬件i2c驱动

参考自博客:https://www.amobbs.com/forum.php?mod=viewthread&tid=5548190&page=1&authorid=88848

 

 

static void hdc_i2c_init(void)
{
  P3SEL |= (BIT0 | BIT1); 
  UCB0CTL1 |= UCSWRST;
  UCB0CTL0 = UCMST + UCMODE_3 + UCSYNC ;
  UCB0CTL1 |= UCSSEL_2;
  UCB0BR0 = 40;
  UCB0BR1 = 0;
  UCB0CTL0 &= ~UCSLA10;
  UCB0I2CSA = (HDC2010_ADDR>>1);  //因为msp430硬件不需要在地址里体现读写位,只需7位地址即可
  UCB0CTL1 &= ~UCSWRST;
}

void hdc2010_Init()
{
  hdc_i2c_init();
  
  /* Startup sequence */
//  i2c_send(ADDR_WR, ConfigReg, 2);
//  i2c_send(ADDR_WR, MeaConfigReg, 2);
}

void hdc_SingleAcquisition(U8 *recvBuf)
{
  //Start Conversion
  i2c_send(ADDR_WR, StartConvert, 2);
  

  
  i2c_send(ADDR_WR, ReadAddr, 1);
  i2c_receive(ADDR_RD, recvBuf, 4);  //T

你可能感兴趣的:(芯片驱动类)