All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches

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.
 
int ds18_trigger (const ds18_t *dev)
 Triggers a temperature conversion.
 
int ds18_read (const ds18_t *dev, int16_t *temperature)
 Reads the scratchpad for the last conversion.
 
int ds18_get_temperature (const ds18_t *dev, int16_t *temperature)
 convenience function for triggering a conversion and reading the value
 

ds18 status return codes

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

Macro Definition Documentation

◆ DS18_ERROR

#define DS18_ERROR   (-1)

Definition at line 54 of file ds18.h.

◆ DS18_OK

#define DS18_OK   (0)

Definition at line 53 of file ds18.h.

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