lpsxxx.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014 Freie Universität Berlin
3  * 2018 Inria
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 
29 #ifndef LPSXXX_H
30 #define LPSXXX_H
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 #include <stdint.h>
37 #include "periph/i2c.h"
38 
52 #ifndef CONFIG_LPSXXX_DEFAULT_ADDRESS
53 #define CONFIG_LPSXXX_DEFAULT_ADDRESS (0x5d)
54 #endif
55 
60 enum {
64 };
65 
69 typedef enum {
71 #if MODULE_LPS331AP
72  LPSXXX_RATE_7HZ = 5,
73  LPSXXX_RATE_12HZ5 = 6,
74  LPSXXX_RATE_25HZ = 7
75 #elif MODULE_LPS25HB
76  LPSXXX_RATE_7HZ = 2,
77  LPSXXX_RATE_12HZ5 = 3,
78  LPSXXX_RATE_25HZ = 4
79 #elif MODULE_LPS22HB
80  LPSXXX_RATE_10HZ = 2,
81  LPSXXX_RATE_25HZ = 3,
82  LPSXXX_RATE_50HZ = 4,
83  LPSXXX_RATE_75HZ = 5
84 #endif
86 
90 #if MODULE_LPS331AP || MODULE_LPS25HB
91 #define LPSXXX_DEFAULT_RATE (LPSXXX_RATE_7HZ)
92 #else /* MODULE_LPS22HB */
93 #define LPSXXX_DEFAULT_RATE (LPSXXX_RATE_25HZ)
94 #endif
95 
99 typedef struct {
101  uint8_t addr;
104 
108 typedef struct {
110 } lpsxxx_t;
111 
122 int lpsxxx_init(lpsxxx_t *dev, const lpsxxx_params_t *params);
123 
133 int lpsxxx_read_temp(const lpsxxx_t *dev, int16_t *temp);
134 
144 int lpsxxx_read_pres(const lpsxxx_t *dev, uint16_t *pres);
145 
154 int lpsxxx_enable(const lpsxxx_t *dev);
155 
164 int lpsxxx_disable(const lpsxxx_t *dev);
165 
166 #ifdef __cplusplus
167 }
168 #endif
169 
170 #endif /* LPSXXX_H */
171 
No valid device found.
Definition: lpsxxx.h:62
lpsxxx_rate_t rate
tell sensor to sample with this rate
Definition: lpsxxx.h:102
Device descriptor for LPSXXX sensors.
Definition: lpsxxx.h:108
Struct holding all parameters needed for device initialization.
Definition: lpsxxx.h:99
lpsxxx_params_t params
device initialization parameters
Definition: lpsxxx.h:109
unsigned int i2c_t
Default i2c_t type definition.
Definition: i2c.h:157
sample with 1Hz
Definition: lpsxxx.h:70
int lpsxxx_disable(const lpsxxx_t *dev)
Disable the given sensor.
int lpsxxx_read_pres(const lpsxxx_t *dev, uint16_t *pres)
Read a pressure value from the given sensor, returned in hPa.
An error occurred on the I2C bus.
Definition: lpsxxx.h:63
uint8_t addr
the devices address on the bus
Definition: lpsxxx.h:101
lpsxxx_rate_t
Possible sampling rates for LPS331AP sensors.
Definition: lpsxxx.h:69
int lpsxxx_init(lpsxxx_t *dev, const lpsxxx_params_t *params)
Initialize a given LPSXXX pressure sensor.
i2c_t i2c
I2C bus the sensor is connected to.
Definition: lpsxxx.h:100
int lpsxxx_read_temp(const lpsxxx_t *dev, int16_t *temp)
Read a temperature value from the given sensor, returned in c°C.
Everything was fine.
Definition: lpsxxx.h:61
int lpsxxx_enable(const lpsxxx_t *dev)
Enable the given sensor.
Low-level I2C peripheral driver interface definition.