Bmp280 Driver TivaC
Driver for weather sensor BMP280 for TivaC MCU
Macros | Enumerations | Functions
BMP280_Drv.c File Reference

Driver files, contain the top layer of the BMP280 API, contains ideally no I2C or SPI specific stuffs. More...

#include "include/BMP280_Drv.h"
#include <assert.h>
#include "external/TivaC_Utils/include/TivaC_Other_Utils.h"
#include "external/TivaC_Utils/include/bit_manipulation.h"
#include "include/BMP280_Utils.h"
#include "include/TivaC_I2C.h"
#include "include/TivaC_SPI.h"
Include dependency graph for BMP280_Drv.c:

Macros

#define BMP280_BASEADDR   0xF3
 
#define RAW_TEM_TOTAL_BYTE   3
 
#define RAW_PRESS_TOTAL_BYTE   3
 
#define BMP280_CALIB_START_ADDR   0x88
 
#define BMP280_RESADDR   0xE0
 
#define BMP280_IDARR   0xD0
 
#define BMP280_MEASURING_MASK   0x8
 
#define BMP280_UPDATING_MASK   0x1
 

Enumerations

enum  bmp280_regName {
  Status = 0, Ctrl_meas, Config, Press_msb = 4,
  Press_lsb, Press_xlsb, Temp_msb, Temp_lsb,
  Temp_xlsb
}
 

Functions

Bmp280ErrCode bmp280_create_predefined_settings (bmp280 *sensor, const Bmp280MeasureSettings settings)
 initialize the bmp280 with predefined value in the datasheet More...
 
Bmp280ErrCode bmp280_create_custom_setting (bmp280 *sensor, const Bmp280Coeff tempSamp, const Bmp280Coeff presSamp, const Bmp280Coeff iirFilter, const Bmp280SamplSettings samplSet, const Bmp280OperMode mode, const float standbyTime)
 initialize the bmp280 struct with options from user More...
 
Bmp280ErrCode bmp280_init (bmp280 *sensor, const Bmp280ComProtocol protocol, const uint8_t address)
 check settings, set the bmp280 address and desired communication protocols
 
Bmp280ErrCode bmp280_open (bmp280 *sensor)
 prepare the i2c/spi port for communications
 
Bmp280ErrCode bmp280_close (bmp280 *sensor)
 close the ports
 
Bmp280ErrCode bmp280_get_id (bmp280 *sensor, uint8_t *returnID)
 get bmp280 sensor ID, should 0x58 or 88 in decimal
 
Bmp280ErrCode bmp280_reset (bmp280 *sensor)
 perform power reset on the bmp280 There is a 5ms seconds delay to allow the bmp280 to properly wake up
 
Bmp280ErrCode bmp280_update_setting (bmp280 *sensor)
 used to write setting sin the bmp280 struct to the control and config register of the bmp280
 
Bmp280ErrCode bmp280_get_ctr_meas (bmp280 *sensor, uint8_t *ctrlMeasReturn)
 read data from control register
 
Bmp280ErrCode bmp280_get_config (bmp280 *sensor, uint8_t *configReturn)
 read data from config register
 
Bmp280ErrCode bmp280_get_status (bmp280 *sensor)
 read bmp280 status and change last known status of the sensor
 
Bmp280ErrCode bmp280_get_temp_press (bmp280 *sensor, float *temperatureC, float *pressPa, Bmp280CalibParam calibParam)
 used to read compensated temperature and pressure More...
 
Bmp280ErrCode bmp280_get_calibration_data (bmp280 *sensor, Bmp280CalibParam *calibParam)
 used to read factory calibration data from the bmp280
 

Detailed Description

Driver files, contain the top layer of the BMP280 API, contains ideally no I2C or SPI specific stuffs.

Author
Khoi Trinh
Date
2018-08-25

Function Documentation

Bmp280ErrCode bmp280_create_custom_setting ( bmp280 *  sensor,
const Bmp280Coeff  tempSamp,
const Bmp280Coeff  presSamp,
const Bmp280Coeff  iirFilter,
const Bmp280SamplSettings  samplSet,
const Bmp280OperMode  mode,
const float  standbyTime 
)

initialize the bmp280 struct with options from user

Returns
no error or user settings violated some rules
Bmp280ErrCode bmp280_create_predefined_settings ( bmp280 *  sensor,
const Bmp280MeasureSettings  settings 
)

initialize the bmp280 with predefined value in the datasheet

Returns
no error or user settings violated some rules
Bmp280ErrCode bmp280_get_temp_press ( bmp280 *  sensor,
float *  temperatureC,
float *  pressPa,
Bmp280CalibParam  calibParam 
)

used to read compensated temperature and pressure

Parameters
temperatureCreturn temperature
pressPareturn pressure
calibParamcalibration data obtained beforehand