12#ifndef _MPL3115A2_ARDUINO_H
13#define _MPL3115A2_ARDUINO_H
17#include <I2C_device.h>
22#define I2C_address (uint8_t) 0x60
24typedef enum mpl3115_mode {MPL3115_barometer=0, MPL3115_altimeter=1};
25typedef enum mpl3115_OSR {MPL3115_OSR_1=0, MPL3115_OSR_2=1, MPL3115_OSR_4=2, MPL3115_OSR_8=3, MPL3115_OSR_16=4, MPL3115_OSR_32=5, MPL3115_OSR_64=6, MPL3115_OSR_128=7};
26enum mpl3115_INT {MPL3115_INT2=0, MPL3115_INT1};
27enum mpl3115_pressure_target {MPL3115_P=MPL3115_OUT_P_MSB, MPL3115_P_DELTA=MPL3115_OUT_P_DELTA_MSB, MPL3115_P_MIN=MPL3115_P_MIN_MSB, MPL3115_P_MAX=MPL3115_P_MAX_MSB};
28enum mpl3115_temperature_target {MPL3115_T=MPL3115_OUT_T_MSB, MPL3115_T_DELTA=MPL3115_OUT_T_DELTA_MSB, MPL3115_T_MIN=MPL3115_T_MIN_MSB, MPL3115_T_MAX=MPL3115_T_MAX_MSB};
32 mpl3115_mode
mode=MPL3115_barometer;
47 uint8_t
init(
bool pinconfig);
74 void start_conversion(mpl3115_mode _mode, uint8_t _oneshot, uint8_t _oversample);
87 float getP(mpl3115_pressure_target target);
100 float getT(mpl3115_temperature_target target);
120 void set_threshold(
float pressure, uint8_t temperature,
float pressure_window, uint8_t temperature_window);
163 int reg_w( uint8_t reg_adr, uint8_t *data, uint16_t size );
172 int reg_w( uint8_t reg_adr, uint8_t data );
181 int reg_r( uint8_t reg_adr, uint8_t *data, uint16_t size );
230 void bit_op8( uint8_t reg, uint8_t mask, uint8_t value );
231 void bit_op16( uint8_t reg, uint16_t mask, uint16_t value );
void set_threshold(float pressure, uint8_t temperature, float pressure_window, uint8_t temperature_window)
Set threshold (target) for interruption.
uint8_t oversample
Selects the oversampling ratio from mpl3115_OSR enum.
uint8_t reg_r(uint8_t reg_adr)
uint16_t read_r16(uint8_t reg)
float getT()
Get the temperature conversion result by reading OUT_T_xxx registers. This clears interruption.
void write_r8(uint8_t reg, uint8_t val)
void write_r16(uint8_t reg, uint16_t val)
void set_sealevel()
Set default sea level (101.326kPa) for altitude calculation.
uint8_t oneshot
Put 1 when oneshot mode.
void dis_interrupt(uint8_t flag)
Disable interrupt function of MPL3115A2.
void bit_op8(uint8_t reg, uint8_t mask, uint8_t value)
uint8_t init()
Initialize the device with reset with several GPIO pin configuration.
void set_interrupt(uint8_t flag, mpl3115_INT channel)
Set interrupt function of MPL3115A2.
int reg_w(uint8_t reg_adr, uint8_t *data, uint16_t size)
float getP()
Get the pressure conversion result by reading OUT_P_xxx registers. This clears interruption.
int reg_r(uint8_t reg_adr, uint8_t *data, uint16_t size)
uint8_t read_r8(uint8_t reg)
int reg_w(uint8_t reg_adr, uint8_t data)
virtual ~MPL3115A2_Arduino()
void start_conversion()
Start conversion.
mpl3115_mode mode
Selects the mode from baromter or altimeter.
The mpl3115.h contains the MPL3115 Pressure sensor register definitions, access macros,...