Multi-Hackers / MPL3115A2

Dependents:   mDotEVBM2X MTDOT-EVBDemo-DRH MTDOT-BOX-EVB-Factory-Firmware-LIB-108 MTDOT-UDKDemo_Senet ... more

Embed: (wiki syntax)

« Back to documentation index

MPL3115A2 Class Reference

MPL3115A2 Class Reference

API abstraction for the MPL3115A2 3-axis barometric sensor IC initial version will be polling only. More...

#include <MPL3115A2.h>

Public Types

enum  WHO_AM_I_VAL { I_AM_MPL3115A2 = 0xc4 }
 

Device ID's that this class is compatible with.

More...
enum  SYS_MODE
 

operating mode of MPL3115A2

More...
enum  DR_STATUS_VALS
 

flags for data overwrite and data ready

More...
enum  OUTPUT_MODE
 

Select whether data is raw or post-processed.

More...
enum  DATA_MODE
 

Sets the pressure measurement post- processing mode for the sensor.

More...
enum  OVERSAMPLE_RATIO
 

values for oversample ratio Note: sample time is 2.5 msec * ratio# i.e.

More...
enum  ACQUISITION_TIMER
 

in active mode this sets time between samples in seconds

More...
enum  REGISTER
 

The device register map.

More...

Public Member Functions

 MPL3115A2 (I2C &i2c, InterruptIn *int1=NULL, InterruptIn *int2=NULL)
 Create the MPL3115A2 object.
bool testWhoAmI (void)
 Test the Who am I register for valid ID.
uint8_t setParameters (OUTPUT_MODE out_mode, DATA_MODE data_mode, OVERSAMPLE_RATIO os_ratio, ACQUISITION_TIMER measure_time)
 Setup the MPL3115A2 for standard barometric sensor read mode - Turns Data post processing ON/OFF using the OUTPUT_MODE enum - Sets Pressure or Altitude mode using the DATA_MODE enum - Sets the Oversample ration using the OVERSAMPLE_RATIO enum - Sets the Aquisition time for Active mode using the ACQUISITION_TIMER enum.
uint8_t standbyMode (void)
 Put the MPL3115A2 in the Standby mode.
uint8_t activeMode (void)
 Put the MPL3115A2 in the active mode.
uint8_t triggerOneShot (void)
 Triggers the MPL3115A2 to take one measurement in Active or Standby mode.
uint8_t setAltitudeCalib (int16_t alti_calib)
 Set the sea level equivalent pressure for Altitude mode - Value is Equivalent sea level pressure for measurement location (2 Pa resolution)
uint8_t clearMinMaxRegs (void)
 Clears all minimum and maximum data registers.
uint8_t getStatus (void)
 Check the MPL3115A2 status register.
int32_t getBaroData (void)
 Get the Pressure or Altitude data.
int16_t getTempData (void)
 Get the Temperature data.
int32_t getMinBaro (bool clear_data)
 Get the Minimum Pressure or Altitude data.
int32_t getMaxBaro (bool clear_data)
 Get the Maximum Pressure or Altitude data.
int16_t getMinTemp (bool clear_data)
 Get the Minimum Temperature data.
int16_t getMaxTemp (bool clear_data)
 Get the Maximum Temperature data.
MPL3115A2_DATA getAllData (bool clear_data)
 Get the MP3115A2 data structure.

Detailed Description

API abstraction for the MPL3115A2 3-axis barometric sensor IC initial version will be polling only.

Interrupt service and rtos support will be added at a later point

Definition at line 118 of file MPL3115A2.h.


Member Enumeration Documentation

in active mode this sets time between samples in seconds

Definition at line 196 of file MPL3115A2.h.

enum DATA_MODE

Sets the pressure measurement post- processing mode for the sensor.

Definition at line 169 of file MPL3115A2.h.

flags for data overwrite and data ready

Definition at line 145 of file MPL3115A2.h.

Select whether data is raw or post-processed.

Definition at line 159 of file MPL3115A2.h.

values for oversample ratio Note: sample time is 2.5 msec * ratio# i.e.

OR_8 -> 2.5 * 8 = 20 msec

Definition at line 180 of file MPL3115A2.h.

enum REGISTER

The device register map.

Definition at line 207 of file MPL3115A2.h.

enum SYS_MODE

operating mode of MPL3115A2

Definition at line 135 of file MPL3115A2.h.

Device ID's that this class is compatible with.

Enumerator:
I_AM_MPL3115A2 

MPL3115A2 WHO_AM_I register content

Definition at line 126 of file MPL3115A2.h.


Constructor & Destructor Documentation

MPL3115A2 ( I2C &  i2c,
InterruptIn *  int1 = NULL,
InterruptIn *  int2 = NULL 
)

Create the MPL3115A2 object.

Parameters:
i2c- A defined I2C object
int1- A defined InterruptIn object pointer. Default NULL for polling mode
int2- A defined InterruptIn object pointer. Default NULL for polling mode TODO - Need to add interrupt support

Definition at line 27 of file MPL3115A2.cpp.


Member Function Documentation

uint8_t activeMode ( void   )

Put the MPL3115A2 in the active mode.

Returns:
status of command

Definition at line 119 of file MPL3115A2.cpp.

uint8_t clearMinMaxRegs ( void   )

Clears all minimum and maximum data registers.

Returns:
status of command

Definition at line 168 of file MPL3115A2.cpp.

MPL3115A2_DATA getAllData ( bool  clear_data )

Get the MP3115A2 data structure.

Parameters:
Booleantrue clears all MIN/MAX registers after reading
Returns:
MPL3115A2_DATA structure

Definition at line 296 of file MPL3115A2.cpp.

int32_t getBaroData ( void   )

Get the Pressure or Altitude data.

Returns:
The last valid pressure based reading from the barometric sensor

Definition at line 190 of file MPL3115A2.cpp.

int32_t getMaxBaro ( bool  clear_data )

Get the Maximum Pressure or Altitude data.

Parameters:
Booleantrue clears the register after reading
Returns:
The Maximum Pressure or Altitude read since last cleared

Definition at line 236 of file MPL3115A2.cpp.

int16_t getMaxTemp ( bool  clear_data )

Get the Maximum Temperature data.

Parameters:
Booleantrue clears the register after reading
Returns:
The Maximum temperature read since last cleared

Definition at line 276 of file MPL3115A2.cpp.

int32_t getMinBaro ( bool  clear_data )

Get the Minimum Pressure or Altitude data.

Parameters:
BooleanTRUE clears the register after reading
Returns:
The Minimum Pressure or Altitude read since last cleared

Definition at line 217 of file MPL3115A2.cpp.

int16_t getMinTemp ( bool  clear_data )

Get the Minimum Temperature data.

Parameters:
Booleantrue clears the register after reading
Returns:
The Minimum temperature read since last cleared

Definition at line 256 of file MPL3115A2.cpp.

uint8_t getStatus ( void   )

Check the MPL3115A2 status register.

Returns:
status byte

Definition at line 179 of file MPL3115A2.cpp.

int16_t getTempData ( void   )

Get the Temperature data.

Returns:
The last valid temperature reading from the barometric sensor

Definition at line 203 of file MPL3115A2.cpp.

uint8_t setAltitudeCalib ( int16_t  alti_calib )

Set the sea level equivalent pressure for Altitude mode - Value is Equivalent sea level pressure for measurement location (2 Pa resolution)

Returns:
status byte

Definition at line 157 of file MPL3115A2.cpp.

uint8_t setParameters ( OUTPUT_MODE  out_mode,
DATA_MODE  data_mode,
OVERSAMPLE_RATIO  os_ratio,
ACQUISITION_TIMER  measure_time 
)

Setup the MPL3115A2 for standard barometric sensor read mode - Turns Data post processing ON/OFF using the OUTPUT_MODE enum - Sets Pressure or Altitude mode using the DATA_MODE enum - Sets the Oversample ration using the OVERSAMPLE_RATIO enum - Sets the Aquisition time for Active mode using the ACQUISITION_TIMER enum.

Returns:
status of command

This sets the resolution, range, data rate, oversample mode, hi and lo pass filter.

Definition at line 86 of file MPL3115A2.cpp.

uint8_t standbyMode ( void   )

Put the MPL3115A2 in the Standby mode.

Returns:
status of command TODO - need to implement function

Definition at line 131 of file MPL3115A2.cpp.

bool testWhoAmI ( void   )

Test the Who am I register for valid ID.

Returns:
Boolean true if valid device

Definition at line 38 of file MPL3115A2.cpp.

uint8_t triggerOneShot ( void   )

Triggers the MPL3115A2 to take one measurement in Active or Standby mode.

Returns:
status of command

Definition at line 144 of file MPL3115A2.cpp.