|
/****************************************************************************
* 函数名:
* 输入:
* 返回:
* 描述:
* ************************************************************************/
void Write_TMP006(unsigned char Reg_Address,unsigned char * data)
{
/* Write address, write 1 btye, read 8 bytes back */
i2cmXfer.slaveAddr = I2C_ADDR_7BIT;
tx[0] = Reg_Address; //寄存器地址
tx[1]=data[0]; //寄存器值 MSB
tx[2]=data[1]; //寄存器值 LSB
i2cmXfer.txBuff = tx;
i2cmXfer.rxBuff = rx;
i2cmXfer.txSz = 3;
i2cmXfer.rxSz = 0;
/* I2C master driver will block if blocking flag is used */
i2cmXfer.flags = ROM_I2CM_FLAG_BLOCKING;
/* Start transfer and wait for completion */
ROM_I2CM_Transfer(i2cmHandle, &i2cmXfer);
}
/****************************************************************************
* 函数名:
* 输入:
* 返回:
* 描述:
* ************************************************************************/
void Read_TMP006(unsigned char Reg_Address,unsigned char *RxData )
{
/* Write address, write 1 btye, read 8 bytes back */
i2cmXfer.slaveAddr = I2C_ADDR_7BIT;
tx[0] = Reg_Address; //寄存器地址
i2cmXfer.txBuff = tx;
i2cmXfer.rxBuff = rx;
i2cmXfer.txSz = 1;
i2cmXfer.rxSz = 2;
/* I2C master driver will block if blocking flag is used */
i2cmXfer.flags = ROM_I2CM_FLAG_BLOCKING;
/* Start transfer and wait for completion */
ROM_I2CM_Transfer(i2cmHandle, &i2cmXfer);
RxData[0]=rx[0];
RxData[1]=rx[1];
} |
|