|
F439_CPP_MPL3115A2_Project_01
STM32F439 MPL3115A2 pressure and temperature tutorial
|
Public interface for the MPL3115A2 pressure and temperature sensor driver. More...
#include <main.h>Go to the source code of this file.
Macros | |
| #define | MPL3115A2_ADDRESS (0x60 << 1) |
| Default 7-bit MPL3115A2 I2C address shifted for STM32 HAL use. | |
Enumerations | |
MPL3115A2 output and configuration registers | |
| enum | { MPL3115A2_REGISTER_STATUS = (0x00) , MPL3115A2_REGISTER_PRESSURE_MSB = (0x01) , MPL3115A2_REGISTER_PRESSURE_CSB = (0x02) , MPL3115A2_REGISTER_PRESSURE_LSB = (0x03) , MPL3115A2_REGISTER_TEMP_MSB = (0x04) , MPL3115A2_REGISTER_TEMP_LSB = (0x05) , MPL3115A2_WHOAMI = (0x0C) } |
MPL3115A2 status register bits | |
| enum | { MPL3115A2_REGISTER_STATUS_TDR = 0x02 , MPL3115A2_REGISTER_STATUS_PTDR = 0x08 } |
MPL3115A2 PT_DATA_CFG register values | |
| enum | { MPL3115A2_PT_DATA_CFG = 0x13 , MPL3115A2_PT_DATA_CFG_TDEFE = 0x01 , MPL3115A2_PT_DATA_CFG_PDEFE = 0x02 , MPL3115A2_PT_DATA_CFG_DREM = 0x04 } |
MPL3115A2 control registers | |
| enum | { MPL3115A2_CTRL_REG1 = (0x26) } |
MPL3115A2 CTRL_REG1 bit masks | |
| enum | { MPL3115A2_CTRL_REG1_SBYB = 0x01 } |
MPL3115A2 oversampling values for CTRL_REG1 | |
| enum | { MPL3115A2_CTRL_REG1_OS128 = 0x38 } |
Functions | |
| HAL_StatusTypeDef | MPL31152A_Init (I2C_HandleTypeDef *hi2c, uint16_t devAddr) |
| Initialize the MPL3115A2 sensor for barometer and temperature reads. | |
| HAL_StatusTypeDef | MPL31152A_getStatus (uint8_t *data) |
| Read the MPL3115A2 STATUS register. | |
| HAL_StatusTypeDef | MPL3115A2_ReadPressure (float *pressure_inHg) |
| Read pressure from the MPL3115A2. | |
| HAL_StatusTypeDef | MPL3115A2_ReadTemperature (float *celsius) |
| Read temperature from the MPL3115A2. | |
Public interface for the MPL3115A2 pressure and temperature sensor driver.
This driver uses STM32 HAL I2C calls to initialize the MPL3115A2 sensor, read the sensor status register, and return pressure and temperature measurements in application-friendly floating-point units.
| anonymous enum |
| anonymous enum |
| HAL_StatusTypeDef MPL31152A_getStatus | ( | uint8_t * | retVal | ) |
Read the MPL3115A2 STATUS register.
| data | Pointer that receives the raw status register value. |
| retVal | Pointer that receives the raw STATUS register value. |
| HAL_StatusTypeDef MPL31152A_Init | ( | I2C_HandleTypeDef * | hi2c, |
| uint16_t | devAddress ) |
Initialize the MPL3115A2 sensor for barometer and temperature reads.
The function stores the HAL I2C handle for later driver calls, waits until the sensor responds on the I2C bus, validates the WHO_AM_I value, enables data-ready event flags, and activates the sensor with OSR=128.
| hi2c | Pointer to the STM32 HAL I2C handle used by the sensor. |
| devAddr | STM32 HAL-formatted I2C device address. |
Initialize the MPL3115A2 sensor for barometer and temperature reads.
Stores the I2C handle and device address, waits for the sensor to answer, verifies WHO_AM_I, enables pressure and temperature data-ready flags, and places the device into active barometer mode with OSR=128.
| hi2c | Pointer to the STM32 HAL I2C handle connected to the sensor. |
| devAddress | STM32 HAL-formatted I2C device address. |
| HAL_StatusTypeDef MPL3115A2_ReadPressure | ( | float * | pressure_inHg | ) |
Read pressure from the MPL3115A2.
| pressure_inHg | Pointer that receives pressure in inches of mercury. |
Read pressure from the MPL3115A2.
Reads the three pressure output registers, converts the Q18.2 pressure value from pascals, and returns the result in inches of mercury.
| pressure_inHg | Pointer that receives the converted pressure in inHg. |
| HAL_StatusTypeDef MPL3115A2_ReadTemperature | ( | float * | celsius | ) |
Read temperature from the MPL3115A2.
| celsius | Pointer that receives temperature in degrees Celsius. |
Read temperature from the MPL3115A2.
Reads the two temperature output registers and converts the signed 12-bit fixed-point value into degrees Celsius.
| celsius | Pointer that receives the converted temperature in degrees Celsius. |