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 
45 #define LPSXXX_DEFAULT_ADDRESS (0x5d)
46 
50 enum {
54 };
55 
59 typedef enum {
61 #if MODULE_LPS331AP
62  LPSXXX_RATE_7HZ = 5,
63  LPSXXX_RATE_12HZ5 = 6,
64  LPSXXX_RATE_25HZ = 7
65 #elif MODULE_LPS25HB
66  LPSXXX_RATE_7HZ = 2,
67  LPSXXX_RATE_12HZ5 = 3,
68  LPSXXX_RATE_25HZ = 4
69 #elif MODULE_LPS22HB
70  LPSXXX_RATE_10HZ = 2,
71  LPSXXX_RATE_25HZ = 3,
72  LPSXXX_RATE_50HZ = 4,
73  LPSXXX_RATE_75HZ = 5
74 #endif
76 
80 #if MODULE_LPS331AP || MODULE_LPS25HB
81 #define LPSXXX_DEFAULT_RATE (LPSXXX_RATE_7HZ)
82 #else /* MODULE_LPS22HB */
83 #define LPSXXX_DEFAULT_RATE (LPSXXX_RATE_25HZ)
84 #endif
85 
89 typedef struct {
91  uint8_t addr;
94 
98 typedef struct {
100 } lpsxxx_t;
101 
112 int lpsxxx_init(lpsxxx_t *dev, const lpsxxx_params_t *params);
113 
123 int lpsxxx_read_temp(const lpsxxx_t *dev, int16_t *temp);
124 
134 int lpsxxx_read_pres(const lpsxxx_t *dev, uint16_t *pres);
135 
144 int lpsxxx_enable(const lpsxxx_t *dev);
145 
154 int lpsxxx_disable(const lpsxxx_t *dev);
155 
156 #ifdef __cplusplus
157 }
158 #endif
159 
160 #endif /* LPSXXX_H */
161 
lpsxxx_rate_t rate
tell sensor to sample with this rate
Definition: lpsxxx.h:92
Everything was fine.
Definition: lpsxxx.h:51
Device descriptor for LPSXXX sensors.
Definition: lpsxxx.h:98
Struct holding all parameters needed for device initialization.
Definition: lpsxxx.h:89
lpsxxx_params_t params
device initialization parameters
Definition: lpsxxx.h:99
unsigned int i2c_t
Default i2c_t type definition.
Definition: i2c.h:157
An error occurred on the I2C bus.
Definition: lpsxxx.h:53
sample with 1Hz
Definition: lpsxxx.h:60
No valid device found.
Definition: lpsxxx.h:52
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.
uint8_t addr
the devices address on the bus
Definition: lpsxxx.h:91
lpsxxx_rate_t
Possible sampling rates for LPS331AP sensors.
Definition: lpsxxx.h:59
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:90
int lpsxxx_read_temp(const lpsxxx_t *dev, int16_t *temp)
Read a temperature value from the given sensor, returned in c°C.
int lpsxxx_enable(const lpsxxx_t *dev)
Enable the given sensor.
Low-level I2C peripheral driver interface definition.