Contiki-NG
bme280.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015, Copyright Robert Olsson
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  * Author : Robert Olsson rolss@kth.se/robert@radio-sensors.com
33  *
34  * Created : 2016-09-14
35  */
36 
37 /**
38  * \file
39  * Definitions for the Bosch BME280 based on datasheet Rev 1.1
40  */
41 
42 #ifndef BME280_H
43 #define BME280_H
44 
45 #ifndef BME280_32BIT
46 #define BME280_64BIT
47 #endif
48 
49 uint8_t bme280_init(uint8_t mode);
50 void bme280_read(uint8_t mode);
51 
52 #ifdef BME280_CONF_ADDR
53 #define BME280_ADDR BME280_CONF_ADDR
54 #else
55 #define BME280_ADDR (0x77 << 1) /* Alternative 0x76 */
56 #endif
57 
58 /* Diffrent BOSCH chip id's */
59 #define BMP085_CHIP_ID 0x55 /* And also BMP180 */
60 #define BMP280_CHIP_ID 0x58
61 #define BME280_CHIP_ID 0x60
62 
63 /* Address map */
64 #define BME280_DIG_T1_ADDR 0x88
65 #define BME280_DIG_T2_ADDR 0x8A
66 #define BME280_DIG_T3_ADDR 0x8C
67 #define BME280_DIG_P1_ADDR 0x8E
68 #define BME280_DIG_P2_ADDR 0x90
69 #define BME280_DIG_P3_ADDR 0x92
70 #define BME280_DIG_P4_ADDR 0x94
71 #define BME280_DIG_P5_ADDR 0x96
72 #define BME280_DIG_P6_ADDR 0x98
73 #define BME280_DIG_P7_ADDR 0x9A
74 #define BME280_DIG_P8_ADDR 0x9C
75 #define BME280_DIG_P9_ADDR 0x9E
76 #define BME280_DIG_H1_ADDR 0xA1
77 #define BMP_CHIP_ID_ADDR 0xD0
78 #define BME280_CNTL_RESET 0xE0
79 #define BME280_DIG_H2_ADDR 0xE1
80 #define BME280_DIG_H3_ADDR 0xE3
81 #define BME280_DIG_H4_ADDR 0xE4
82 #define BME280_DIG_H5_ADDR 0xE5
83 #define BME280_DIG_H6_ADDR 0xE7
84 #define BME280_CNTL_HUM 0xF2
85 #define BME280_STATUS 0xF3
86 #define BME280_CNTL_MEAS 0xF4
87 #define BME280_CONTROL 0xF5
88 #define BME280_PRESS 0xF7
89 
90 /* Function modes outlined in datasheet */
91 #define BME280_MODE_NONE 0
92 #define BME280_MODE_WEATHER 1
93 #define BME280_MODE_HUMIDITY 2
94 #define BME280_MODE_INDOOR_NAVIGATION 3
95 #define BME280_MODE_GAMING 4
96 
97 #define BME280_MAX_WAIT 300 /* ms. Forced mode max wait */
98 
99 
100 struct {
101  int32_t t_overscale100;
102  uint32_t h_overscale1024;
103 #ifdef BME280_64BIT
104  uint32_t p_overscale256;
105 #else
106  uint32_t p;
107 #endif
108 } bme280_mea;
109 
110 #endif /* BME280_H */