Loading...
Searching...
No Matches
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
33extern "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
60enum {
64};
65
69typedef 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#elif MODULE_LPS22HH || MODULE_LPS22CH
85 LPSXXX_RATE_10HZ = 2,
86 LPSXXX_RATE_25HZ = 3,
87 LPSXXX_RATE_50HZ = 4,
88 LPSXXX_RATE_75HZ = 5,
89 LPSXXX_RATE_100HZ = 6,
90 LPSXXX_RATE_200HZ = 7
91#endif
93
97#if MODULE_LPS331AP || MODULE_LPS25HB
98#define LPSXXX_DEFAULT_RATE (LPSXXX_RATE_7HZ)
99#else /* MODULE_LPS22HB || MODULE_LPS22HH || MODULE_LPS22CH */
100#define LPSXXX_DEFAULT_RATE (LPSXXX_RATE_25HZ)
101#endif
102
106typedef struct {
108 uint8_t addr;
111
115typedef struct {
117} lpsxxx_t;
118
129int lpsxxx_init(lpsxxx_t *dev, const lpsxxx_params_t *params);
130
140int lpsxxx_read_temp(const lpsxxx_t *dev, int16_t *temp);
141
151int lpsxxx_read_pres(const lpsxxx_t *dev, uint16_t *pres);
152
161int lpsxxx_enable(const lpsxxx_t *dev);
162
171int lpsxxx_disable(const lpsxxx_t *dev);
172
173#ifdef __cplusplus
174}
175#endif
176
177#endif /* LPSXXX_H */
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_disable(const lpsxxx_t *dev)
Disable the given sensor.
int lpsxxx_init(lpsxxx_t *dev, const lpsxxx_params_t *params)
Initialize a given LPSXXX pressure sensor.
lpsxxx_rate_t
Possible sampling rates for LPS331AP sensors.
Definition lpsxxx.h:69
int lpsxxx_read_pres(const lpsxxx_t *dev, uint16_t *pres)
Read a pressure value from the given sensor, returned in hPa.
int lpsxxx_enable(const lpsxxx_t *dev)
Enable the given sensor.
@ LPSXXX_RATE_1HZ
sample with 1Hz
Definition lpsxxx.h:70
@ LPSXXX_OK
Everything was fine.
Definition lpsxxx.h:61
@ LPSXXX_ERR_NODEV
No valid device found.
Definition lpsxxx.h:62
@ LPSXXX_ERR_I2C
An error occurred on the I2C bus.
Definition lpsxxx.h:63
uint_fast8_t i2c_t
Default i2c_t type definition.
Definition i2c.h:151
Low-level I2C peripheral driver interface definition.
Struct holding all parameters needed for device initialization.
Definition lpsxxx.h:106
i2c_t i2c
I2C bus the sensor is connected to.
Definition lpsxxx.h:107
lpsxxx_rate_t rate
tell sensor to sample with this rate
Definition lpsxxx.h:109
uint8_t addr
the devices address on the bus
Definition lpsxxx.h:108
Device descriptor for LPSXXX sensors.
Definition lpsxxx.h:115
lpsxxx_params_t params
device initialization parameters
Definition lpsxxx.h:116