Contiki-NG
bmpx8x.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015, Zolertia - http://www.zolertia.com
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * 3. Neither the name of the Institute nor the names of its contributors
14  * may be used to endorse or promote products derived from this software
15  * without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  * This file is part of the Contiki operating system.
30  *
31  */
32 /*---------------------------------------------------------------------------*/
33 /**
34  * \addtogroup zoul-sensors
35  * @{
36  *
37  * \defgroup zoul-bmpx8x-sensor BMP085/BMP180 Sensor
38  *
39  * Driver for the BMP085/BMP180 sensor
40  *
41  * BMP085/BMP180 digital atmospheric pressure and temperature driver
42  * @{
43  *
44  * \file
45  * Header file for the external BMP085/BMP180 Sensor Driver
46  *
47  * \author
48  * Antonio Lignan <alinan@zolertia.com>
49  */
50 /*---------------------------------------------------------------------------*/
51 #ifndef BMPX8X_H_
52 #define BMPX8X_H_
53 #include <stdio.h>
54 #include "lib/sensors.h"
55 #include "dev/zoul-sensors.h"
56 #include "i2c.h"
57 /* -------------------------------------------------------------------------- */
58 /**
59  * \name BMPx8x address and registers
60  * @{
61  */
62 /* -------------------------------------------------------------------------- */
63 #define BMPx8x_ADDR 0x77
64 /* -------------------------------------------------------------------------- */
65 /* Control register */
66 #define BMPx8x_CTRL_REG 0xF4
67 /* Read uncompensated temperature */
68 #define BMPx8x_CTRL_REG_TEMP 0x2E
69 /* Read uncompensated pressure, no oversampling */
70 #define BMPx8x_CTRL_REG_PRESS_4_5MS 0x34
71 /* Read uncompensated pressure, oversampling 1*/
72 #define BMPx8x_CTRL_REG_PRESS_7_5MS 0x74
73 /* Read uncompensated pressure, oversampling 2 */
74 #define BMPx8x_CTRL_REG_PRESS_13_5MS 0xB4
75 /* Read uncompensated pressure, oversampling 3 */
76 #define BMPx8x_CTRL_REG_PRESS_25_5MS 0xF4
77 /* -------------------------------------------------------------------------- */
78 #define BMPx8x_DATA_MSB 0xF6
79 #define BMPx8x_DATA_LSB 0xF7
80 /* 19-bit resolution */
81 #define BMPx8x_DATA_XLSB 0xF8
82 /* -------------------------------------------------------------------------- */
83 /* Calibration registers, 16-bit wide */
84 #define BMPx8x_AC1_CALIB 0xAA
85 #define BMPx8x_AC2_CALIB 0xAC
86 #define BMPx8x_AC3_CALIB 0xAE
87 #define BMPx8x_AC4_CALIB 0xB0
88 #define BMPx8x_AC5_CALIB 0xB2
89 #define BMPx8x_AC6_CALIB 0xB4
90 #define BMPx8x_B1_CALIB 0xB6
91 #define BMPx8x_B2_CALIB 0xB8
92 #define BMPx8x_MB_CALIB 0xBA
93 #define BMPx8x_MC_CALIB 0xBC
94 #define BMPx8x_MD_CALIB 0xBE
95 #define BMPx8x_CALIB_TABLE_SIZE 22 /**< size in bytes */
96 /** @} */
97 /* -------------------------------------------------------------------------- */
98 /**
99  * \name BMPx8x operation modes
100  * @{
101  */
102 #define BMPx8x_MODE_ULTRA_LOW_POWER 0x00
103 #define BMPx8x_MODE_STANDARD 0x01
104 #define BMPx8x_MODE_HIGH_RES 0x02
105 #define BMPx8x_MODE_ULTRA_HIGH_RES 0x03
106 /* -------------------------------------------------------------------------- */
107 #define BMPx8x_DELAY_4_5MS 4700
108 #define BMPx8x_DELAY_7_5MS 7700
109 #define BMPx8x_DELAY_13_5MS 13700
110 #define BMPx8x_DELAY_25_5MS 25700
111 /** @} */
112 /* -------------------------------------------------------------------------- */
113 /**
114  * \name BMPx8x return and command values
115  * @{
116  */
117 #define BMPx8x_SUCCESS 0x00
118 #define BMPx8x_ERROR -1
119 
120 #define BMPx8x_ACTIVE SENSORS_ACTIVE
121 #define BMPx8x_OVERSAMPLING 0x00
122 #define BMPx8x_READ_PRESSURE 0x01
123 #define BMPx8x_READ_TEMP 0x02
124 /** @} */
125 /* -------------------------------------------------------------------------- */
126 #define BMPx8x_SENSOR "BMP085/BMP180 pressure and temperature sensor"
127 /* -------------------------------------------------------------------------- */
128 extern const struct sensors_sensor bmpx8x;
129 /* -------------------------------------------------------------------------- */
130 #endif
131 /* -------------------------------------------------------------------------- */
132 /**
133  * @}
134  * @}
135  */
136 
Implementation of a generic module controlling Zoul sensors.