sdp3x.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2019 Dirk Ehmen
3  * 2020 Nishchay Agrawal
4  *
5  * This file is subject to the terms and conditions of the GNU Lesser
6  * General Public License v2.1. See the file LICENSE in the top level
7  * directory for more details.
8  */
9 
22 #ifndef SDP3X_H
23 #define SDP3X_H
24 
25 #include "saul.h"
26 #include "xtimer.h"
27 #include "mutex.h"
28 #include "periph/i2c.h"
29 #include "periph/gpio.h"
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
39 #define SDP3X_FLAG_MASS_FLOW 0x02
40 #define SDP3X_FLAG_DIFF_PRESS 0x00
41 #define SDP3X_FLAG_AVERAGE 0x01
42 #define SDP3X_FLAG_NO_AVERAGE 0x00
48 typedef struct {
50  uint8_t i2c_addr;
51  gpio_t irq_pin;
53 
57 typedef struct {
61 } sdp3x_t;
62 
66 typedef struct {
69  int32_t temperature;
71 
75 enum {
76  SDP3x_OK = 0,
78  SDP3x_NODATA = -2,
81 };
82 
91 int sdp3x_init(sdp3x_t *dev, const sdp3x_params_t *params);
92 
103 int8_t sdp3x_start_continuous(sdp3x_t *dev, uint8_t flags);
104 
115 
126 int32_t sdp3x_read_single_temperature(sdp3x_t *dev, uint8_t flags);
127 
138  uint8_t flags);
139 
150 int8_t sdp3x_read_single_measurement(sdp3x_t *dev, uint8_t flags,
151  sdp3x_measurement_t *result);
152 
163 int8_t sdp3x_stop_continuous(sdp3x_t *dev, xtimer_t *continuous_timer);
164 
172 int8_t sdp3x_soft_reset(const sdp3x_t *dev);
173 
183 int8_t sdp3x_enter_sleep(const sdp3x_t *dev);
184 
192 int8_t sdp3x_exit_sleep(const sdp3x_t *dev);
193 
194 #ifdef __cplusplus
195 }
196 #endif
197 
198 #endif /* SDP3X_H */
xtimer
xtimer timer structure
Definition: xtimer.h:81
sdp3x_measurement_t::differential_pressure
int32_t differential_pressure
Differential Pressure measured in centiPa.
Definition: sdp3x.h:67
SDP3x_IOERROR
@ SDP3x_IOERROR
I/O error.
Definition: sdp3x.h:79
sdp3x_t::continuous_measurement
bool continuous_measurement
Device measuring data continuously.
Definition: sdp3x.h:58
sdp3x_stop_continuous
int8_t sdp3x_stop_continuous(sdp3x_t *dev, xtimer_t *continuous_timer)
Stop Continuous Measuring.
sdp3x_exit_sleep
int8_t sdp3x_exit_sleep(const sdp3x_t *dev)
Exit sleep mode.
sdp3x_init
int sdp3x_init(sdp3x_t *dev, const sdp3x_params_t *params)
Initialize SDP3x.
sdp3x_read_single_differential_pressure
int32_t sdp3x_read_single_differential_pressure(sdp3x_t *dev, uint8_t flags)
Read current differential_pressure value.
i2c_t
unsigned int i2c_t
Default i2c_t type definition.
Definition: i2c.h:151
sdp3x_params_t::irq_pin
gpio_t irq_pin
IRQ pin to check data ready.
Definition: sdp3x.h:51
sdp3x_soft_reset
int8_t sdp3x_soft_reset(const sdp3x_t *dev)
Resets all I2C devices.
sdp3x_start_continuous
int8_t sdp3x_start_continuous(sdp3x_t *dev, uint8_t flags)
Start Continuous Measuring.
sdp3x_enter_sleep
int8_t sdp3x_enter_sleep(const sdp3x_t *dev)
Activates sleep mode.
sdp3x_t::params
sdp3x_params_t params
Device initialization parameters.
Definition: sdp3x.h:59
SDP3x_WRONGSIZE
@ SDP3x_WRONGSIZE
Wrong size of array for method.
Definition: sdp3x.h:80
sdp3x_read_single_measurement
int8_t sdp3x_read_single_measurement(sdp3x_t *dev, uint8_t flags, sdp3x_measurement_t *result)
read temperature and differential pressure
sdp3x_read_single_temperature
int32_t sdp3x_read_single_temperature(sdp3x_t *dev, uint8_t flags)
Read current temperature value.
sdp3x_params_t::i2c_addr
uint8_t i2c_addr
I2C address.
Definition: sdp3x.h:50
mutex.h
Mutex for thread synchronization.
sdp3x_read_continuous
int8_t sdp3x_read_continuous(sdp3x_measurement_t *result, sdp3x_t *dev)
read temperature and differential pressure
SDP3x_OK
@ SDP3x_OK
all went as expected
Definition: sdp3x.h:76
gpio.h
Low-level GPIO peripheral driver interface definitions.
SDP3x_NODATA
@ SDP3x_NODATA
No Data available.
Definition: sdp3x.h:78
sdp3x_t
Device descriptor for the SDP3x sensor.
Definition: sdp3x.h:57
saul.h
Definition of the generic [S]ensor [A]ctuator [U]ber [L]ayer.
SDP3x_CRCERROR
@ SDP3x_CRCERROR
CRC-Check failed.
Definition: sdp3x.h:77
sdp3x_params_t::i2c_dev
i2c_t i2c_dev
I2C device which is used.
Definition: sdp3x.h:49
sdp3x_measurement_t
Measurement from SDP3x sensor.
Definition: sdp3x.h:66
sdp3x_measurement_t::temperature
int32_t temperature
Temperature measured in centiĀ°C.
Definition: sdp3x.h:69
i2c.h
Low-level I2C peripheral driver interface definition.
xtimer.h
xtimer interface definitions
mutex_t
Mutex structure.
Definition: mutex.h:120
sdp3x_params_t
Device initialization parameters.
Definition: sdp3x.h:48
sdp3x_t::mutex
mutex_t mutex
Mutex for this sdp3x dev.
Definition: sdp3x.h:60