Loading...
Searching...
No Matches
mpl3115a2.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2014 PHYTEC Messtechnik GmbH
3 * SPDX-FileCopyrightText: 2017 HAW Hamburg
4 * SPDX-License-Identifier: LGPL-2.1-only
5 */
6
7#pragma once
8
29
30#include <stdint.h>
31#include <stdbool.h>
32#include "periph/i2c.h"
33
34#ifdef __cplusplus
35extern "C"
36{
37#endif
38
42enum {
47};
48
52#define MPL3115A2_I2C_ADDRESS (0x60)
53
58enum {
67};
68#define MPL3115A2_OS_RATIO_DEFAULT MPL3115A2_OS_RATIO_16
70
81#ifndef MPL3115A2_CONVERSION_TIME
82#define MPL3115A2_CONVERSION_TIME (514000UL)
83#endif
85
89typedef struct {
91 uint8_t addr;
92 uint8_t ratio;
94
101
114
124
134
144
155
166int mpl3115a2_read_pressure(const mpl3115a2_t *dev, uint32_t *pres, uint8_t *status);
167
177int mpl3115a2_read_temp(const mpl3115a2_t *dev, int16_t *temp);
178
179#ifdef __cplusplus
180}
181#endif
182
int mpl3115a2_reset(const mpl3115a2_t *dev)
Reset the MPL3115A2 sensor.
int mpl3115a2_read_pressure(const mpl3115a2_t *dev, uint32_t *pres, uint8_t *status)
Read sensor's data in pressure mode.
int mpl3115a2_set_standby(const mpl3115a2_t *dev)
Set standby mode.
int mpl3115a2_init(mpl3115a2_t *dev, const mpl3115a2_params_t *params)
Initialize the MPL3115A2 sensor driver.
int mpl3115a2_is_ready(const mpl3115a2_t *dev)
Check for new set of measurement data.
int mpl3115a2_set_active(const mpl3115a2_t *dev)
Set active mode, this enables periodic measurements.
int mpl3115a2_read_temp(const mpl3115a2_t *dev, int16_t *temp)
Read sensor's temperature.
@ MPL3115A2_OS_RATIO_8
Oversample Ratio 8, conversion 34ms.
Definition mpl3115a2.h:62
@ MPL3115A2_OS_RATIO_1
Oversample Ratio 1, conversion 6ms.
Definition mpl3115a2.h:59
@ MPL3115A2_OS_RATIO_128
Oversample Ratio 128, conversion 514ms.
Definition mpl3115a2.h:66
@ MPL3115A2_OS_RATIO_2
Oversample Ratio 2, conversion 10ms.
Definition mpl3115a2.h:60
@ MPL3115A2_OS_RATIO_4
Oversample Ratio 4, conversion 18ms.
Definition mpl3115a2.h:61
@ MPL3115A2_OS_RATIO_32
Oversample Ratio 32, conversion 130ms.
Definition mpl3115a2.h:64
@ MPL3115A2_OS_RATIO_16
Oversample Ratio 16, conversion 66ms.
Definition mpl3115a2.h:63
@ MPL3115A2_OS_RATIO_64
Oversample Ratio 64, conversion 258ms.
Definition mpl3115a2.h:65
@ MPL3115A2_OK
all good
Definition mpl3115a2.h:43
@ MPL3115A2_ERROR_DEV
Device MPL3115A2 not found.
Definition mpl3115a2.h:45
@ MPL3115A2_ERROR_CNF
Device configuration failed.
Definition mpl3115a2.h:46
@ MPL3115A2_ERROR_I2C
I2C communication failed.
Definition mpl3115a2.h:44
uint_fast8_t i2c_t
Default i2c_t type definition.
Definition i2c.h:155
Low-level I2C peripheral driver interface definition.
Configuration parameters.
Definition mpl3115a2.h:89
uint8_t ratio
MPL3115A2 oversampling ratio.
Definition mpl3115a2.h:92
uint8_t addr
I2C bus address of the device.
Definition mpl3115a2.h:91
i2c_t i2c
I2C bus the device is connected to.
Definition mpl3115a2.h:90
Device descriptor for MPL3115A2 sensors.
Definition mpl3115a2.h:98
mpl3115a2_params_t params
device configuration parameters
Definition mpl3115a2.h:99