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 
9 #pragma once
10 
40 #include <stdint.h>
41 
42 #include "periph/gpio.h"
43 
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47 
52 #define DS18_OK (0)
53 #define DS18_ERROR (-1)
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 
Low-level GPIO peripheral driver interface definitions.
gpio_mode_t
Available pin modes.
Definition: periph_cpu.h:91
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
int ds18_trigger(const ds18_t *dev)
Triggers a temperature conversion.
int ds18_init(ds18_t *dev, const ds18_params_t *params)
Initialize a ds18 device.
Device initialization parameters.
Definition: ds18.h:59
gpio_mode_t in_mode
Pin input mode (usually deduced from output mode)
Definition: ds18.h:62
gpio_t pin
Pin the sensor is connected to.
Definition: ds18.h:60
gpio_mode_t out_mode
Pin output mode.
Definition: ds18.h:61
Device descriptor for a ds18 device.
Definition: ds18.h:68
ds18_params_t params
Device Parameters.
Definition: ds18.h:69