MPL3115A2_Arduino 1.0.1
This library enables the developer to evaluate NXP MPL3115A2(S) with Arduino.
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
MPL3115A2_Arduino Class Reference
Inheritance diagram for MPL3115A2_Arduino:

Public Member Functions

uint8_t init ()
 Initialize the device with reset with several GPIO pin configuration.
 
uint8_t init (bool pinconfig)
 Initialize the device with reset.
 
void set_interrupt (uint8_t flag, mpl3115_INT channel)
 Set interrupt function of MPL3115A2.
 
void dis_interrupt (uint8_t flag)
 Disable interrupt function of MPL3115A2.
 
void start_conversion ()
 Start conversion.
 
void start_conversion (mpl3115_mode _mode, uint8_t _oneshot, uint8_t _oversample)
 Start conversion with settings.
 
float getP ()
 Get the pressure conversion result by reading OUT_P_xxx registers. This clears interruption.
 
float getP (mpl3115_pressure_target target)
 Get the pressure conversion result by reading OUT_P_xxx_xxx registers.
 
float getT ()
 Get the temperature conversion result by reading OUT_T_xxx registers. This clears interruption.
 
float getT (mpl3115_temperature_target target)
 Get the temperature conversion result by reading OUT_T_xxx_xxx registers.
 
void set_sealevel ()
 Set default sea level (101.326kPa) for altitude calculation.
 
void set_sealevel (float pressure)
 Set reference sea level for altitude calculation.
 
void set_threshold (float pressure, uint8_t temperature, float pressure_window, uint8_t temperature_window)
 Set threshold (target) for interruption.
 
 MPL3115A2_Arduino ()
 
 MPL3115A2_Arduino (uint8_t i2c_address)
 
 MPL3115A2_Arduino (TwoWire &wire, uint8_t i2c_address)
 
virtual ~MPL3115A2_Arduino ()
 
virtual float read (void)
 
bool ping (void)
 
int reg_w (uint8_t reg_adr, uint8_t *data, uint16_t size)
 
int reg_w (uint8_t reg_adr, uint8_t data)
 
int reg_r (uint8_t reg_adr, uint8_t *data, uint16_t size)
 
uint8_t reg_r (uint8_t reg_adr)
 
void write_r8 (uint8_t reg, uint8_t val)
 
void write_r16 (uint8_t reg, uint16_t val)
 
uint8_t read_r8 (uint8_t reg)
 
uint16_t read_r16 (uint8_t reg)
 
void bit_op8 (uint8_t reg, uint8_t mask, uint8_t value)
 
void bit_op16 (uint8_t reg, uint16_t mask, uint16_t value)
 

Public Attributes

mpl3115_mode mode =MPL3115_barometer
 Selects the mode from baromter or altimeter.
 
uint8_t oneshot =0
 Put 1 when oneshot mode.
 
uint8_t oversample =MPL3115_OSR_1
 Selects the oversampling ratio from mpl3115_OSR enum.
 

Detailed Description

Definition at line 30 of file MPL3115A2_Arduino.h.

Constructor & Destructor Documentation

◆ MPL3115A2_Arduino() [1/3]

MPL3115A2_Arduino::MPL3115A2_Arduino ( )

Create a MPL3115A2_Arduino instance

Definition at line 16 of file MPL3115A2_Arduino.cpp.

◆ MPL3115A2_Arduino() [2/3]

MPL3115A2_Arduino::MPL3115A2_Arduino ( uint8_t  i2c_address)

Create a MPL3115A2_Arduino instance

Parameters
i2c_addressIf the device is configured with address other than I2C_address(=0x60), put its address here.

Definition at line 17 of file MPL3115A2_Arduino.cpp.

◆ MPL3115A2_Arduino() [3/3]

MPL3115A2_Arduino::MPL3115A2_Arduino ( TwoWire &  wire,
uint8_t  i2c_address = I2C_address 
)

Create a MPL3115A2_Arduino instance

Parameters
wireTwoWire instance
i2c_addressIf the device is configured with address other than I2C_address(=0x60), put its address here.

Definition at line 18 of file MPL3115A2_Arduino.cpp.

◆ ~MPL3115A2_Arduino()

MPL3115A2_Arduino::~MPL3115A2_Arduino ( )
virtual

Destructor of MPL3115A2_Arduino

Definition at line 19 of file MPL3115A2_Arduino.cpp.

Member Function Documentation

◆ bit_op8()

void MPL3115A2_Arduino::bit_op8 ( uint8_t  reg,
uint8_t  mask,
uint8_t  value 
)

Register overwriting with bit-mask

Register can be updated by bit level

Parameters
regregister index/address/pointer
maskbit-mask to protect overwriting
valuevalue to overwrite

Referenced by dis_interrupt(), and set_interrupt().

◆ dis_interrupt()

void MPL3115A2_Arduino::dis_interrupt ( uint8_t  flag)

Disable interrupt function of MPL3115A2.

Parameters
flagFlag for disabling interruption: Selected from "CTRL_REG4 - Bit field value definitions" in mpl3115.h

Definition at line 57 of file MPL3115A2_Arduino.cpp.

◆ getP() [1/2]

float MPL3115A2_Arduino::getP ( )

Get the pressure conversion result by reading OUT_P_xxx registers. This clears interruption.

Returns
Pressure value in float

Definition at line 61 of file MPL3115A2_Arduino.cpp.

Referenced by getP().

◆ getP() [2/2]

float MPL3115A2_Arduino::getP ( mpl3115_pressure_target  target)

Get the pressure conversion result by reading OUT_P_xxx_xxx registers.

Parameters
targetSelect from mpl3115_pressure_target if you would like to read the registers other than OUT_P_xxx
Returns
Pressure value in float

Definition at line 65 of file MPL3115A2_Arduino.cpp.

◆ getT() [1/2]

float MPL3115A2_Arduino::getT ( )

Get the temperature conversion result by reading OUT_T_xxx registers. This clears interruption.

Returns
Temperature value in float

Definition at line 80 of file MPL3115A2_Arduino.cpp.

Referenced by getT().

◆ getT() [2/2]

float MPL3115A2_Arduino::getT ( mpl3115_temperature_target  target)

Get the temperature conversion result by reading OUT_T_xxx_xxx registers.

Parameters
targetSelect from mpl3115_temperature_target if you would like to read the registers other than OUT_T_xxx
Returns
Temperature value in float

Definition at line 84 of file MPL3115A2_Arduino.cpp.

◆ init() [1/2]

uint8_t MPL3115A2_Arduino::init ( )

Initialize the device with reset with several GPIO pin configuration.

Returns
WHO_AM_I register value

Definition at line 21 of file MPL3115A2_Arduino.cpp.

Referenced by init().

◆ init() [2/2]

uint8_t MPL3115A2_Arduino::init ( bool  pinconfig)

Initialize the device with reset.

Parameters
pinconfigIf you wouldn't like to config the pins by this function, put false in this parameter. This parameter can be skipped.
Returns
WHO_AM_I register value

Definition at line 25 of file MPL3115A2_Arduino.cpp.

◆ ping()

bool MPL3115A2_Arduino::ping ( void  )

Ping the device

Returns
true when ACK

◆ read()

virtual float MPL3115A2_Arduino::read ( void  )
virtual

Get temperature value in degree Celsius [°C]

This method simply calls "temp()" method

Returns
temperature value in degree Celsius [°C]

◆ read_r16()

uint16_t MPL3115A2_Arduino::read_r16 ( uint8_t  reg)

Register read, 16 bit

This 16 bit access may ot be common but it's useful for sensor devices

Parameters
regregister index/address/pointer
Returns
data value

◆ read_r8()

uint8_t MPL3115A2_Arduino::read_r8 ( uint8_t  reg)

Register read, 8 bit

Parameters
regregister index/address/pointer
Returns
data value

Referenced by init().

◆ reg_r() [1/2]

uint8_t MPL3115A2_Arduino::reg_r ( uint8_t  reg_adr)

Single register read

Parameters
regregister index/address/pointer
Returns
read data

◆ reg_r() [2/2]

int MPL3115A2_Arduino::reg_r ( uint8_t  reg_adr,
uint8_t *  data,
uint16_t  size 
)

Multiple register read

Parameters
regregister index/address/pointer
datapointer to data buffer
sizedata size
Returns
transferred data size

Referenced by getP(), and getT().

◆ reg_w() [1/2]

int MPL3115A2_Arduino::reg_w ( uint8_t  reg_adr,
uint8_t *  data,
uint16_t  size 
)

Multiple register write

Parameters
regregister index/address/pointer
datapointer to data buffer
sizedata size
Returns
transferred data size

Referenced by set_sealevel(), and set_threshold().

◆ reg_w() [2/2]

int MPL3115A2_Arduino::reg_w ( uint8_t  reg_adr,
uint8_t  data 
)

Single register write

Parameters
regregister index/address/pointer
datapointer to data buffer
sizedata size
Returns
transferred data size

◆ set_interrupt()

void MPL3115A2_Arduino::set_interrupt ( uint8_t  flag,
mpl3115_INT  channel 
)

Set interrupt function of MPL3115A2.

Parameters
flagFlag for interruption: Selected from "CTRL_REG4 - Bit field value definitions" in mpl3115.h
channelSets the flag in INT1 or 2. Be selected from mpl3115_INT

Definition at line 52 of file MPL3115A2_Arduino.cpp.

◆ set_sealevel() [1/2]

void MPL3115A2_Arduino::set_sealevel ( )

Set default sea level (101.326kPa) for altitude calculation.

Definition at line 94 of file MPL3115A2_Arduino.cpp.

Referenced by set_sealevel().

◆ set_sealevel() [2/2]

void MPL3115A2_Arduino::set_sealevel ( float  pressure)

Set reference sea level for altitude calculation.

Parameters
pressureReference sea level value in kPa unit

Definition at line 98 of file MPL3115A2_Arduino.cpp.

◆ set_threshold()

void MPL3115A2_Arduino::set_threshold ( float  pressure,
uint8_t  temperature,
float  pressure_window = 0,
uint8_t  temperature_window = 0 
)

Set threshold (target) for interruption.

Parameters
pressurePressure threshold (target) for threshold interruption in kPa unit
temperatureTemperature threshold (target) for threshold interruption in degC unit
pressure_windowPressure window value referring to target for window interruption in kPa unit
temperature_windowTemperature window value referring to target for window interruption in degC unit

Definition at line 104 of file MPL3115A2_Arduino.cpp.

◆ start_conversion() [1/2]

void MPL3115A2_Arduino::start_conversion ( )

Start conversion.

Definition at line 37 of file MPL3115A2_Arduino.cpp.

Referenced by start_conversion().

◆ start_conversion() [2/2]

void MPL3115A2_Arduino::start_conversion ( mpl3115_mode  _mode,
uint8_t  _oneshot,
uint8_t  _oversample 
)

Start conversion with settings.

Parameters
_modeSetting for mode parameter in this class
_oneshotSetting for oneshot parameter in this class
_oversampleSetting for oversample parameter in this class

Definition at line 41 of file MPL3115A2_Arduino.cpp.

◆ write_r16()

void MPL3115A2_Arduino::write_r16 ( uint8_t  reg,
uint16_t  val 
)

Register write, 16 bit

This 16 bit access may ot be common but it's useful for sensor devices

Parameters
regregister index/address/pointer
valdata value

◆ write_r8()

void MPL3115A2_Arduino::write_r8 ( uint8_t  reg,
uint8_t  val 
)

Register write, 8 bit

Parameters
regregister index/address/pointer
valdata value

Referenced by init(), and start_conversion().

Member Data Documentation

◆ mode

mpl3115_mode MPL3115A2_Arduino::mode =MPL3115_barometer

Selects the mode from baromter or altimeter.

Definition at line 32 of file MPL3115A2_Arduino.h.

Referenced by getP(), set_threshold(), start_conversion(), and start_conversion().

◆ oneshot

uint8_t MPL3115A2_Arduino::oneshot =0

Put 1 when oneshot mode.

Definition at line 33 of file MPL3115A2_Arduino.h.

Referenced by start_conversion(), and start_conversion().

◆ oversample

uint8_t MPL3115A2_Arduino::oversample =MPL3115_OSR_1

Selects the oversampling ratio from mpl3115_OSR enum.

Definition at line 34 of file MPL3115A2_Arduino.h.

Referenced by start_conversion(), and start_conversion().


The documentation for this class was generated from the following files: