mpl3115a2 v0.1.0 MPL3115A2.Commands

Commands for reading and modifying the device's registers.

Link to this section Summary

Functions

ALARM_SEL The bit selects the Target value for SRC_PW/SRC_TW and SRC_PTH/SRC_TTH

ALT Altimeter-Barometer mode.

OUT_P Altitude in meters.

OUT_P_DELTA Altitude delta in meters.

OFF_H Altitude Offset

SRC_PCHG Delta P interrupt status.

SRC_PW Altitude/Pressure alerter status near or equal to target Pressure/Altitude.

SRC_PTH Altitude/Pressure threshold interrupt.

BAR_IN Barometric input for altitude calculations.

ST Auto acquisition time step.

DREM Data ready event mode.

SRC_DRDY Data ready interrupt status.

F_WMRK FIFO Event Sample Count Watermark.

SRC_FIFO FIFO interrupt status.

F_OVF FIFO overflow events detected?

F_MODE FIFO mode, can be either :fifo_disabled, :circular_buffer or :halt_on_overflow.

F_DATA Read FIFO data in Altitude mode.

F_DATA Read FIFO data in Barometer mode.

F_CNT FIFO sample count

F_WMRK_FLAG FIFO watermark events detected?

Tries to configure the device according to sane defaults.

IPOL1 The IPOL bit selects the polarity of the interrupt signal.

PP_OD1 This bit configures the interrupt pin to Push-Pull or in Open Drain mode.

IPOL2 Interrupt Polarity active high, or active low on interrupt pad INT2.

PP_OD2 Push-Pull/Open Drain selection on interrupt pad INT2.

INT_EN_DRDY Data Ready Interrupt Enable.

INT_EN_FIFO FIFO Interrupt Enable.

INT_EN_PCHG Pressure Change Interrupt Enable.

INT_EN_PTH Pressure Threshold Interrupt Enable.

INT_EN_PW Pressure Window Interrupt Enable.

INT_EN_TCHG Temperature Change Interrupt Enable.

INT_EN_TTH Temperature Threshold Interrupt Enable.

INT_EN_TW Temperature Window Interrupt Enable.

INT_CFG_DRDY Data Ready Interrupt Pin Select.

INT_CFG_FIFO FIFO Interrupt Pin Select.

INT_CFG_PCHG - Pressure Change Interrupt Pin Select

INT_CFG_PTH Pressure Threshold Interrupt Pin Select

INT_CFG_PW Pressure Window Interrupt Pin Select

INT_CFG_TCHG - Temperature Change Interrupt Pin Select

INT_CFG_TTH Temperature Threshold Interrupt Pin Select

INT_CFG_TW Temperature Window Interrupt Pin Select

LOAD_OUTPUT This is to load the target values for SRC_PW/SRC_TW and SRC_PTH/SRC_TTH.

P_MAX Captured maximum Pressure/Altitude value.

T_MAX Captured maximum temperature value.

P_MIN Captured minimum Pressure/Altitude value.

T_MIN Captured minimum temperature value.

OST One-shot measurement

Oversample delay in ms.

OS Oversample Ratio.

OUT_P Pressure in Pascals.

PDEFE Data event flag enable on new Pressure/Altitude data.

P_TGT Altitude/Pressure target value.

P_WND Pressure/Altitude window value.

PDR Pressure/Altitude new data available.

POW Pressure/Altitude data overwrite.

OUT_P_DELTA Pressure delta in Pascals.

OFF_P Pressure Offset

PTOW Pressure/Altitude OR Temperature data overwrite.

PTDR Pressure/Altitude OR Temperature data ready.

RAW Raw output mode.

RST Software Reset.

SBYB System Standby

SYSMOD System Mode, either :standby or :active.

OUT_T Temperature in ℃.

TDR Temperature new Data Available.

TOW Temperature data overwrite.

OUT_T_DELTA Temperature delta in ℃.

SRC_TCHG Delta T interrupt status.

TDEFE Data event flag enable on new Temperature data.

SRC_TW Temperature alerter status bit near or equal to target temperature.

OFF_T Temperature Offset

T_TGT Temperature target value input in °C.

SRC_TTH Temperature threshold interrupt.

T_WND Temperature alarm window value in °C.

TIME_DLY

WHO_AM_I Should always respond with 0x0c.

Link to this section Functions

Link to this function

alarm_select(pid)

ALARM_SEL The bit selects the Target value for SRC_PW/SRC_TW and SRC_PTH/SRC_TTH

Default value: 0 0: The values in P_TGT_MSB, P_TGT_LSB and T_TGT are used (Default) 1: The values in OUT_P/OUT_T are used for calculating the interrupts SRC_PW/SRC_TW and SRC_PTH/SRC_TTH.

Link to this function

alarm_select(pid, i)

Link to this function

altimeter_or_barometer(pid)

ALT Altimeter-Barometer mode.

Selects whether the device is in Altimeter or Barometer mode. Can be either :barometer or :altimeter.

Link to this function

altimeter_or_barometer(pid, atom)

OUT_P Altitude in meters.

Link to this function

altitude_delta(pid)

OUT_P_DELTA Altitude delta in meters.

Link to this function

altitude_offset(pid)

OFF_H Altitude Offset

Altitude user accessible offset trim value.

Link to this function

altitude_offset(pid, value)

Link to this function

altitude_pressure_delta_interrupt?(pid)

SRC_PCHG Delta P interrupt status.

Link to this function

altitude_pressure_interrupt?(pid)

SRC_PW Altitude/Pressure alerter status near or equal to target Pressure/Altitude.

Near is within target value ± window value. Window value needs to be non zero for interrupt to trigger.

Link to this function

altitude_pressure_threshold_interrupt?(pid)

SRC_PTH Altitude/Pressure threshold interrupt.

With the window set to a non zero value, the trigger will occur on crossing any of the thresholds: upper, center or lower. If the window is set to 0, it will only trigger on crossing the center threshold.

Link to this function

barometric_pressure_input(pid)

BAR_IN Barometric input for altitude calculations.

Input is equivalent sea level pressure for measurement location.

Link to this function

barometric_pressure_input(pid, pascals)

Link to this function

data_acquisition_time_step(pid)

ST Auto acquisition time step.

Link to this function

data_acquisition_time_step(pid, value)

Link to this function

data_ready_event_mode(pid)

DREM Data ready event mode.

If the DREM bit is set true and one or more of the data ready event flags (PDEFE, TDEFE) are enabled, then an event flag will be raised upon change in state of the data. If the DREM bit is false and one or more of the data ready event flags are enabled, then an event flag will be raised whenever the system acquires a new set of data.

Default value: false.

Link to this function

data_ready_event_mode(pid, bool)

Link to this function

data_ready_interrupt?(pid)

SRC_DRDY Data ready interrupt status.

true indicates that Pressure/Altitude or Temperature data ready interrupt is active indicating the presence of new data and/or a data overwrite, otherwise it is false.

Link to this function

fifo_event_sample_count_watermark(pid)

F_WMRK FIFO Event Sample Count Watermark.

Link to this function

fifo_event_sample_count_watermark(pid, count)

Link to this function

fifo_interrupt?(pid)

SRC_FIFO FIFO interrupt status.

true indicates that a FIFO interrupt event such as an overflow event has occurred. false indicates that no FIFO interrupt event has occurred.

Link to this function

fifo_overflow?(pid)

F_OVF FIFO overflow events detected?

Link to this function

fifo_overflow_mode(pid)

F_MODE FIFO mode, can be either :fifo_disabled, :circular_buffer or :halt_on_overflow.

Link to this function

fifo_overflow_mode(pid, atom)

Link to this function

fifo_read_altitude(pid)

F_DATA Read FIFO data in Altitude mode.

Link to this function

fifo_read_pressure(pid)

F_DATA Read FIFO data in Barometer mode.

Link to this function

fifo_sample_count(pid)

F_CNT FIFO sample count

Link to this function

fifo_watermark?(pid)

F_WMRK_FLAG FIFO watermark events detected?

Link to this function

initialize!(pid, config)

Tries to configure the device according to sane defaults.

config is a map containing any of the following keys:

  • :standby set to true to put the device in standby, otherwise defaults to false.
  • :oversample set to the oversample rate you want. Valid values are two's complements from 1 to 128. Defaults to 128.
  • :mode, set to either :altimeter or :barometer. Defaults to :altimeter.
  • :event_on_new_temperature set to false to disable. Defaults to true.
  • :event_on_new_pressure set to false to disable. Defaults to true.
  • :data_ready_event_mode set to false to disable. Defaults to true.
Link to this function

interrupt1_polarity(pid)

IPOL1 The IPOL bit selects the polarity of the interrupt signal.

When IPOL is ‘0’ (default value) any interrupt event will signalled with a logical ‘0'. Interrupt Polarity active high, or active low on interrupt pad INT1. Default value: 0 0: Active low 1: Active high

Link to this function

interrupt1_polarity(pid, i)

Link to this function

interrupt1_pp_or_od(pid)

PP_OD1 This bit configures the interrupt pin to Push-Pull or in Open Drain mode.

The default value is 0 which corresponds to Push-Pull mode. The open drain configuration can be used for connecting multiple interrupt signals on the same interrupt line. Push-Pull/Open Drain selection on interrupt pad INT1.

Default value: 0 0: Internal Pullup 1: Open drain

Link to this function

interrupt1_pp_or_od(pid, i)

Link to this function

interrupt2_polarity(pid)

IPOL2 Interrupt Polarity active high, or active low on interrupt pad INT2.

Default value: 0 0: Active low 1: Active high

Link to this function

interrupt2_polarity(pid, i)

Link to this function

interrupt2_pp_or_od(pid)

PP_OD2 Push-Pull/Open Drain selection on interrupt pad INT2.

Default value: 0 0: Internal Pull-up 1: Open drain

Link to this function

interrupt2_pp_or_od(pid, i)

Link to this function

interrupt_enable_data_ready(pid)

INT_EN_DRDY Data Ready Interrupt Enable.

Default value: 0 0: Data Ready interrupt disabled 1: Data Ready interrupt enabled

Link to this function

interrupt_enable_data_ready(pid, i)

Link to this function

interrupt_enable_fifo(pid)

INT_EN_FIFO FIFO Interrupt Enable.

Default value: 0 0: FIFO interrupt disabled 1: FIFO interrupt enabled

Link to this function

interrupt_enable_fifo(pid, i)

Link to this function

interrupt_enable_pressure_change(pid)

INT_EN_PCHG Pressure Change Interrupt Enable.

Default value: 0 0: Pressure Change interrupt disabled 1: Pressure Change interrupt enabled

Link to this function

interrupt_enable_pressure_change(pid, i)

Link to this function

interrupt_enable_pressure_threshold(pid)

INT_EN_PTH Pressure Threshold Interrupt Enable.

Default value: 0 0: Pressure Threshold interrupt disabled 1: Pressure Threshold interrupt enabled

Link to this function

interrupt_enable_pressure_threshold(pid, i)

Link to this function

interrupt_enable_pressure_window(pid)

INT_EN_PW Pressure Window Interrupt Enable.

Default value: 0 0: Pressure window interrupt disabled 1: Pressure window interrupt enabled

Link to this function

interrupt_enable_pressure_window(pid, i)

Link to this function

interrupt_enable_temperature_change(pid)

INT_EN_TCHG Temperature Change Interrupt Enable.

Default value: 0 0: Temperature Change interrupt disabled 1: Temperature Change interrupt enabled

Link to this function

interrupt_enable_temperature_change(pid, i)

Link to this function

interrupt_enable_temperature_threshold(pid)

INT_EN_TTH Temperature Threshold Interrupt Enable.

Default value: 0 0: Temperature Threshold interrupt disabled 1: Temperature Threshold interrupt enabled

Link to this function

interrupt_enable_temperature_threshold(pid, i)

Link to this function

interrupt_enable_temperature_window(pid)

INT_EN_TW Temperature Window Interrupt Enable.

Interrupt Enable. Default value: 0 0: Temperature window interrupt disabled 1: Temperature window interrupt enabled

Link to this function

interrupt_enable_temperature_window(pid, i)

Link to this function

interrupt_pin_data_ready(pid)

INT_CFG_DRDY Data Ready Interrupt Pin Select.

1 - Interrupt Pin 1 2 - Interrupt Pin 2

Link to this function

interrupt_pin_data_ready(pid, i)

Link to this function

interrupt_pin_fifo(pid)

INT_CFG_FIFO FIFO Interrupt Pin Select.

1 - Interrupt Pin 1 2 - Interrupt Pin 2

Link to this function

interrupt_pin_fifo(pid, i)

Link to this function

interrupt_pin_pressure_change(pid)

INT_CFG_PCHG - Pressure Change Interrupt Pin Select

1 - Interrupt Pin 1 2 - Interrupt Pin 2

Link to this function

interrupt_pin_pressure_change(pid, i)

Link to this function

interrupt_pin_pressure_threshold(pid)

INT_CFG_PTH Pressure Threshold Interrupt Pin Select

1 - Interrupt Pin 1 2 - Interrupt Pin 2

Link to this function

interrupt_pin_pressure_threshold(pid, i)

Link to this function

interrupt_pin_pressure_window(pid)

INT_CFG_PW Pressure Window Interrupt Pin Select

1 - Interrupt Pin 1 2 - Interrupt Pin 2

Link to this function

interrupt_pin_pressure_window(pid, i)

Link to this function

interrupt_pin_temperature_change(pid)

INT_CFG_TCHG - Temperature Change Interrupt Pin Select

1 - Interrupt Pin 1 2 - Interrupt Pin 2

Link to this function

interrupt_pin_temperature_change(pid, i)

Link to this function

interrupt_pin_temperature_threshold(pid)

INT_CFG_TTH Temperature Threshold Interrupt Pin Select

1 - Interrupt Pin 1 2 - Interrupt Pin 2

Link to this function

interrupt_pin_temperature_threshold(pid, i)

Link to this function

interrupt_pin_temperature_window(pid)

INT_CFG_TW Temperature Window Interrupt Pin Select

1 - Interrupt Pin 1 2 - Interrupt Pin 2

Link to this function

interrupt_pin_temperature_window(pid, i)

Link to this function

load_output(pid)

LOAD_OUTPUT This is to load the target values for SRC_PW/SRC_TW and SRC_PTH/SRC_TTH.

Default value: 0 0: Do not load OUT_P/OUT_T as target values 1: The next values of OUT_P/OUT_T are used to set the target values for the interrupts. Note:

  1. This bit must be set at least once if ALARM_SEL=1
  2. To reload the next OUT_P/OUT_T as the target values clear and set again.
Link to this function

load_output(pid, i)

Link to this function

maximum_pressure(pid)

P_MAX Captured maximum Pressure/Altitude value.

Link to this function

maximum_temperature(pid)

T_MAX Captured maximum temperature value.

Link to this function

minimum_pressure(pid)

P_MIN Captured minimum Pressure/Altitude value.

Link to this function

minimum_temperature(pid)

T_MIN Captured minimum temperature value.

OST One-shot measurement

OST bit will initiate a measurement immediately. If the SBYB bit is set to active, setting the OST bit will initiate an immediate measurement, the part will then return to acquiring data as per the setting of the ST bits in CTRL_REG2. In this mode, the OST bit does not clear itself and must be cleared and set again to initiate another immediate measurement.

One Shot: When SBYB is 0, the OST bit is an auto-clear bit. When OST is set, the device initiates a measurement by going into active mode. Once a Pressure/Altitude and Temperature measurement is completed, it clears the OST bit and comes back to STANDBY mode. User shall read the value of the OST bit before writing to this bit again.

Link to this function

one_shot(pid, bool)

Link to this function

oversample_delay(pid)

Oversample delay in ms.

Link to this function

oversample_ratio(pid)

OS Oversample Ratio.

These bits select the oversampling ratio.

Link to this function

oversample_ratio(pid, value)

OUT_P Pressure in Pascals.

Link to this function

pressure_altitude_event_flag_enable(pid)

PDEFE Data event flag enable on new Pressure/Altitude data.

Default value: false.

Link to this function

pressure_altitude_event_flag_enable(pid, bool)

Link to this function

pressure_altitude_target(pid)

P_TGT Altitude/Pressure target value.

This value works in conjunction with the window value (P_WND).

In Altitude mode the result is in meters. In Pressure mode the result is in Pascals.

Link to this function

pressure_altitude_target(pid, value)

Link to this function

pressure_altitude_window(pid)

P_WND Pressure/Altitude window value.

In Altitude mode the result is in meters. In Pressure mode the result is in Pascals.

Link to this function

pressure_data_available(pid)

PDR Pressure/Altitude new data available.

Link to this function

pressure_data_overwrite(pid)

POW Pressure/Altitude data overwrite.

Link to this function

pressure_delta(pid)

OUT_P_DELTA Pressure delta in Pascals.

Link to this function

pressure_offset(pid)

OFF_P Pressure Offset

Pressure user accessible offset trim value.

Link to this function

pressure_offset(pid, value)

Link to this function

pressure_or_temperature_data_overwrite(pid)

PTOW Pressure/Altitude OR Temperature data overwrite.

Link to this function

pressure_or_temperature_data_ready(pid)

PTDR Pressure/Altitude OR Temperature data ready.

RAW Raw output mode.

RAW bit will output ADC data with no post processing, except for oversampling. No scaling or offsets will be applied in the digital domain. The FIFO must be disabled and all other functionality: Alarms, Deltas, and other interrupts are disabled.

RST Software Reset.

This bit is used to activate the software reset. The Boot mechanism can be enabled in STANDBY and ACTIVE mode.

When the Boot bit is enabled the boot mechanism resets all functional block registers and loads the respective internal registers with default values. If the system was already in STANDBY mode, the reboot process will immediately begin; else if the system was in ACTIVE mode, the boot mechanism will automatically transition the system from ACTIVE mode to STANDBY mode, only then can the reboot process begin.

The I2C communication system is reset to avoid accidental corrupted data access.

At the end of the boot process the RST bit is de-asserted to false. Reading this bit will return a value of false.

Default value: false false: Device reset disabled true: Device reset enabled

Link to this function

standby(pid, bool)

SBYB System Standby

Link to this function

system_mode(pid)

SYSMOD System Mode, either :standby or :active.

Link to this function

temperature(pid)

OUT_T Temperature in ℃.

Link to this function

temperature_data_available(pid)

TDR Temperature new Data Available.

Link to this function

temperature_data_overwrite(pid)

TOW Temperature data overwrite.

Link to this function

temperature_delta(pid)

OUT_T_DELTA Temperature delta in ℃.

Link to this function

temperature_delta_interrupt?(pid)

SRC_TCHG Delta T interrupt status.

Link to this function

temperature_event_flag_enable(pid)

TDEFE Data event flag enable on new Temperature data.

Default value: false.

Link to this function

temperature_event_flag_enable(pid, bool)

Link to this function

temperature_interrupt?(pid)

SRC_TW Temperature alerter status bit near or equal to target temperature.

Near is within target value ± window value. Window value needs to be non zero for interrupt to trigger.

Link to this function

temperature_offset(pid)

OFF_T Temperature Offset

Temperature user accessible offset trim value.

Link to this function

temperature_offset(pid, value)

Link to this function

temperature_target(pid)

T_TGT Temperature target value input in °C.

Link to this function

temperature_target(pid, value)

Link to this function

temperature_threshold_interrupt?(pid)

SRC_TTH Temperature threshold interrupt.

With the window set to a non zero value, the trigger will occur on crossing any of the thresholds: upper, center or lower. If the window is set to 0, it will only trigger on crossing the center threshold.

Link to this function

temperature_window(pid)

T_WND Temperature alarm window value in °C.

Link to this function

time_delay(pid)

TIME_DLY

The time delay register contains the number of ticks of data sample time since the last byte of the FIFO was written. This register starts to increment on FIFO overflow or data wrap and clears when last byte of FIFO is read.

WHO_AM_I Should always respond with 0x0c.