Contiki-Inga 3.x
Macros | Functions
MPL115A Pressure Sensor (Barometer)

Macros

#define MPL115A_CS   4
 
#define MPL115A_PRESSURE_OUT_MSB   0x80 | (0x00 << 1)
 
#define MPL115A_PRESSURE_OUT_LSB   0x80 | (0x01 << 1)
 
#define MPL115A_TEMP_OUT_MSB   0x80 | (0x02 << 1)
 
#define MPL115A_TEMP_OUT_LSB   0x80 | (0x03 << 1)
 
#define MPL115A_COEFF_ADDR_A0_M   0x80 | (0x04 << 1)
 
#define MPL115A_COEFF_ADDR_A0_L   0x80 | (0x05 << 1)
 
#define MPL115A_COEFF_ADDR_B1_M   0x80 | (0x06 << 1)
 
#define MPL115A_COEFF_ADDR_B1_L   0x80 | (0x07 << 1)
 
#define MPL115A_COEFF_ADDR_B2_M   0x80 | (0x08 << 1)
 
#define MPL115A_COEFF_ADDR_B2_L   0x80 | (0x09 << 1)
 
#define MPL115A_COEFF_ADDR_C12_M   0x80 | (0x0A << 1)
 
#define MPL115A_COEFF_ADDR_C12_L   0x80 | (0x0B << 1)
 
#define MPL115A_COEFF_ADDR_C11_M   0x80 | (0x0C << 1)
 
#define MPL115A_COEFF_ADDR_C11_L   0x80 | (0x0D << 1)
 
#define MPL115A_COEFF_ADDR_C22_M   0x80 | (0x0E << 1)
 
#define MPL115A_COEFF_ADDR_C22_L   0x80 | (0x0F << 1)
 
#define MPL115A_START_P_CONV   (0x10 << 1)
 
#define MPL115A_START_T_CONV   (0x11 << 1)
 
#define MPL115A_START_B_CONV   (0x12 << 1)
 

Functions

void mpl115a_init (void)
 Initialize the MPL115A Pressure Sensor. More...
 
uint16_t mpl115a_get_pressure (void)
 Get raw pressure value (10Bit) More...
 
uint16_t mpl115a_get_temp (void)
 Get raw temperature value (10Bit) More...
 
uint8_t mpl115a_cmd (uint8_t reg)
 This function reads and writes from the given register of the MPL115A. More...
 

Detailed Description

A pressure sensor sounds a little bit strange in conjunction with a health care sensor node, but it exists an interesting task. With the help of the differential pressure value, it is possible to recognize an up and down movement of a test person. Therefore the Freescale MPL115A (SPI) was integrated onto the sensor node. This pressure sensor has a very small design size and furthermore an independent temperature sensor. In Combination with the temperature value and a few coefficients, the raw pressure value can be compensated to get the exact result. The coefficients are stored in the internal ROM of the MPL115A and can be read out via SPI. The compensation can be done by the MCU (this option is implemented), or by an external application (e.g. server application)

Note
The pressure compensation costs about 6 32Bit multiplications

Macro Definition Documentation

#define MPL115A_COEFF_ADDR_A0_L   0x80 | (0x05 << 1)

Pressure compensate coefficient A0 (low byte)

Definition at line 187 of file mpl115a.h.

#define MPL115A_COEFF_ADDR_A0_M   0x80 | (0x04 << 1)

Pressure compensate coefficient A0 (high byte)

Definition at line 183 of file mpl115a.h.

#define MPL115A_COEFF_ADDR_B1_L   0x80 | (0x07 << 1)

Pressure compensate coefficient B1 (low byte)

Definition at line 196 of file mpl115a.h.

#define MPL115A_COEFF_ADDR_B1_M   0x80 | (0x06 << 1)

Pressure compensate coefficient B1 (high byte)

Definition at line 192 of file mpl115a.h.

#define MPL115A_COEFF_ADDR_B2_L   0x80 | (0x09 << 1)

Pressure compensate coefficient B2 (low byte)

Definition at line 205 of file mpl115a.h.

#define MPL115A_COEFF_ADDR_B2_M   0x80 | (0x08 << 1)

Pressure compensate coefficient B2 (high byte)

Definition at line 201 of file mpl115a.h.

#define MPL115A_COEFF_ADDR_C11_L   0x80 | (0x0D << 1)

Pressure compensate coefficient C11 (low byte)

Definition at line 223 of file mpl115a.h.

#define MPL115A_COEFF_ADDR_C11_M   0x80 | (0x0C << 1)

Pressure compensate coefficient C11 (high byte)

Definition at line 219 of file mpl115a.h.

#define MPL115A_COEFF_ADDR_C12_L   0x80 | (0x0B << 1)

Pressure compensate coefficient C12 (low byte)

Definition at line 214 of file mpl115a.h.

#define MPL115A_COEFF_ADDR_C12_M   0x80 | (0x0A << 1)

Pressure compensate coefficient C12 (high byte)

Definition at line 210 of file mpl115a.h.

#define MPL115A_COEFF_ADDR_C22_L   0x80 | (0x0F << 1)

Pressure compensate coefficient C22 (low byte)

Definition at line 232 of file mpl115a.h.

#define MPL115A_COEFF_ADDR_C22_M   0x80 | (0x0E << 1)

Pressure compensate coefficient C22 (high byte)

Definition at line 228 of file mpl115a.h.

#define MPL115A_CS   4

SPI device order. The chip select number where the pressure sensor mpl115a is connected to the BCD-decimal decoder

Definition at line 72 of file mpl115a.h.

Referenced by mpl115a_cmd(), and mpl115a_init().

#define MPL115A_PRESSURE_OUT_LSB   0x80 | (0x01 << 1)

Pressure value low byte

D7 D6 D5 D4 D3 D2 D1 D0
Bit1 Bit0 x x x x x x

Definition at line 125 of file mpl115a.h.

Referenced by mpl115a_get_pressure().

#define MPL115A_PRESSURE_OUT_MSB   0x80 | (0x00 << 1)

Pressure value high byte

D7 D6 D5 D4 D3 D2 D1 D0
Bit9 Bit8 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2

Definition at line 99 of file mpl115a.h.

Referenced by mpl115a_get_pressure().

#define MPL115A_START_B_CONV   (0x12 << 1)

Start both, pressure and temperature measurement command

Definition at line 246 of file mpl115a.h.

#define MPL115A_START_P_CONV   (0x10 << 1)

Start pressure measurement command

Definition at line 237 of file mpl115a.h.

Referenced by mpl115a_get_pressure().

#define MPL115A_START_T_CONV   (0x11 << 1)

Start temperature measurement command

Definition at line 241 of file mpl115a.h.

Referenced by mpl115a_get_temp().

#define MPL115A_TEMP_OUT_LSB   0x80 | (0x03 << 1)

Temperature value low byte

D7 D6 D5 D4 D3 D2 D1 D0
Bit1 Bit0 x x x x x x

Definition at line 178 of file mpl115a.h.

Referenced by mpl115a_get_temp().

#define MPL115A_TEMP_OUT_MSB   0x80 | (0x02 << 1)

Temperature value high byte

D7 D6 D5 D4 D3 D2 D1 D0
Bit9 Bit8 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2

Definition at line 152 of file mpl115a.h.

Referenced by mpl115a_get_temp().

Function Documentation

uint8_t mpl115a_cmd ( uint8_t  reg)

This function reads and writes from the given register of the MPL115A.

Parameters
regThe register address
Returns
The data value

Definition at line 187 of file mpl115a.c.

References MPL115A_CS, mspi_chip_release(), mspi_chip_select(), and mspi_transceive().

Referenced by mpl115a_get_pressure(), and mpl115a_get_temp().

uint16_t mpl115a_get_pressure ( void  )

Get raw pressure value (10Bit)

Returns
Pressure value
Note
The overall pressure measurement takes approximately 3ms

Definition at line 52 of file mpl115a.c.

References mpl115a_cmd(), MPL115A_PRESSURE_OUT_LSB, MPL115A_PRESSURE_OUT_MSB, and MPL115A_START_P_CONV.

uint16_t mpl115a_get_temp ( void  )

Get raw temperature value (10Bit)

Returns
Temperature value
Note
The overall temperature measurement takes approximately 3ms

Definition at line 68 of file mpl115a.c.

References mpl115a_cmd(), MPL115A_START_T_CONV, MPL115A_TEMP_OUT_LSB, and MPL115A_TEMP_OUT_MSB.

void mpl115a_init ( void  )

Initialize the MPL115A Pressure Sensor.

Definition at line 45 of file mpl115a.c.

References MPL115A_CS, MSPI_BAUD_MAX, mspi_chip_release(), mspi_init(), and MSPI_MODE_0.