Driver interface for the DS18 temperature sensors. More...

Detailed Description

Driver interface for the DS18 temperature sensors.

This driver provides [S]ensor [A]ctuator [U]ber [L]ayer capabilities. Currently the driver has the following limitations:

Files

file  ds18_internal.h
 Internal addresses, registers, constants for DS1822 and DS18B20 temperature sensors.
 
file  ds18_params.h
 Default configuration for DS1822 and DS18B20 temperature sensors.
 
file  ds18.h
 Driver for Maxim Integrated DS1822 and DS18B20 temperature sensors.
 

Data Structures

struct  ds18_params_t
 Device initialization parameters. More...
 
struct  ds18_t
 Device descriptor for a ds18 device. More...
 

Functions

int ds18_init (ds18_t *dev, const ds18_params_t *params)
 Initialize a ds18 device. More...
 
int ds18_trigger (const ds18_t *dev)
 Triggers a temperature conversion. More...
 
int ds18_read (const ds18_t *dev, int16_t *temperature)
 Reads the scratchpad for the last conversion. More...
 
int ds18_get_temperature (const ds18_t *dev, int16_t *temperature)
 convenience function for triggering a conversion and reading the value More...
 

ds18 status return codes

#define DS18_OK   (0)
 
#define DS18_ERROR   (-1)
 

Function Documentation

◆ ds18_get_temperature()

int ds18_get_temperature ( const ds18_t dev,
int16_t *  temperature 
)

convenience function for triggering a conversion and reading the value

Note
This function will block for the conversion time. The current implementation of the driver uses 12-bit resolution, so this time is 750 ms.
Parameters
[in]devdevice descriptor
[out]temperaturebuffer to write the temperature in centi-degrees
Returns
0 on success
-1 on error

◆ ds18_init()

int ds18_init ( ds18_t dev,
const ds18_params_t params 
)

Initialize a ds18 device.

Parameters
[out]devdevice descriptor
[in]paramsds18 initialization struct
Returns
0 on success
-1 on error

◆ ds18_read()

int ds18_read ( const ds18_t dev,
int16_t *  temperature 
)

Reads the scratchpad for the last conversion.

Parameters
[in]devdevice descriptor
[out]temperaturebuffer to write the temperature in centi-degrees
Returns
0 on success
-1 on error

◆ ds18_trigger()

int ds18_trigger ( const ds18_t dev)

Triggers a temperature conversion.

Note
This also triggers a conversion on all devices connected to the bus
Parameters
[in]devdevice descriptor
Returns
0 on success
-1 on error