69#define DS18B20_TEMP_ERROR_GENERIC INT16_MIN
70#define DS18B20_TEMP_ERROR_NO_SENSOR (INT16_MIN + 1)
71#define DS18B20_TEMP_ERROR_CRC_FAIL (INT16_MIN + 2)
78#define DS18B20_FAMILY_CODE 0x28
83#define DS18B20_BITS_PER_BYTE 8
88#define DS18B20_ROM_BYTES 8
93#define DS18B20_SEARCH_ROM 0xF0
101#define DS18B20_ALARM_SEARCH 0xEC
106#define DS18B20_MATCH_ROM 0x55
111#define DS18B20_CONVERT_T 0x44
117#define DS18B20_READ_ROM 0x33
122#define DS18B20_READ_SCRATCHPAD 0xBE
128#define DS18B20_WRITE_SCRATCHPAD 0x4E
137#define DS18B20_COPY_SCRATCHPAD 0x48
143#define DS18B20_RECALL_EEPROM 0xB8
149#define DS18B20_READ_POWER_SUPPLY 0xB4
154#define DS18B20_RES_MIN 9
159#define DS18B20_RES_MAX 12
164#define DS18B20_RES_DEFAULT 12
ds18b20_state_t
DS18B20 driver state machine states.
Definition ds18b20.h:49
@ DS18B20_ST_START
Definition ds18b20.h:51
@ DS18B20_ST_READ
Definition ds18b20.h:56
@ DS18B20_ST_DECODE
Definition ds18b20.h:57
@ DS18B20_ST_CONVERT
Definition ds18b20.h:52
@ DS18B20_ST_REQUEST
Definition ds18b20.h:55
@ DS18B20_ST_WAIT
Definition ds18b20.h:53
@ DS18B20_ST_CONTINUE
Definition ds18b20.h:54
@ DS18B20_ST_IDLE
Definition ds18b20.h:50
void ds18b20_alarm_search_start(ds18b20_search_sink_t sink, uint8_t max_devices)
Start a non-blocking alarm search.
uint8_t ds18b20_alarm_search_count(void)
Number of DS18B20 devices found in alarm (valid once finished).
uint8_t ds18b20_alarm_search_poll(void)
Advance the non-blocking alarm search by one hardware operation.
uint8_t ds18b20_set_alarm_thresholds_poll(void)
Advance the non-blocking alarm threshold write.
uint8_t ds18b20_detect_parasite_poll(void)
Advance the non-blocking parasite-mode detection.
uint8_t ds18b20_read_rom_poll(void)
Advance the non-blocking Read ROM transaction.
uint8_t ds18b20_copy_scratchpad_poll(void)
Advance the non-blocking Copy Scratchpad transaction.
uint8_t ds18b20_recall_eeprom_poll(void)
Advance the non-blocking Recall EEPROM transaction.
void ds18b20_set_alarm_thresholds(uint8_t th, uint8_t tl)
Configure the alarm trigger thresholds TH and TL.
void ds18b20_read_rom(uint8_t *rom)
Read the 64-bit ROM of the (only) DS18B20 on the bus.
uint8_t ds18b20_parasite_mode(void)
Current parasite-power configuration of the driver.
void ds18b20_copy_scratchpad(void)
Copy the scratchpad into the EEPROM (non-volatile).
void ds18b20_detect_parasite(void)
Detect the bus wiring and configure parasite mode automatically.
void ds18b20_read_scratchpad(uint8_t *buf)
Read the 9-byte scratchpad (raw; includes TH, TL and the CRC).
void ds18b20_set_parasite(uint8_t parasite)
Declare the bus as parasite-powered.
uint8_t ds18b20_last_command_ok(void)
Result of the last completed command transaction.
uint8_t ds18b20_read_scratchpad_poll(void)
Advance the non-blocking raw scratchpad read.
void ds18b20_recall_eeprom(void)
Recall the EEPROM contents into the scratchpad.
void ds18b20_select(const uint8_t *rom)
Select which DS18B20 device to measure by its ROM address.
void ds18b20_busy(unsigned action)
Busy indicator callback (weak).
void ds18b20_poll(void)
Advance the state machine (non-blocking).
void ds18b20_init(void)
Initialize DS18B20 driver hardware and peripherals.
uint8_t ds18b20_crc8(const uint8_t *data, uint8_t len)
Calculate Dallas/Maxim CRC-8 over a byte buffer.
void ds18b20_complete(int16_t temp)
Measurement complete callback (weak).
void ds18b20_start_measure(void)
Start one measurement cycle (non-blocking).
uint8_t ds18b20_set_resolution_poll(void)
Advance the non-blocking resolution change by one hardware operation.
void ds18b20_set_resolution(uint8_t bits)
Start a non-blocking resolution change.
uint8_t ds18b20_get_resolution(void)
Current conversion resolution in bits.
const uint8_t * ds18b20_device_rom(uint8_t index)
ROM address of a discovered device.
void ds18b20_scan_start(void)
Arm simultaneous conversion of every discovered device.
uint8_t ds18b20_scan_index(void)
Index of the device whose result ds18b20_complete() just reported.
uint8_t ds18b20_device_count(void)
Number of DS18B20 devices stored by the driver.
uint8_t ds18b20_search_count(void)
Number of DS18B20 devices found (valid once the search finished).
uint8_t(* ds18b20_search_sink_t)(const uint8_t *rom)
Callback invoked for every DS18B20 found by the search.
Definition ds18b20.h:194
void ds18b20_search_start(ds18b20_search_sink_t sink, uint8_t max_devices)
Start a non-blocking device search.
uint8_t ds18b20_search_poll(void)
Advance the non-blocking device search by one hardware operation.
Central compile-time configuration for the 1-Wire stack.
Library version (semantic versioning).