38#ifndef DRIVER_DS18B20_H
39#define DRIVER_DS18B20_H
63#ifndef DS18B20_MAX_SEARCH_SIZE
64 #define DS18B20_MAX_SEARCH_SIZE 64
157#define DRIVER_DS18B20_LINK_INIT(HANDLE, STRUCTURE) memset(HANDLE, 0, sizeof(STRUCTURE))
165#define DRIVER_DS18B20_LINK_BUS_INIT(HANDLE, FUC) (HANDLE)->bus_init = FUC
173#define DRIVER_DS18B20_LINK_BUS_DEINIT(HANDLE, FUC) (HANDLE)->bus_deinit = FUC
181#define DRIVER_DS18B20_LINK_BUS_READ(HANDLE, FUC) (HANDLE)->bus_read = FUC
189#define DRIVER_DS18B20_LINK_BUS_WRITE(HANDLE, FUC) (HANDLE)->bus_write = FUC
197#define DRIVER_DS18B20_LINK_DELAY_MS(HANDLE, FUC) (HANDLE)->delay_ms = FUC
205#define DRIVER_DS18B20_LINK_DELAY_US(HANDLE, FUC) (HANDLE)->delay_us = FUC
213#define DRIVER_DS18B20_LINK_ENABLE_IRQ(HANDLE, FUC) (HANDLE)->enable_irq = FUC
221#define DRIVER_DS18B20_LINK_DISABLE_IRQ(HANDLE, FUC) (HANDLE)->disable_irq = FUC
229#define DRIVER_DS18B20_LINK_DEBUG_PRINT(HANDLE, FUC) (HANDLE)->debug_print = FUC
uint8_t ds18b20_alarm_convert_to_data(ds18b20_handle_t *handle, int8_t reg, float *temp)
convert the register data to the alarm temperature
uint8_t ds18b20_search_alarm(ds18b20_handle_t *handle, uint8_t(*rom)[8], uint8_t *num)
search the ds18b20 alarm rom
uint8_t ds18b20_get_power_mode(ds18b20_handle_t *handle, ds18b20_power_mode_t *power_mode)
get the power mode
uint8_t ds18b20_search_rom(ds18b20_handle_t *handle, uint8_t(*rom)[8], uint8_t *num)
search the ds18b20 rom
uint8_t ds18b20_scrachpad_get_alarm_threshold(ds18b20_handle_t *handle, int8_t *threshold_high, int8_t *threshold_low)
get the alarm threshold in the scratchpad
uint8_t ds18b20_scratchpad_set_alarm_threshold(ds18b20_handle_t *handle, int8_t threshold_high, int8_t threshold_low)
set the alarm threshold in the scratchpad
uint8_t ds18b20_alarm_convert_to_register(ds18b20_handle_t *handle, float temp, int8_t *reg)
convert the alarm temperature to the register data
uint8_t ds18b20_scratchpad_get_resolution(ds18b20_handle_t *handle, ds18b20_resolution_t *resolution)
get the resolution in the scratchpad
ds18b20_power_mode_t
ds18b20 power mode enumeration definition
uint8_t ds18b20_init(ds18b20_handle_t *handle)
initialize the chip
uint8_t ds18b20_set_rom(ds18b20_handle_t *handle, uint8_t rom[8])
set the handle rom
uint8_t ds18b20_copy_eeprom_to_scratchpad(ds18b20_handle_t *handle)
copy the eeprom content to the scratchpad
uint8_t ds18b20_copy_scratchpad_to_eeprom(ds18b20_handle_t *handle)
copy the scratchpad content to the eeprom
ds18b20_resolution_t
ds18b20 resolution enumeration definition
uint8_t ds18b20_info(ds18b20_info_t *info)
get chip's information
uint8_t ds18b20_read(ds18b20_handle_t *handle, int16_t *raw, float *temp)
read data from the chip
uint8_t ds18b20_scratchpad_set_resolution(ds18b20_handle_t *handle, ds18b20_resolution_t resolution)
set the resolution in the scratchpad
struct ds18b20_handle_s ds18b20_handle_t
ds18b20 handle structure definition
ds18b20_mode_t
ds18b20 mode enumeration definition
uint8_t ds18b20_deinit(ds18b20_handle_t *handle)
close the chip
uint8_t ds18b20_get_mode(ds18b20_handle_t *handle, ds18b20_mode_t *mode)
get the chip mode
uint8_t ds18b20_set_mode(ds18b20_handle_t *handle, ds18b20_mode_t mode)
set the chip mode
struct ds18b20_info_s ds18b20_info_t
ds18b20 info structure definition
uint8_t ds18b20_get_rom(ds18b20_handle_t *handle, uint8_t rom[8])
get the chip rom
@ DS18B20_POWER_MODE_PARASITE
@ DS18B20_POWER_MODE_EXTERNALLY
@ DS18B20_RESOLUTION_11BIT
@ DS18B20_RESOLUTION_9BIT
@ DS18B20_RESOLUTION_10BIT
@ DS18B20_RESOLUTION_12BIT
ds18b20 handle structure definition
uint8_t(* bus_deinit)(void)
void(* delay_ms)(uint32_t ms)
void(* debug_print)(const char *const fmt,...)
void(* delay_us)(uint32_t us)
void(* disable_irq)(void)
uint8_t(* bus_read)(uint8_t *value)
uint8_t(* bus_write)(uint8_t value)
uint8_t(* bus_init)(void)
ds18b20 info structure definition
float supply_voltage_max_v
char manufacturer_name[32]
float supply_voltage_min_v