Vala bindings and examples added. Minor clean-up in header file
[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         int client;
34         unsigned char version;
35         struct bmp085_calibration_data calibration;
36         unsigned long raw_temperature;
37         unsigned long raw_pressure;
38         unsigned char oversampling_setting;
39         unsigned long next_temp_measurement;
40         long b6; // calculated temperature correction coefficient
41 };
42
43 int open_bmp085(int adapter_nr, struct bmp085_data *data);
44 void close_bmp085(struct bmp085_data *data);
45 void set_oversampling(struct bmp085_data *data, unsigned char oversampling);
46 unsigned char get_oversampling(struct bmp085_data *data);
47 s32 get_temperature(struct bmp085_data *data);
48 s32 get_pressure(struct bmp085_data *data);
49
50
51 #endif