LibDriver LM75B
Loading...
Searching...
No Matches
driver_lm75b.h
Go to the documentation of this file.
1
37
38#ifndef DRIVER_LM75B_H
39#define DRIVER_LM75B_H
40
41#include <stdio.h>
42#include <stdint.h>
43#include <string.h>
44
45#ifdef __cplusplus
46extern "C"{
47#endif
48
54
59
74
85
94
103
112
116typedef struct lm75b_handle_s
117{
118 uint8_t iic_addr;
119 uint8_t (*iic_init)(void);
120 uint8_t (*iic_deinit)(void);
121 uint8_t (*iic_read)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len);
122 uint8_t (*iic_write)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len);
123 void (*delay_ms)(uint32_t ms);
124 void (*debug_print)(const char *const fmt, ...);
125 uint8_t inited;
127
143
147
154
161#define DRIVER_LM75B_LINK_INIT(HANDLE, STRUCTURE) memset(HANDLE, 0, sizeof(STRUCTURE))
162
169#define DRIVER_LM75B_LINK_IIC_INIT(HANDLE, FUC) (HANDLE)->iic_init = FUC
170
177#define DRIVER_LM75B_LINK_IIC_DEINIT(HANDLE, FUC) (HANDLE)->iic_deinit = FUC
178
185#define DRIVER_LM75B_LINK_IIC_READ(HANDLE, FUC) (HANDLE)->iic_read = FUC
186
193#define DRIVER_LM75B_LINK_IIC_WRITE(HANDLE, FUC) (HANDLE)->iic_write = FUC
194
201#define DRIVER_LM75B_LINK_DELAY_MS(HANDLE, FUC) (HANDLE)->delay_ms = FUC
202
209#define DRIVER_LM75B_LINK_DEBUG_PRINT(HANDLE, FUC) (HANDLE)->debug_print = FUC
210
214
221
230uint8_t lm75b_info(lm75b_info_t *info);
231
241uint8_t lm75b_set_addr_pin(lm75b_handle_t *handle, lm75b_address_t addr_pin);
242
252uint8_t lm75b_get_addr_pin(lm75b_handle_t *handle, lm75b_address_t *addr_pin);
253
264uint8_t lm75b_init(lm75b_handle_t *handle);
265
276uint8_t lm75b_deinit(lm75b_handle_t *handle);
277
290uint8_t lm75b_read(lm75b_handle_t *handle, uint16_t *raw, float *s);
291
303uint8_t lm75b_set_mode(lm75b_handle_t *handle, lm75b_mode_t mode);
304
316uint8_t lm75b_get_mode(lm75b_handle_t *handle, lm75b_mode_t *mode);
317
321
328
340uint8_t lm75b_set_fault_queue(lm75b_handle_t *handle, lm75b_fault_queue_t fault_queue);
341
353uint8_t lm75b_get_fault_queue(lm75b_handle_t *handle, lm75b_fault_queue_t *fault_queue);
354
366uint8_t lm75b_hysteresis_convert_to_register(lm75b_handle_t *handle, float c, uint16_t *reg);
367
379uint8_t lm75b_hysteresis_convert_to_data(lm75b_handle_t *handle, uint16_t reg, float *c);
380
392uint8_t lm75b_set_hysteresis(lm75b_handle_t *handle, uint16_t hysteresis);
393
405uint8_t lm75b_get_hysteresis(lm75b_handle_t *handle, uint16_t *hysteresis);
406
418uint8_t lm75b_over_temperature_threshold_convert_to_register(lm75b_handle_t *handle, float c, uint16_t *reg);
419
431uint8_t lm75b_over_temperature_threshold_convert_to_data(lm75b_handle_t *handle, uint16_t reg, float *c);
432
444uint8_t lm75b_set_over_temperature_threshold(lm75b_handle_t *handle, uint16_t threshold);
445
457uint8_t lm75b_get_over_temperature_threshold(lm75b_handle_t *handle, uint16_t *threshold);
458
471
484
497
510
514
521
535uint8_t lm75b_set_reg(lm75b_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len);
536
550uint8_t lm75b_get_reg(lm75b_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len);
551
555
559
560#ifdef __cplusplus
561}
562#endif
563
564#endif
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
@ LM75B_MODE_NORMAL
@ LM75B_MODE_SHUTDOWN
@ LM75B_FAULT_QUEUE_3
@ LM75B_FAULT_QUEUE_2
@ LM75B_FAULT_QUEUE_1
@ LM75B_FAULT_QUEUE_6
@ LM75B_ADDRESS_A100
@ LM75B_ADDRESS_A101
@ LM75B_ADDRESS_A001
@ LM75B_ADDRESS_A011
@ LM75B_ADDRESS_A010
@ LM75B_ADDRESS_A111
@ LM75B_ADDRESS_A110
@ LM75B_ADDRESS_A000
@ LM75B_OS_POLARITY_LOW
@ LM75B_OS_POLARITY_HIGH
@ LM75B_OS_OPERATION_INTERRUPT
@ LM75B_OS_OPERATION_COMPARATOR
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
lm75b handle structure definition
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)
lm75b information structure definition
float temperature_max
float supply_voltage_max_v
uint32_t driver_version
float temperature_min
float max_current_ma
char manufacturer_name[32]
float supply_voltage_min_v
char interface[8]
char chip_name[32]