![]() ![]() ![]() ![]() |
|
This module provides an interface to the popular Freescale MPL3115A2 pressure and temperature sensor.
It uses HiPi::BCM2835::I2C as a backend
HiPi::BCM2835::I2C supports the read method employing repeated starts that MPL31152 requires.
Currently only one shot methods and some utilities are wrapped. It is recommeded that you implement your own module inheriting from HiPi::Interface::MPL3115A2 to suit your own requirement.
use HiPi::BCM2835::I2C qw( :all ); register addresses MPL_REG_F_STATUS MPL_REG_F_DATA MPL_REG_F_SETUP MPL_REG_TIME_DLY MPL_REG_SYSMOD MPL_REG_INT_SOURCE MPL_REG_PT_DATA_CFG MPL_REG_BAR_IN_MSB MPL_REG_MAR_IN_LSB MPL_REG_P_TGT_MSB MPL_REG_P_TGT_LSB MPL_REG_T_TGT MPL_REG_P_WND_MSB MPL_REG_P_WND_LSB MPL_REG_T_WND MPL_REG_P_MIN_MSB MPL_REG_P_MIN_CSB MPL_REG_P_MIN_LSB MPL_REG_T_MIN_MSB MPL_REG_T_MIN_LSB MPL_REG_P_MAX_MSB MPL_REG_P_MAX_CSB MPL_REG_P_MAX_LSB MPL_REG_T_MAX_MSB MPL_REG_T_MAX_LSB MPL_REG_CTRL_REG1 MPL_REG_CTRL_REG2 MPL_REG_CTRL_REG3 MPL_REG_CTRL_REG4 MPL_REG_CTRL_REG5 MPL_REG_OFF_P MPL_REG_OFF_T MPL_REG_OFF_H bitmasks for CTRL_REG1 MPL_CTRL_REG1_SBYB MPL_CTRL_REG1_OST MPL_CTRL_REG1_RST MPL_CTRL_REG1_OS0 MPL_CTRL_REG1_OS1 MPL_CTRL_REG1_OS2 MPL_CTRL_REG1_RAW MPL_CTRL_REG1_ALT MPL_CTRL_REG1_MASK bitmasks for CTRL_REG2 MPL_CTRL_REG2_ST0 MPL_CTRL_REG2_ST1 MPL_CTRL_REG2_ST2 MPL_CTRL_REG2_ST3 MPL_CTRL_REG2_ALARM_SEL MPL_CTRL_REG2_LOAD_OUTPUT MPL_CTRL_REG2_MASK bitmasks for CTRL_REG3 MPL_CTRL_REG3_PP_0D2 MPL_CTRL_REG3_IPOL2 MPL_CTRL_REG3_PP_OD1 MPL_CTRL_REG3_IPOL1 MPL_CTRL_REG3_MASK bitmasks for CTRL_REG4 MPL_CTRL_REG4_INT_EN_DRDY MPL_CTRL_REG4_INT_EN_FIFO MPL_CTRL_REG4_INT_EN_PW MPL_CTRL_REG4_INT_EN_TW MPL_CTRL_REG4_INT_EN_PTH MPL_CTRL_REG4_INT_EN_TTH MPL_CTRL_REG4_INT_EN_PCHG MPL_CTRL_REG4_INT_EN_TCHG MPL_CTRL_REG4_MASK bitmasks for all interrrupt registers MPL_INTREGS_DRDY MPL_INTREGS_FIFO MPL_INTREGS_PW MPL_INTREGS_TW MPL_INTREGS_PTH MPL_INTREGS_TTH MPL_INTREGS_PCHG MPL_INTREGS_TCHG MPL_INTREGS_MASK bitmasks for DR_STATUS MPL_DR_STATUS_PTOW MPL_DR_STATUS_POW MPL_DR_STATUS_TOW MPL_DR_STATUS_PTDR MPL_DR_STATUS_PDR MPL_DR_STATUS_TDR MPL_DR_STATUS_MASK bitmasks for F_STATUS MPL_F_STATUS_F_OVF MPL_F_STATUS_F_WMRK_FLAG MPL_F_STATUS_F_CNT5 MPL_F_STATUS_F_CNT4 MPL_F_STATUS_F_CNT3 MPL_F_STATUS_F_CNT2 MPL_F_STATUS_F_CNT1 MPL_F_STATUS_F_CNT0 MPL_F_STATUS_MASK bitmasks for data configuration MPL_PT_DATA_CFG_DREM MPL_PT_DATA_CFG_PDEFE MPL_PT_DATA_CFG_TDEFE MPL_PT_DATA_CFG_MASK standard recommended delay of 550 ms is one shot mode MPL_OSREAD_DELAY data mode flags MPL_FUNC_ALTITUDE MPL_FUNC_PRESSURE fixed device id 196 MPL3115A2_ID
Returns a new instance of the HiPi::Interface::MPL3115A2 class. Optional key => values pairs in %params and their defaults address => 0x60, peripheral => ( RPi board rev == 1 ) ? BB_I2C_PERI_0 : BB_I2C_PERI_0, you can import the peripheral constants into your code using use HiPi::BCM2835::I2C qw( :i2c );
Returns false in standy mode, true in active mode.
Returns standard id MPL3115A2_ID. Often used as a method of confirming correct communication.
One shot method returning an array containing converted values for altitude, pressure and temperature.
$function is one of MPL_FUNC_PRESSURE or MPL_FUNC_ALTITUDE One shot method returning an array containing 2 converted values for altitude or pressure as chosen by $function, and temperature.
One shot method returning altitude value.
One shot method returning pressure value.
One shot method returning temperature value.
Takes the values returned from a call such as : $sen->device->i2c_read_register_rs(MPL_REG_OUT_P_MSB, 3) and converts them to a pressure value in pascals.
Takes a pressure in pascals and converts it to three bytes suitable for passing to offset configuration registers.
Takes the values returned from a call such as : $sen->device->i2c_read_register_rs(MPL_REG_OUT_P_MSB, 3) and converts them to an altitude value in meters.
Takes an altitude in meters and converts it to three bytes suitable for passing to offset configuration registers.
Takes the values returned from a call such as : $sen->device->i2c_read_register_rs(MPL_REG_OUT_T_MSB, 2) and converts them to a temperature value.
Takes a temperature and converts it to two bytes suitable for passing to offset configuration registers.