表1 |
表2 |
接著在return的時候將High/Low byte合併,參考表2. 回傳值是溫度值x10
不過這邊未考慮 "負"值.
uint32_t read_temp(void)
{
uint32_t tempH,tempL;
I2CWriteLength = 2;
I2CReadLength = 1;
I2CMasterBuffer[0] = NXP5600_I2C_WRITE;
I2CMasterBuffer[1] = NXP_5600_REG_LTHB;
I2CMasterBuffer[2] = NXP5600_I2C_READ;
I2CEngine();
tempH = I2CSlaveBuffer[0];
I2CWriteLength = 2;
I2CReadLength = 1;
I2CMasterBuffer[0] = NXP5600_I2C_WRITE;
I2CMasterBuffer[1] = NXP_5600_REG_ATLB;
I2CMasterBuffer[2] = NXP5600_I2C_READ;
I2CEngine();
tempL = I2CSlaveBuffer[0];
tempL = (tempL >> 5)*125;
return (tempH*10+tempL/100) ;
}
0 留言:
張貼留言