42 if (temp && temp->
inst) {
51 if (temp && temp->
inst) {
60 int16_t integer_part = hb;
68 float fractional = (lb >> 5) * 0.125f;
69 return (
float)integer_part + fractional;
79 int integer_part = (int)val;
80 if (integer_part < 0) integer_part = 0;
81 if (integer_part > 255) integer_part = 255;
82 *out_hb = (
u8)integer_part;
85 float fraction = val - integer_part;
86 if (fraction < 0) fraction = 0;
87 u8 frac_bits = (
u8)(fraction * 8.0f);
88 *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_status_t
Temperature Sensor Status List.
@ TEMP_SENSOR_SKIP
Skip the function */.
@ TEMP_SENSOR_OK
Successful Operation */.
@ TEMP_SENSOR_ERR
Failed to retrieve/write value */.
temp_sensor_status_t tempSensor_enableErrorInterrupt(temp_sensor_instance_t *temp)
Enable error interrupt for the Temperature Sensor.
temp_sensor_status_t tempSensor_applyConfig(temp_sensor_instance_t *temp)
Apply I2C + Temp Sensor configuration.
u8 tempSensor_readTempReg(temp_sensor_instance_t *temp, const u8 reg)
Read a register from the Temperature Sensor.
u8 tempSensor_writeTempReg(temp_sensor_instance_t *temp, const u8 reg, const u8 data)
Write a value to a register in the Temperature Sensor.
u8 tempSensor_encodeTempLimit(float val, u8 is_extended, u8 *out_hb, u8 *out_lb)
Encode temperature limit into high and low byte format.
float tempSensor_calTempCelsius(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.
temp_sensor_status_t(* applyConfig)(temp_sensor_instance_t *temp)
temp_sensor_status_t(* enableErrorInterrupt)(temp_sensor_instance_t *temp)
const temp_sensor_api_t * drv
Pointer to Temperature Sensor API structure */.
i2c_instance_t * inst
Pointer to I2C instance */.
Temperature Sensor driver API definitions.