NAME Device::Chip::MPL3115A2 - chip driver for a MPL3115A2 SYNOPSIS use Device::Chip::MPL3115A2; use Future::AsyncAwait; my $chip = Device::Chip::MPL3115A2->new; await $chip->mount( Device::Chip::Adapter::...->new ); printf "Current pressure is %.2f kPa\n", await $chip->read_pressure; DESCRIPTION This Device::Chip subclass provides specific communication to a Freescale Semiconductor MPL3115A2 attached to a computer via an I²C adapter. The reader is presumed to be familiar with the general operation of this chip; the documentation here will not attempt to explain or define chip-specific concepts or features, only the use of this module to access them. ACCESSORS The following methods documented in an await expression return Future instances. read_config $config = await $chip->read_config; Returns a HASH reference of the contents of control registers CTRL_REG1 to CTRL_REG3, using fields named from the data sheet. SBYB => "STANDBY" | "ACTIVE" OST => 0 | 1 RST => 0 | 1 OS => 1 | 2 | 4 | ... | 64 | 128 RAW => 0 | 1 ALT => 0 | 1 ST => 1 | 2 | 4 | ... | 16384 | 32768 ALARM_SEL => 0 | 1 LOAD_OUTPUT => 0 | 1 IPOL1 => 0 | 1 PP_OD1 => 0 | 1 IPOL2 => 0 | 1 PP_OD2 => 0 | 1 change_config await $chip->change_config( %changes ); Writes updates to the control registers CTRL_REG1 to CTRL_REG3. This will be performed as a read-modify-write operation, so any fields not given as arguments to this method will retain their current values. Note that these two methods use a cache of configuration bytes to make subsequent modifications more efficient. This cache will not respect the "one-shot" nature of the OST and RST bits. get_sealevel_pressure set_sealevel_pressure $pressure = await $chip->get_sealevel_pressure; await $chip->set_sealevel_pressure( $pressure ); Read or write the barometric pressure calibration register which is used to convert pressure to altitude when the chip is in altimeter mode, in Pascals. The default value is 101,326 Pa. read_pressure $pressure = await $chip->read_pressure; Returns the value of the OUT_P_* registers, suitably converted into Pascals. (The chip must be in barometer mode and must not be in RAW mode for the conversion to work). read_altitude $altitude = await $chip->read_altitude; Returns the value of the OUT_P_* registers, suitably converted into metres. (The chip must be in altimeter mode and must not be in RAW mode for the conversion to work). read_temperature $temperature = await $chip->read_temperature; Returns the value of the OUT_T_* registers, suitable converted into degrees C. (The chip must not be in RAW mode for the conversion to work). read_min_pressure read_max_pressure $pressure = await $chip->read_min_pressure; $pressure = await $chip->read_max_pressure; Returns the values of the P_MIN and P_MAX registers, suitably converted into Pascals. clear_min_pressure clear_max_pressure await $chip->clear_min_pressure; await $chip->clear_max_pressure; Clear the P_MIN or P_MAX registers, resetting them to start again from the next measurement. read_min_altitude read_max_altitude $altitude = await $chip->read_min_altitude; $altitude = await $chip->read_max_altitude; Returns the values of the P_MIN and P_MAX registers, suitably converted into metres. clear_min_altitude clear_max_altitude await $chip->clear_min_altitude; await $chip->clear_max_altitude; Clear the P_MIN or P_MAX registers, resetting them to start again from the next measurement. read_min_temperature read_max_temperature $temperature = await $chip->read_min_temperature; $temperature = await $chip->read_max_temperature; Returns the values of the T_MIN and T_MAX registers, suitably converted into metres. clear_min_temperature clear_max_temperature await $chip->clear_min_temperature; await $chip->clear_max_temperature; Clear the T_MIN or T_MAX registers, resetting them to start again from the next measurement. METHODS check_id await $chip->check_id; Reads the WHO_AM_I register and checks for a valid ID result. The returned future fails if the expected result is not received. start_oneshot await $chip->start_oneshot; Sets the OST bit of CTRL_REG1 to start a one-shot measurement when in standby mode. After calling this method you will need to use busywait_oneshot to wait for the measurement to finish, or rely somehow on the interrupts. busywait_oneshot await $chip->busywait_oneshot; Repeatedly reads the OST bit of CTRL_REG1 until it becomes clear. oneshot await $chip->oneshot; A convenient wrapper around start_oneshot and busywait_oneshot. AUTHOR Paul Evans