Subversion Repositories Projects

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2194 - 1
/*
2
bmp085 lib 0x01
3
 
4
copyright (c) Davide Gironi, 2012
5
 
6
Released under GPLv3.
7
Please refer to LICENSE file for licensing information.
8
 
9
References:
10
  - this library is a porting of the bmp085driver 0.4 ardunio library
11
    http://code.google.com/p/bmp085driver/
12
 
13
Notes:
14
  - to compile with avrgcc you may define -lm flag for some math functions
15
*/
16
 
17
 
18
#ifndef BMP085_H_
19
#define BMP085_H_
20
 
21
#include <stdio.h>
22
#include <avr/io.h>
23
 
24
#define BMP085_ADDR (0x77<<1) //0x77 default I2C address
25
 
26
#define BMP085_I2CFLEURYPATH "i2cmaster.h" //define the path to i2c fleury lib
27
#define BMP085_I2CINIT 1 //init i2c
28
 
29
//registers
30
#define BMP085_REGAC1 0xAA
31
#define BMP085_REGAC2 0xAC
32
#define BMP085_REGAC3 0xAE
33
#define BMP085_REGAC4 0xB0
34
#define BMP085_REGAC5 0xB2
35
#define BMP085_REGAC6 0xB4
36
#define BMP085_REGB1 0xB6
37
#define BMP085_REGB2 0xB8
38
#define BMP085_REGMB 0xBA
39
#define BMP085_REGMC 0xBC
40
#define BMP085_REGMD 0xBE
41
#define BMP085_REGCONTROL 0xF4 //control
42
#define BMP085_REGCONTROLOUTPUT 0xF6 //output 0xF6=MSB, 0xF7=LSB, 0xF8=XLSB
43
#define BMP085_REGREADTEMPERATURE 0x2E //read temperature
44
#define BMP085_REGREADPRESSURE 0x34 //read pressure
45
 
46
//modes
47
#define BMP085_MODEULTRALOWPOWER 0 //oversampling=0, internalsamples=1, maxconvtimepressure=4.5ms, avgcurrent=3uA, RMSnoise_hPA=0.06, RMSnoise_m=0.5
48
#define BMP085_MODESTANDARD 1 //oversampling=1, internalsamples=2, maxconvtimepressure=7.5ms, avgcurrent=5uA, RMSnoise_hPA=0.05, RMSnoise_m=0.4
49
#define BMP085_MODEHIGHRES 2 //oversampling=2, internalsamples=4, maxconvtimepressure=13.5ms, avgcurrent=7uA, RMSnoise_hPA=0.04, RMSnoise_m=0.3
50
#define BMP085_MODEULTRAHIGHRES 3 //oversampling=3, internalsamples=8, maxconvtimepressure=25.5ms, avgcurrent=12uA, RMSnoise_hPA=0.03, RMSnoise_m=0.25
51
 
52
//autoupdate temperature enabled
53
#define BMP085_AUTOUPDATETEMP 1 //autoupdate temperature every read
54
 
55
//setup parameters
56
#define BMP085_MODE BMP085_MODEULTRAHIGHRES //define a mode
57
#define BMP085_UNITPAOFFSET 0 //define a unit offset (pa)
58
#define BMP085_UNITMOFFSET 0 //define a unit offset (m)
59
 
60
//avarage filter
61
#define BMP085_FILTERPRESSURE 1 //avarage filter for pressure
62
 
63
//variables
64
int bmp085_regac1, bmp085_regac2, bmp085_regac3, bmp085_regb1, bmp085_regb2, bmp085_regmb, bmp085_regmc, bmp085_regmd;
65
unsigned int bmp085_regac4, bmp085_regac5, bmp085_regac6;
66
long bmp085_rawtemperature, bmp085_rawpressure;
67
 
68
//functions
69
extern void bmp085_init();
70
extern int32_t bmp085_getpressure();
71
extern double bmp085_getaltitude();
72
extern double bmp085_gettemperature();
73
 
74
#endif