ds18.h

Driver for Maxim Integrated DS1822 and DS18B20 temperature sensors.

DS18_OK
1
(0)
DS18_ERROR
1
(-1)
int ds18_init(ds18_t * dev, const ds18_params_t * params)

Initialize a ds18 device.

Parameters

dev:device descriptor
params:ds18 initialization struct

Return values

  • 0 on success
  • -1 on error
int ds18_trigger(ds18_t * dev)

Triggers a temperature conversion.

Note

This also triggers a conversion on all devices connected to the bus

Parameters

dev:device descriptor

Return values

  • 0 on success
  • -1 on error
int ds18_read(ds18_t * dev, int16_t * temperature)

Reads the scratchpad for the last conversion.

Parameters

dev:device descriptor
temperature:buffer to write the temperature in centi-degrees

Return values

  • 0 on success
  • -1 on error
int ds18_get_temperature(ds18_t * dev, int16_t * temperature)

convenience fuction for triggering a conversion and reading the value

Note

This function will block for the convertion time. The current implementation of the driver uses 12-bit resolution, so this time is 750 ms.

Parameters

dev:device descriptor
temperature:buffer to write the temperature in centi-degrees

Return values

  • 0 on success
  • -1 on error
struct ds18_t

Device descriptor for a ds18 device.

gpio.h::gpio_t pin

Pin the sensor is connected to.

cc2538/include/periph_cpu.h::gpio_mode_t out_mode

Pin output mode.

cc2538/include/periph_cpu.h::gpio_mode_t in_mode

Pin input mode.

struct ds18_params_t

Device initialization parameters.

gpio.h::gpio_t pin

Pin the sensor is connected to.

cc2538/include/periph_cpu.h::gpio_mode_t out_mode

Pin output mode.