29 #ifndef __MPL3115A2_H__
30 #define __MPL3115A2_H__
40 #define MPL3115A2_ADDRESS 0x60 // 7-bit I2C address for sensor
43 #define OUT_P_MSB 0x01 //Altitude data
44 #define OUT_P_CSB 0x02
45 #define OUT_P_LSB 0x03
46 #define OUT_T_MSB 0x04
47 #define OUT_T_LSB 0x05
48 #define DR_STATUS 0x06
49 #define OUT_P_DELTA_MSB 0x07
50 #define OUT_P_DELTA_CSB 0x08
51 #define OUT_P_DELTA_LSB 0x09
52 #define OUT_T_DELTA_MSB 0x0A
53 #define OUT_T_DELTA_LSB 0x0B
60 #define INT_SOURCE 0x12
61 #define PT_DATA_CFG 0x13
62 #define BAR_IN_MSB 0x14
63 #define BAR_IN_LSB 0x15
64 #define P_TGT_MSB 0x16
65 #define P_TGT_LSB 0x17
67 #define P_WND_MSB 0x19
68 #define P_WND_LSB 0x1A
70 #define P_MIN_MSB 0x1C
71 #define P_MIN_CSB 0x1D
72 #define P_MIN_LSB 0x1E
73 #define T_MIN_MSB 0x1F
74 #define T_MIN_LSB 0x20
75 #define P_MAX_MSB 0x21
76 #define P_MAX_CSB 0x22
77 #define P_MAX_LSB 0x23
78 #define T_MAX_MSB 0x24
79 #define T_MAX_LSB 0x25
80 #define CTRL_REG1 0x26
81 #define CTRL_REG2 0x27
82 #define CTRL_REG3 0x28
83 #define CTRL_REG4 0x29
84 #define CTRL_REG5 0x2A
91 #define POW 0x40 //Pressure overwrite
93 #define PTDR 0x08 //Pressure/Altitude OR Temperature data ready
94 #define PDR 0x04 //Pressure/Altitude new data available
95 #define TDR 0x02 //Temperature new Data Available.
106 #define SBYB 0x01 //Active mode
109 #define OS_1 0x00 // 6 ms min between samples
110 #define OS_2 OS0 // 10 ms
111 #define OS_4 OS1 // 18 ms
112 #define OS_8 OS1 | OS0 // 34 ms
113 #define OS_16 OS2 // 66 ms
114 #define OS_32 OS2 | OS0 // 130 ms
115 #define OS_64 OS2 | OS1 // 258 ms
116 #define OS_128 OS2 | OS1 | OS0 // 512 ms
118 #define BAR_MASK 0x80
119 #define ALT_MASK 0xEF
120 #define ACTIVE_MASK 0xF1
121 #define STANDBY_MASK 0xFE
124 #define ALARM_SEL 0x20
125 #define LOAD_OUTPUT 0x10
130 #define CLEAR_ST 0xF0
133 #define IPOL1 0x10 //Set to 1 for Active HIGH on INT1
134 #define PP_OD1 0x08 //Set to 0 for internal pull up
135 #define IPOL2 0x02 //1 Active high, 0 Active Low Interrupt on Pad2
136 #define PP_OD2 0x01 //Set to 0 for internal pull up
139 #define INT_EN_DRDY 0x80 //Set to 1: Data Ready interrupt enabled
140 #define INT_EN_FIFO 0x40 //Set to 1: FIFO interrupt enabled
141 #define INT_EN_PW 0x20 //Set to 1: Pressure window interrupt enabled
142 #define INT_EN_TW 0x10 //Set to 1: Temperature window interrupt enabled
143 #define INT_EN_PTH 0x08 //Set to 1: Pressure Threshold interrupt enabled
144 #define INT_EN_TTH 0x04 //Set to 1: Temperature Threshold interrupt enabled
145 #define INT_EN_PCHG 0x02 //Set to 1: Pressure Change interrupt enabled.
146 #define INT_EN_TCHG 0x01 //Set to 1: Temperature Change interrupt enabled
147 #define INT_EN_CLEAR 0x00
151 #define INT_CFG_DRDY 0x80 //1: Interrupt is routed to INT1
152 #define INT_CFG_FIFO 0x40
153 #define INT_CFG_PW 0x20
154 #define INT_CFG_TW 0x10
155 #define INT_CFG_PTH 0x08
156 #define INT_CFG_TTH 0x04
157 #define INT_CFG_PCHG 0x02
158 #define INT_CFG_TCHG 0x01
160 #define INT_CFG_CLEAR 0x00
166 #define DISABLED 0x00
167 #define CIRCULAR 0x40
168 #define FULL_STOP 0x80
169 #define F_MODE DISABLED
171 #define DREM 0x04 // Data Ready Event Mode
172 #define PDEFE 0x02 // Pressure Data Event Flag Enabled
173 #define TDEFE 0x01 // Temperature Data Event Flag Enabled
177 #define SRC_DRDY 0x80
178 #define SRC_FIFO 0x40
183 #define SRC_PCHG 0x02
184 #define SRC_TCHG 0x01
float MPL3115A2_ReadPressure(unitsType units)
Get a barometric pressure reading.
void MPL3115A2_SetPressureAlarmThreshold(unsigned int thresh)
Configure alarm threshold.
unsigned char buffer[256]
unsigned char MPL3115A2_ID(void)
Returns the Factory Chip ID.
void MPL3115A2_SetTempTargetWindow(unsigned int target, unsigned int window)
Configures the temperature target and window for the interrupts.
float MPL3115A2_ReadTemperature(void)
Get a temperature reading from the sensor.
float MPL3115A2_ReadAltitude(void)
Returns the number of meters above sea level,Returns -1 if no new data is available.
void MPL3115A2_BarometerMode(void)
Configure the sensor in Barometer mode.
void MPL3115A2_ConfigurePressureInterrupt(void)
Configure Pressure Interrupt.
void MPL3115A2_WriteByte(char reg, char value)
Write a single byte to the register.
void MPL3115A2_ReadByteArray(char reg, char *buffer, unsigned int length)
Read byte value from register.
void MPL3115A2_ClearInterrupts(void)
Clear any existing interrupts.
void MPL3115A2_ToggleOneShot(void)
Causes the sensor to immediately take another reading , needed to sample faster than 1Hz...
void MPL3115A2_SetPressureOffset(unsigned char P_Offset)
Set the pressure offset correction.
void MPL3115A2_SetAcquisitionTimeStep(unsigned char)
Set the acquisition time step in seconds.
float MPL3115A2_GetMinimumPressure(void)
Get minimum stored pressure.
float MPL3115A2_GetMinimumTemperature(void)
Get minimum recorded temperature reading.
unsigned char MPL3115A2_GetMode(void)
Return a bool value indicating wheather the sensor is in Active or Standby mode.
float MPL3115A2_ReadBarometricPressure(void)
Reads the current pressure in Pa.
void MPL3115A2_SetTempOffset(char T_Offset)
Used to correct the measured sensor temeperature by a particular offset.
void MPL3115A2_ConfigureInterruptPin(unsigned char intrrpt, unsigned char pin)
Configure Interrupt pins.
void MPL3115A2_Initialize(void)
Initialize the sensor and enable interrupts.
void MPL3115A2_SetTemperatureThreshold(unsigned char thresh)
Configure the temeperature threshold.
void MPL3115A2_EnableEventFlags(void)
Enables the pressure and temp measurement event flags so that we can test against them...
void MPL3115A2_AltimeterMode(void)
Sets the mode to Altimeter.
void MPL3115A2_WriteByteArray(char reg, char *buffer, unsigned int length)
Writes an array of bytes to the sensor.
unsigned char MPL3115A2_ReadByte(char reg)
Read byte value from register.
void MPL3115A2_SetAltimeterOffset(unsigned char H_Offset)
Set the altimeter offset correction.
float MPL3115A2_GetMaximumTemperature(void)
Get maximum recorded temperature reading.
void MPL3115A2_ActiveMode(void)
Puts the sensor in active mode, needed is the sensor is in standby mode.
void MPL3115A2_StandbyMode(void)
Puts the sensor in standby mode, the user must do this in order to modify the major control registers...
void MPL3115A2_SetPressureTargetWindow(unsigned int target, unsigned int window)
Configure alarm target and window.
void MPL3115A2_OutputSampleRate(unsigned char)
Configures the output sample rate.The higher the oversample rate the greater the time between data sa...
unsigned int MPL3115A2_ReadBarometicPressureInput(void)
Returns barometric pressure input used for calculating altitude.
float MPL3115A2_GetMaximumPressure(void)
Get maximum stored pressure.
void MPL3115A2_ConfigureAltitudeInterrupt(void)
Configure altitude interrupt pin.