2015-08-25 12:45:48 +00:00
|
|
|
/*
|
|
|
|
* bmp180.h
|
|
|
|
*
|
|
|
|
* Created on: 23.08.2015
|
|
|
|
* Author: fbargste
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef DRIVER_BMP180_H_
|
|
|
|
#define DRIVER_BMP180_H_
|
|
|
|
|
|
|
|
#include "stdint.h"
|
|
|
|
#include "stdbool.h"
|
|
|
|
|
|
|
|
#include "FreeRTOS.h"
|
|
|
|
#include "queue.h"
|
|
|
|
|
|
|
|
// Uncomment to enable debug output
|
|
|
|
//#define BMP180_DEBUG
|
|
|
|
|
|
|
|
#define BMP180_TEMPERATURE (1<<0)
|
|
|
|
#define BMP180_PRESSURE (1<<1)
|
|
|
|
|
2016-10-24 13:09:17 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2015-08-25 12:45:48 +00:00
|
|
|
//
|
|
|
|
// Create bmp180_types
|
|
|
|
//
|
|
|
|
|
|
|
|
// temperature in °C
|
|
|
|
typedef float bmp180_temp_t;
|
|
|
|
// pressure in mPa (To get hPa divide by 100)
|
|
|
|
typedef uint32_t bmp180_press_t;
|
|
|
|
|
|
|
|
// BMP180_Event_Result
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
uint8_t cmd;
|
2015-09-18 07:59:47 +00:00
|
|
|
bmp180_temp_t temperature;
|
2015-08-25 12:45:48 +00:00
|
|
|
bmp180_press_t pressure;
|
|
|
|
} bmp180_result_t;
|
|
|
|
|
|
|
|
// Init bmp180 driver ...
|
|
|
|
bool bmp180_init(uint8_t scl, uint8_t sda);
|
|
|
|
|
|
|
|
// Trigger a "complete" measurement (temperature and pressure will be valid when given to "bmp180_informUser)
|
2016-11-05 10:04:03 +00:00
|
|
|
void bmp180_trigger_measurement(const QueueHandle_t* resultQueue);
|
2015-08-25 12:45:48 +00:00
|
|
|
|
|
|
|
// Trigger a "temperature only" measurement (only temperature will be valid when given to "bmp180_informUser)
|
2016-11-05 10:04:03 +00:00
|
|
|
void bmp180_trigger_temperature_measurement(const QueueHandle_t* resultQueue);
|
2015-08-25 12:45:48 +00:00
|
|
|
|
|
|
|
// Trigger a "pressure only" measurement (only pressure will be valid when given to "bmp180_informUser)
|
2016-11-05 10:04:03 +00:00
|
|
|
void bmp180_trigger_pressure_measurement(const QueueHandle_t* resultQueue);
|
2015-08-25 12:45:48 +00:00
|
|
|
|
|
|
|
// Give the user the chance to create it's own handler
|
2016-11-05 10:04:03 +00:00
|
|
|
extern bool (*bmp180_informUser)(const QueueHandle_t* resultQueue, uint8_t cmd, bmp180_temp_t temperature, bmp180_press_t pressure);
|
2015-08-25 12:45:48 +00:00
|
|
|
|
2016-07-18 14:43:16 +00:00
|
|
|
// Calibration constants
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int16_t AC1;
|
|
|
|
int16_t AC2;
|
|
|
|
int16_t AC3;
|
|
|
|
uint16_t AC4;
|
|
|
|
uint16_t AC5;
|
|
|
|
uint16_t AC6;
|
|
|
|
|
|
|
|
int16_t B1;
|
|
|
|
int16_t B2;
|
|
|
|
|
|
|
|
int16_t MB;
|
|
|
|
int16_t MC;
|
|
|
|
int16_t MD;
|
|
|
|
} bmp180_constants_t;
|
|
|
|
|
|
|
|
// Returns true if the bmp180 is detected.
|
|
|
|
bool bmp180_is_available();
|
|
|
|
// Reads all the internal constants, returning true on success.
|
|
|
|
bool bmp180_fillInternalConstants(bmp180_constants_t *c);
|
|
|
|
// Reads an optional temperature and pressure. The over sampling
|
|
|
|
// setting, oss, may be 0 to 3. Returns true on success.
|
|
|
|
bool bmp180_measure(bmp180_constants_t *c, int32_t *temperature,
|
|
|
|
uint32_t *pressure, uint8_t oss);
|
|
|
|
|
2016-10-24 13:09:17 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-08-25 12:45:48 +00:00
|
|
|
#endif /* DRIVER_BMP180_H_ */
|