Loading...
Searching...
No Matches
ds18.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2017 Frits Kuipers
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
36
37#include <stdint.h>
38
39#include "periph/gpio.h"
40
41#ifdef __cplusplus
42extern "C" {
43#endif
44
49#define DS18_OK (0)
50#define DS18_ERROR (-1)
52
61
65typedef struct {
67} ds18_t;
68
79int ds18_init(ds18_t *dev, const ds18_params_t *params);
80
90int ds18_trigger(const ds18_t *dev);
91
101int ds18_read(const ds18_t *dev, int16_t *temperature);
102
116int ds18_get_temperature(const ds18_t *dev, int16_t *temperature);
117
118#ifdef __cplusplus
119}
120#endif
121
Low-level GPIO peripheral driver interface definitions.
gpio_mode_t
Available pin modes.
Definition periph_cpu.h:96
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:56
gpio_mode_t in_mode
Pin input mode (usually deduced from output mode)
Definition ds18.h:59
gpio_t pin
Pin the sensor is connected to.
Definition ds18.h:57
gpio_mode_t out_mode
Pin output mode.
Definition ds18.h:58
Device descriptor for a ds18 device.
Definition ds18.h:65
ds18_params_t params
Device Parameters.
Definition ds18.h:66