Add functions to get/set the oversampling setting.
[freerunner-navigation-board:bmp085.git] / userspace / bmp085.h
1 #include <sys/types.h>
2
3 #ifndef BMP085_H
4 #define BMP085_H
5
6 #define BMP085_I2C_ADDRESS              0x77
7
8 #define BMP085_CALIBRATION_DATA_START   0xAA
9 #define BMP085_CALIBRATION_DATA_LENGTH  22
10
11 #define BMP085_CHIP_ID_REG              0xD0
12 #define BMP085_VERSION_REG              0xD1
13
14 #define BMP085_CHIP_ID                  0x55 /* 85 */
15
16
17 typedef int16_t s16;
18 typedef u_int16_t u16;
19 typedef int32_t s32;
20 typedef u_int8_t u8;
21
22
23 struct bmp085_calibration_data {
24         s16 AC1, AC2, AC3;
25         u16 AC4, AC5, AC6;
26         s16 B1, B2;
27         s16 MB, MC, MD;
28 };
29
30
31 /* Each client has this additional data */
32 struct bmp085_data {
33 #ifdef __KERNEL__
34         struct i2c_client *client;
35 #else
36         int client;
37 #endif
38         unsigned char version;
39         struct bmp085_calibration_data calibration;
40         unsigned long raw_temperature;
41         unsigned long raw_pressure;
42         unsigned char oversampling_setting;
43         unsigned long next_temp_measurement;
44         long b6; // calculated temperature correction coefficient
45 };
46
47 int open_bmp085(int adapter_nr, struct bmp085_data *data);
48 void close_bmp085(struct bmp085_data *data);
49 void set_oversampling(struct bmp085_data *data, unsigned char oversampling);
50 unsigned char get_oversampling(struct bmp085_data *data);
51 s32 get_temperature(struct bmp085_data *data);
52 s32 get_pressure(struct bmp085_data *data);
53
54
55 #endif