Contiki 2.5
Files | Macros | Functions | Variables
Pressure Sensor (Barometer) MPL115A

Files

file  pressure-mpl115a.c
 
    MPL115A Pressure Sensor (Barometer) interface implementation

 
file  pressure-mpl115a.h
 
    MPL115A Pressure Sensor (Barometer) interface definitions

 

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...
 

Variables

int16_t coeff_t::value
 
uint8_t coeff_t::addr [2]
 

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 180 of file pressure-mpl115a.h.

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

Pressure compensate coefficient A0 (high byte)

Definition at line 176 of file pressure-mpl115a.h.

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

Pressure compensate coefficient B1 (low byte)

Definition at line 189 of file pressure-mpl115a.h.

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

Pressure compensate coefficient B1 (high byte)

Definition at line 185 of file pressure-mpl115a.h.

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

Pressure compensate coefficient B2 (low byte)

Definition at line 198 of file pressure-mpl115a.h.

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

Pressure compensate coefficient B2 (high byte)

Definition at line 194 of file pressure-mpl115a.h.

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

Pressure compensate coefficient C11 (low byte)

Definition at line 216 of file pressure-mpl115a.h.

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

Pressure compensate coefficient C11 (high byte)

Definition at line 212 of file pressure-mpl115a.h.

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

Pressure compensate coefficient C12 (low byte)

Definition at line 207 of file pressure-mpl115a.h.

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

Pressure compensate coefficient C12 (high byte)

Definition at line 203 of file pressure-mpl115a.h.

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

Pressure compensate coefficient C22 (low byte)

Definition at line 225 of file pressure-mpl115a.h.

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

Pressure compensate coefficient C22 (high byte)

Definition at line 221 of file pressure-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 65 of file pressure-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 118 of file pressure-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 92 of file pressure-mpl115a.h.

Referenced by mpl115a_get_pressure().

#define MPL115A_START_B_CONV   (0x12 << 1)

Start both, pressure and temperature measurement command

Definition at line 239 of file pressure-mpl115a.h.

#define MPL115A_START_P_CONV   (0x10 << 1)

Start pressure measurement command

Definition at line 230 of file pressure-mpl115a.h.

Referenced by mpl115a_get_pressure().

#define MPL115A_START_T_CONV   (0x11 << 1)

Start temperature measurement command

Definition at line 234 of file pressure-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 171 of file pressure-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 145 of file pressure-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 179 of file pressure-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 48 of file pressure-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 63 of file pressure-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 42 of file pressure-mpl115a.c.

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

Variable Documentation

uint8_t coeff_t::addr[2]

coefficient addresses

Definition at line 258 of file pressure-mpl115a.h.

int16_t coeff_t::value

Pressure compensate coefficient value

Definition at line 254 of file pressure-mpl115a.h.