|
F439_CPP_MPL3115A2_Project_01
STM32F439 MPL3115A2 pressure and temperature tutorial
|
MPL3115A2 pressure and temperature sensor driver implementation. More...
#include "mpl31152a.h"Functions | |
| HAL_StatusTypeDef | MPL31152A_Init (I2C_HandleTypeDef *hi2c, uint16_t devAddress) |
| Initialize and configure the MPL3115A2 sensor. | |
| HAL_StatusTypeDef | MPL31152A_getStatus (uint8_t *retVal) |
| Read the MPL3115A2 STATUS register. | |
| HAL_StatusTypeDef | MPL3115A2_ReadTemperature (float *celsius) |
| Read and convert the MPL3115A2 temperature measurement. | |
| HAL_StatusTypeDef | MPL3115A2_ReadPressure (float *pressure_inHg) |
| Read and convert the MPL3115A2 pressure measurement. | |
Variables | |
| static I2C_HandleTypeDef * | i2c |
| HAL I2C handle used for all MPL3115A2 transactions. | |
| static uint16_t | devAddr |
| STM32 HAL-formatted MPL3115A2 I2C address. | |
MPL3115A2 pressure and temperature sensor driver implementation.
The driver is intentionally small for tutorial use. It stores one global I2C handle and device address, initializes the sensor for barometer operation, and exposes blocking read helpers for temperature and pressure.
| HAL_StatusTypeDef MPL31152A_getStatus | ( | uint8_t * | retVal | ) |
Read the MPL3115A2 STATUS register.
| retVal | Pointer that receives the raw STATUS register value. |
| HAL_StatusTypeDef MPL31152A_Init | ( | I2C_HandleTypeDef * | hi2c, |
| uint16_t | devAddress ) |
Initialize and configure the MPL3115A2 sensor.
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 and convert the MPL3115A2 pressure measurement.
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 and convert the MPL3115A2 temperature measurement.
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. |