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
10#pragma once
11
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
35#include <stdint.h>
36#include "periph/i2c.h"
37
51#ifndef CONFIG_LPSXXX_DEFAULT_ADDRESS
52#define CONFIG_LPSXXX_DEFAULT_ADDRESS (0x5d)
53#endif
55
59enum {
63};
64
68typedef enum {
70#if MODULE_LPS331AP
71 LPSXXX_RATE_7HZ = 5,
72 LPSXXX_RATE_12HZ5 = 6,
73 LPSXXX_RATE_25HZ = 7
74#elif MODULE_LPS25HB
75 LPSXXX_RATE_7HZ = 2,
76 LPSXXX_RATE_12HZ5 = 3,
77 LPSXXX_RATE_25HZ = 4
78#elif MODULE_LPS22HB
79 LPSXXX_RATE_10HZ = 2,
80 LPSXXX_RATE_25HZ = 3,
81 LPSXXX_RATE_50HZ = 4,
82 LPSXXX_RATE_75HZ = 5
83#elif MODULE_LPS22HH || MODULE_LPS22CH
84 LPSXXX_RATE_10HZ = 2,
85 LPSXXX_RATE_25HZ = 3,
86 LPSXXX_RATE_50HZ = 4,
87 LPSXXX_RATE_75HZ = 5,
88 LPSXXX_RATE_100HZ = 6,
89 LPSXXX_RATE_200HZ = 7
90#endif
92
96#if MODULE_LPS331AP || MODULE_LPS25HB
97#define LPSXXX_DEFAULT_RATE (LPSXXX_RATE_7HZ)
98#else /* MODULE_LPS22HB || MODULE_LPS22HH || MODULE_LPS22CH */
99#define LPSXXX_DEFAULT_RATE (LPSXXX_RATE_25HZ)
100#endif
101
105typedef struct {
107 uint8_t addr;
110
114typedef struct {
116} lpsxxx_t;
117
128int lpsxxx_init(lpsxxx_t *dev, const lpsxxx_params_t *params);
129
139int lpsxxx_read_temp(const lpsxxx_t *dev, int16_t *temp);
140
150int lpsxxx_read_pres(const lpsxxx_t *dev, uint16_t *pres);
151
160int lpsxxx_enable(const lpsxxx_t *dev);
161
170int lpsxxx_disable(const lpsxxx_t *dev);
171
172#ifdef __cplusplus
173}
174#endif
175
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:68
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_OK
Everything was fine.
Definition lpsxxx.h:60
@ LPSXXX_ERR_NODEV
No valid device found.
Definition lpsxxx.h:61
@ LPSXXX_ERR_I2C
An error occurred on the I2C bus.
Definition lpsxxx.h:62
@ LPSXXX_RATE_1HZ
sample with 1Hz
Definition lpsxxx.h:69
uint_fast8_t i2c_t
Default i2c_t type definition.
Definition i2c.h:144
Low-level I2C peripheral driver interface definition.
Struct holding all parameters needed for device initialization.
Definition lpsxxx.h:105
i2c_t i2c
I2C bus the sensor is connected to.
Definition lpsxxx.h:106
lpsxxx_rate_t rate
tell sensor to sample with this rate
Definition lpsxxx.h:108
uint8_t addr
the devices address on the bus
Definition lpsxxx.h:107
Device descriptor for LPSXXX sensors.
Definition lpsxxx.h:114
lpsxxx_params_t params
device initialization parameters
Definition lpsxxx.h:115