MPL3115A2_Arduino 1.0.1
This library enables the developer to evaluate NXP MPL3115A2(S) with 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. | |
Definition at line 30 of file MPL3115A2_Arduino.h.
MPL3115A2_Arduino::MPL3115A2_Arduino | ( | ) |
Create a MPL3115A2_Arduino instance
Definition at line 16 of file MPL3115A2_Arduino.cpp.
MPL3115A2_Arduino::MPL3115A2_Arduino | ( | uint8_t | i2c_address | ) |
Create a MPL3115A2_Arduino instance
i2c_address | If 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::MPL3115A2_Arduino | ( | TwoWire & | wire, |
uint8_t | i2c_address = I2C_address |
||
) |
Create a MPL3115A2_Arduino instance
wire | TwoWire instance |
i2c_address | If the device is configured with address other than I2C_address(=0x60), put its address here. |
Definition at line 18 of file MPL3115A2_Arduino.cpp.
|
virtual |
Destructor of MPL3115A2_Arduino
Definition at line 19 of file MPL3115A2_Arduino.cpp.
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
reg | register index/address/pointer |
mask | bit-mask to protect overwriting |
value | value to overwrite |
Referenced by dis_interrupt(), and set_interrupt().
void MPL3115A2_Arduino::dis_interrupt | ( | uint8_t | flag | ) |
Disable interrupt function of MPL3115A2.
flag | Flag for disabling interruption: Selected from "CTRL_REG4 - Bit field value definitions" in mpl3115.h |
Definition at line 57 of file MPL3115A2_Arduino.cpp.
float MPL3115A2_Arduino::getP | ( | ) |
Get the pressure conversion result by reading OUT_P_xxx registers. This clears interruption.
Definition at line 61 of file MPL3115A2_Arduino.cpp.
Referenced by getP().
float MPL3115A2_Arduino::getP | ( | mpl3115_pressure_target | target | ) |
Get the pressure conversion result by reading OUT_P_xxx_xxx registers.
target | Select from mpl3115_pressure_target if you would like to read the registers other than OUT_P_xxx |
Definition at line 65 of file MPL3115A2_Arduino.cpp.
float MPL3115A2_Arduino::getT | ( | ) |
Get the temperature conversion result by reading OUT_T_xxx registers. This clears interruption.
Definition at line 80 of file MPL3115A2_Arduino.cpp.
Referenced by getT().
float MPL3115A2_Arduino::getT | ( | mpl3115_temperature_target | target | ) |
Get the temperature conversion result by reading OUT_T_xxx_xxx registers.
target | Select from mpl3115_temperature_target if you would like to read the registers other than OUT_T_xxx |
Definition at line 84 of file MPL3115A2_Arduino.cpp.
uint8_t MPL3115A2_Arduino::init | ( | ) |
Initialize the device with reset with several GPIO pin configuration.
Definition at line 21 of file MPL3115A2_Arduino.cpp.
Referenced by init().
uint8_t MPL3115A2_Arduino::init | ( | bool | pinconfig | ) |
Initialize the device with reset.
pinconfig | If you wouldn't like to config the pins by this function, put false in this parameter. This parameter can be skipped. |
Definition at line 25 of file MPL3115A2_Arduino.cpp.
bool MPL3115A2_Arduino::ping | ( | void | ) |
Ping the device
|
virtual |
Get temperature value in degree Celsius [°C]
This method simply calls "temp()" method
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
reg | register index/address/pointer |
uint8_t MPL3115A2_Arduino::read_r8 | ( | uint8_t | reg | ) |
Register read, 8 bit
reg | register index/address/pointer |
Referenced by init().
uint8_t MPL3115A2_Arduino::reg_r | ( | uint8_t | reg_adr | ) |
Single register read
reg | register index/address/pointer |
int MPL3115A2_Arduino::reg_r | ( | uint8_t | reg_adr, |
uint8_t * | data, | ||
uint16_t | size | ||
) |
int MPL3115A2_Arduino::reg_w | ( | uint8_t | reg_adr, |
uint8_t * | data, | ||
uint16_t | size | ||
) |
Multiple register write
reg | register index/address/pointer |
data | pointer to data buffer |
size | data size |
Referenced by set_sealevel(), and set_threshold().
int MPL3115A2_Arduino::reg_w | ( | uint8_t | reg_adr, |
uint8_t | data | ||
) |
Single register write
reg | register index/address/pointer |
data | pointer to data buffer |
size | data size |
void MPL3115A2_Arduino::set_interrupt | ( | uint8_t | flag, |
mpl3115_INT | channel | ||
) |
Set interrupt function of MPL3115A2.
flag | Flag for interruption: Selected from "CTRL_REG4 - Bit field value definitions" in mpl3115.h |
channel | Sets the flag in INT1 or 2. Be selected from mpl3115_INT |
Definition at line 52 of file MPL3115A2_Arduino.cpp.
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().
void MPL3115A2_Arduino::set_sealevel | ( | float | pressure | ) |
Set reference sea level for altitude calculation.
pressure | Reference sea level value in kPa unit |
Definition at line 98 of file MPL3115A2_Arduino.cpp.
void MPL3115A2_Arduino::set_threshold | ( | float | pressure, |
uint8_t | temperature, | ||
float | pressure_window = 0 , |
||
uint8_t | temperature_window = 0 |
||
) |
Set threshold (target) for interruption.
pressure | Pressure threshold (target) for threshold interruption in kPa unit |
temperature | Temperature threshold (target) for threshold interruption in degC unit |
pressure_window | Pressure window value referring to target for window interruption in kPa unit |
temperature_window | Temperature window value referring to target for window interruption in degC unit |
Definition at line 104 of file MPL3115A2_Arduino.cpp.
void MPL3115A2_Arduino::start_conversion | ( | ) |
Start conversion.
Definition at line 37 of file MPL3115A2_Arduino.cpp.
Referenced by start_conversion().
void MPL3115A2_Arduino::start_conversion | ( | mpl3115_mode | _mode, |
uint8_t | _oneshot, | ||
uint8_t | _oversample | ||
) |
Start conversion with settings.
_mode | Setting for mode parameter in this class |
_oneshot | Setting for oneshot parameter in this class |
_oversample | Setting for oversample parameter in this class |
Definition at line 41 of file MPL3115A2_Arduino.cpp.
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
reg | register index/address/pointer |
val | data value |
void MPL3115A2_Arduino::write_r8 | ( | uint8_t | reg, |
uint8_t | val | ||
) |
Register write, 8 bit
reg | register index/address/pointer |
val | data value |
Referenced by init(), and start_conversion().
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().
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().
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().