XBee Firmware Library  1.6.0
Functions
DS18B20 digital thermometer

Functions

ssize_t ds18b20_check_family_code (uint8_t *rom)
 Verifies that the family code stored in rom first byte belongs to the driver supported device. Data read is CRC8 checked before a success is reported. More...
 
ssize_t ds18b20_config (uint8_t *rom, int8_t th, int8_t tl, uint8_t resolution)
 Configures resolution and alarm registers of a specific DS18B20. More...
 
ssize_t ds18b20_eeprom_recall (uint8_t *rom)
 Restores data from permanent EEPROM (TH, TL and configuration registers) to scratchpad memory. More...
 
ssize_t ds18b20_parasite_powered (uint8_t *rom)
 Checks wether the DS18B20 is parasite powered. More...
 
ssize_t ds18b20_read_temp (uint8_t *rom, int16_t *temperature)
 Reads temperature registers from DS18B20. If device is parasite-powered a strong pull-up is necessary. More...
 
ssize_t ds18b20_scratchpad_copy (uint8_t *rom)
 Copies data from scratchpad memory (TH, TL and configuration registers) to permanent EEPROM. If device is parasite-powered a strong pull-up is necessary. More...
 
ssize_t ds18b20_scratchpad_read (uint8_t *rom, uint8_t *scratchpad)
 Reads the content of scratchpad memory (temperature, triggers and configuration registers) from DS18B20. Data read is CRC8 checked before a success is reported. More...
 
int16_t ds18b20_temp_conv (uint8_t *temp_regs)
 Performs a conversion of the temperature read from DS18B20. More...
 
ssize_t ds1904_check_family_code (uint8_t *rom)
 Verifies that the family code stored in rom first byte belongs to the driver supported device. Data read is CRC8 checked before a success is reported. More...
 

Detailed Description

DS18B20 API Overview

This API contains the functions to configure and control a DS18B20 temperature sensor over a 1-Wire bus.

DS18B20 Macros

The DS18B20 temperature sensor has 6 specific commands that are defined as the following macros:

Function Documentation

ssize_t ds18b20_check_family_code ( uint8_t rom)

Verifies that the family code stored in rom first byte belongs to the driver supported device. Data read is CRC8 checked before a success is reported.

Parameters
[in]romaddress where ROM of device is stored.
Return values
0on success.
<0if there is any error.
ssize_t ds18b20_config ( uint8_t rom,
int8_t  th,
int8_t  tl,
uint8_t  resolution 
)

Configures resolution and alarm registers of a specific DS18B20.

Parameters
[in]romaddress where ROM of device is stored. NULL if only one device is connected to the 1-Wire bus.
[in]thalarm High Register.
[in]tlalarm Low Register.
[in]resolutionresolution to be configured (9, 10, 11 or 12 bits).
Return values
0on success.
<0if there is any error.
ssize_t ds18b20_eeprom_recall ( uint8_t rom)

Restores data from permanent EEPROM (TH, TL and configuration registers) to scratchpad memory.

Parameters
[in]romaddress where ROM of device is stored. NULL if only one device is connected to the 1-Wire bus.
Return values
0on success.
<0if there is any error.
ssize_t ds18b20_parasite_powered ( uint8_t rom)

Checks wether the DS18B20 is parasite powered.

Parameters
[in]uint8_t*rom address where ROM of device is stored. NULL if only one device is connected to the 1-Wire bus.
Return values
0if device is externally powered.
1if device is parasite powered.
<0if there is any error.
ssize_t ds18b20_read_temp ( uint8_t rom,
int16_t temperature 
)

Reads temperature registers from DS18B20. If device is parasite-powered a strong pull-up is necessary.

Parameters
[in]romaddress where ROM of device is stored. NULL if only one device is connected to the 1-Wire bus.
[in]temperaturebuffer where read register will be stored.
Return values
0on success.
<0if there is any error.
ssize_t ds18b20_scratchpad_copy ( uint8_t rom)

Copies data from scratchpad memory (TH, TL and configuration registers) to permanent EEPROM. If device is parasite-powered a strong pull-up is necessary.

Parameters
[in]romaddress where ROM of device is stored. NULL if only one device is connected to the 1-Wire bus.
Return values
0on success.
<0if there is any error.
ssize_t ds18b20_scratchpad_read ( uint8_t rom,
uint8_t scratchpad 
)

Reads the content of scratchpad memory (temperature, triggers and configuration registers) from DS18B20. Data read is CRC8 checked before a success is reported.

Parameters
[in]romaddress where ROM of device is stored. NULL if only one device is connected to the 1-Wire bus.
[in]scratchpadaddress where content of memory will be stored.
Return values
0on success.
<0if there is any error.
int16_t ds18b20_temp_conv ( uint8_t temp_regs)

Performs a conversion of the temperature read from DS18B20.

Parameters
[in]temp_regstemperature registers (LSB and MSB).
Return values
signedvalue of temperature multiplied by 100 (2 less significative digits are decimals).
ssize_t ds1904_check_family_code ( uint8_t rom)

Verifies that the family code stored in rom first byte belongs to the driver supported device. Data read is CRC8 checked before a success is reported.

Parameters
[in]romaddress where ROM of device is stored.
Return values
0on success.
<0if there is any error.