43#define CHIP_NAME "NXP LM75B"
44#define MANUFACTURER_NAME "NXP"
45#define SUPPLY_VOLTAGE_MIN 2.8f
46#define SUPPLY_VOLTAGE_MAX 5.5f
47#define MAX_CURRENT 10.0f
48#define TEMPERATURE_MIN -55.0f
49#define TEMPERATURE_MAX 125.0f
50#define DRIVER_VERSION 2000
55#define LM75B_REG_CONF 0x01
56#define LM75B_REG_TEMP 0x00
57#define LM75B_REG_TOS 0x03
58#define LM75B_REG_THYST 0x02
127 *reg = ((uint16_t)(c / 0.5f) & 0xFF) << 7;
131 *reg = (1<<15) | (~(((uint16_t)(-c /0.5f) & 0xFF) - 1))<<7;
160 if ((reg & 0x0100) != 0)
162 *c= -0.5f * (float)((uint16_t)((~(reg))&0xFF) + 1);
166 *c = (float)(reg) * 0.5f;
197 buf[0] = (hysteresis >> 8) & 0xFF;
198 buf[1] = hysteresis & 0xFF;
202 handle->
debug_print(
"lm75b: write hysteresis failed.\n");
238 handle->
debug_print(
"lm75b: read hysteresis failed.\n");
242 *hysteresis = (uint16_t)(((uint16_t)buf[0]) << 8) | buf[1];
271 *reg = ((uint16_t)(c / 0.5f) & 0xFF) << 7;
275 *reg = (1<<15) | (~(((uint16_t)(-c /0.5f) & 0xFF) - 1))<<7;
304 if ((reg & 0x0100) != 0)
306 *c= -0.5f * (float)((uint16_t)((~(reg))&0xFF) + 1);
310 *c = (float)(reg) * 0.5f;
341 buf[0] = (threshold >> 8) & 0xFF;
342 buf[1] = threshold & 0xFF;
386 *threshold = (uint16_t)(((uint16_t)buf[0]) << 8) | buf[1];
419 handle->
debug_print(
"lm75b: read configure failed.\n");
423 prev &= ~(0x03 << 3);
424 prev |= fault_queue << 3;
428 handle->
debug_print(
"lm75b: write configure failed.\n");
464 handle->
debug_print(
"lm75b: read configure failed.\n");
501 handle->
debug_print(
"lm75b: read configure failed.\n");
506 prev |= polarity << 2;
510 handle->
debug_print(
"lm75b: write configure failed.\n");
546 handle->
debug_print(
"lm75b: read configure failed.\n");
583 handle->
debug_print(
"lm75b: read configure failed.\n");
592 handle->
debug_print(
"lm75b: write configure failed.\n");
628 handle->
debug_print(
"lm75b: read configure failed.\n");
665 handle->
debug_print(
"lm75b: read configure failed.\n");
674 handle->
debug_print(
"lm75b: write configure failed.\n");
710 handle->
debug_print(
"lm75b: read configure failed.\n");
747 handle->
debug_print(
"lm75b: iic_deinit is null.\n");
759 handle->
debug_print(
"lm75b: iic_write is null.\n");
808 handle->
debug_print(
"lm75b: read configure failed.\n");
816 handle->
debug_print(
"lm75b: write configure failed.\n");
822 handle->
debug_print(
"lm75b: iic deinit failed.\n");
857 memset(buf, 0,
sizeof(uint8_t) * 2);
865 *raw = (uint16_t)(((uint16_t)buf[0]) << 8) | buf[1];
867 if (((*raw) & 0x0400) != 0)
869 *raw = (*raw) | 0xF800U;
870 *s = (float)(-(~(*raw) + 1)) * 0.125f;
874 *s = (float)(*raw) * 0.125f;
#define SUPPLY_VOLTAGE_MAX
#define LM75B_REG_CONF
chip register definition
#define MANUFACTURER_NAME
#define SUPPLY_VOLTAGE_MIN
#define CHIP_NAME
chip information definition
struct lm75b_handle_s lm75b_handle_t
lm75b handle structure definition
lm75b_mode_t
lm75b os polarity enumeration definition
uint8_t lm75b_set_mode(lm75b_handle_t *handle, lm75b_mode_t mode)
set the chip mode
lm75b_fault_queue_t
lm75b fault queue enumeration definition
lm75b_address_t
lm75b address enumeration definition
uint8_t lm75b_get_mode(lm75b_handle_t *handle, lm75b_mode_t *mode)
get the chip mode
struct lm75b_info_s lm75b_info_t
lm75b information structure definition
lm75b_os_polarity_t
lm75b os polarity enumeration definition
uint8_t lm75b_read(lm75b_handle_t *handle, uint16_t *raw, float *s)
read data from the chip
uint8_t lm75b_info(lm75b_info_t *info)
get chip's information
uint8_t lm75b_set_addr_pin(lm75b_handle_t *handle, lm75b_address_t addr_pin)
set the iic address pin
uint8_t lm75b_get_addr_pin(lm75b_handle_t *handle, lm75b_address_t *addr_pin)
get the iic address pin
uint8_t lm75b_init(lm75b_handle_t *handle)
initialize the chip
uint8_t lm75b_deinit(lm75b_handle_t *handle)
close the chip
lm75b_os_operation_mode_t
lm75b os operation enumeration definition
uint8_t lm75b_set_reg(lm75b_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
set the chip register
uint8_t lm75b_get_reg(lm75b_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
get the chip register
uint8_t lm75b_hysteresis_convert_to_register(lm75b_handle_t *handle, float c, uint16_t *reg)
convert the hysteresis value to the register data
uint8_t lm75b_get_fault_queue(lm75b_handle_t *handle, lm75b_fault_queue_t *fault_queue)
get the chip fault queue
uint8_t lm75b_get_over_temperature_threshold(lm75b_handle_t *handle, uint16_t *threshold)
get the over temperature threshold
uint8_t lm75b_set_hysteresis(lm75b_handle_t *handle, uint16_t hysteresis)
set the hysteresis value
uint8_t lm75b_get_hysteresis(lm75b_handle_t *handle, uint16_t *hysteresis)
get the hysteresis value
uint8_t lm75b_get_os_polarity(lm75b_handle_t *handle, lm75b_os_polarity_t *polarity)
get the chip os polarity
uint8_t lm75b_over_temperature_threshold_convert_to_data(lm75b_handle_t *handle, uint16_t reg, float *c)
convert the register raw data to the over temperature threshold
uint8_t lm75b_hysteresis_convert_to_data(lm75b_handle_t *handle, uint16_t reg, float *c)
convert the register raw data to the hysteresis value
uint8_t lm75b_get_interrupt_mode(lm75b_handle_t *handle, lm75b_os_operation_mode_t *mode)
get the chip interrupt mode
uint8_t lm75b_set_os_polarity(lm75b_handle_t *handle, lm75b_os_polarity_t polarity)
set the chip os polarity
uint8_t lm75b_set_interrupt_mode(lm75b_handle_t *handle, lm75b_os_operation_mode_t mode)
set the chip interrupt mode
uint8_t lm75b_set_fault_queue(lm75b_handle_t *handle, lm75b_fault_queue_t fault_queue)
set the chip fault queue
uint8_t lm75b_set_over_temperature_threshold(lm75b_handle_t *handle, uint16_t threshold)
set the over temperature threshold
uint8_t lm75b_over_temperature_threshold_convert_to_register(lm75b_handle_t *handle, float c, uint16_t *reg)
convert the over temperature threshold to the register data
void(* delay_ms)(uint32_t ms)
void(* debug_print)(const char *const fmt,...)
uint8_t(* iic_init)(void)
uint8_t(* iic_write)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
uint8_t(* iic_read)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
uint8_t(* iic_deinit)(void)
float supply_voltage_max_v
char manufacturer_name[32]
float supply_voltage_min_v