25 if (temp && temp->
inst) {
34 if (temp && temp->
inst) {
43 int16_t integer_part = hb;
51 float fractional = (lb >> 5) * 0.125f;
52 return (
float)integer_part + fractional;
62 int integer_part = (int)val;
63 if (integer_part < 0) integer_part = 0;
64 if (integer_part > 255) integer_part = 255;
65 *out_hb = (
u8)integer_part;
68 float fraction = val - integer_part;
69 if (fraction < 0) fraction = 0;
70 u8 frac_bits = (
u8)(fraction * 8.0f);
71 *out_lb = (frac_bits << 5);
void i2c_setMux(i2c_instance_t *inst, const uint8_t cr)
Set I2C MUX control register.
void i2c_writeData_b(i2c_instance_t *inst, u8 regAddr, u8 *data, u32 length)
Write data with an 8-bit register address over I2C and check rx ack for each transaction.
void i2c_readData_b(i2c_instance_t *inst, u8 regAddr, u8 *data, u32 length)
Read data with an 8-bit register address over I2C.
@ TEMP_SENSOR_SKIP
Skip the function */.
@ TEMP_SENSOR_OK
Successful Operation */.
u8 temp_writeTempReg(temp_sensor_instance_t *temp, const u8 reg, const u8 data)
Write a value to a register in the Temperature Sensor.
u8 temp_readTempReg(temp_sensor_instance_t *temp, const u8 reg)
Read a register from the Temperature Sensor.
u8 encode_temp_limit(float val, u8 is_extended, u8 *out_hb, u8 *out_lb)
Encode temperature limit into high and low byte format.
float calculate_temp_celsius(u8 hb, u8 lb, u8 is_extended)
Calculate temperature in Celsius from high and low byte format.
struct temp_sensor_instance temp_sensor_instance_t
Forward declaration of Temperature Sensor instance.
i2c_instance_t * inst
Pointer to I2C instance */.
Temperature Sensor driver API definitions.