ds18.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 Frits Kuipers
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
38 #ifndef DS18_H
39 #define DS18_H
40 
41 #include "periph/gpio.h"
42 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
51 #define DS18_OK (0)
52 #define DS18_ERROR (-1)
53 
59 typedef struct {
60  gpio_t pin;
64 
68 typedef struct {
70 } ds18_t;
71 
82 int ds18_init(ds18_t *dev, const ds18_params_t *params);
83 
93 int ds18_trigger(const ds18_t *dev);
94 
104 int ds18_read(const ds18_t *dev, int16_t *temperature);
105 
119 int ds18_get_temperature(const ds18_t *dev, int16_t *temperature);
120 
121 #ifdef __cplusplus
122 }
123 #endif
124 
126 #endif /* DS18_H */
ds18_trigger
int ds18_trigger(const ds18_t *dev)
Triggers a temperature conversion.
ds18_init
int ds18_init(ds18_t *dev, const ds18_params_t *params)
Initialize a ds18 device.
ds18_params_t
Device initialization parameters.
Definition: ds18.h:59
ds18_get_temperature
int ds18_get_temperature(const ds18_t *dev, int16_t *temperature)
convenience function for triggering a conversion and reading the value
ds18_read
int ds18_read(const ds18_t *dev, int16_t *temperature)
Reads the scratchpad for the last conversion.
ds18_t::params
ds18_params_t params
Device Parameters.
Definition: ds18.h:69
ds18_params_t::out_mode
gpio_mode_t out_mode
Pin output mode.
Definition: ds18.h:61
ds18_params_t::pin
gpio_t pin
Pin the sensor is connected to.
Definition: ds18.h:60
ds18_params_t::in_mode
gpio_mode_t in_mode
Pin input mode (usually deduced from output mode)
Definition: ds18.h:62
gpio.h
Low-level GPIO peripheral driver interface definitions.
gpio_mode_t
gpio_mode_t
Available pin modes.
Definition: periph_cpu.h:70
ds18_t
Device descriptor for a ds18 device.
Definition: ds18.h:68