upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
bh1750_defs.h
1 /*
2  * Authors: Jon Trulson <jtrulson@ics.com>
3  * Copyright (c) 2016 Intel Corporation.
4  *
5  * The MIT License
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining
8  * a copy of this software and associated documentation files (the
9  * "Software"), to deal in the Software without restriction, including
10  * without limitation the rights to use, copy, modify, merge, publish,
11  * distribute, sublicense, and/or sell copies of the Software, and to
12  * permit persons to whom the Software is furnished to do so, subject to
13  * the following conditions:
14  *
15  * The above copyright notice and this permission notice shall be
16  * included in all copies or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25  */
26 
27 #pragma once
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif // __cplusplus
32 
33 #define BH1750_DEFAULT_I2C_BUS 0
34 #define BH1750_DEFAULT_I2C_ADDR 0x23
35 
36 // BH1750 commands
37 
38 #define BH1750_CMD_POWER_DOWN 0x00
39 #define BH1750_CMD_POWER_UP 0x01
40 
41 #define BH1750_CMD_RESET 0x07
42 
43 // continuous modes
44 #define BH1750_CMD_CONT_H_RES_MODE1 0x10 // 1 lx resolution
45 #define BH1750_CMD_CONT_H_RES_MODE2 0x11 // .5 lx resolution
46 #define BH1750_CMD_CONT_L_RES_MODE 0x13 // 4 lx resolution
47 
48 // one-time modes
49 #define BH1750_CMD_ONETIME_H_RES_MODE1 0x20
50 #define BH1750_CMD_ONETIME_H_RES_MODE2 0x21
51 #define BH1750_CMD_ONETIME_L_RES_MODE 0x23
52 
53 // max measurement time in ms (for H modes)
54 #define BH1750_MAX_MEAS_TIME_H 180
55 
56 // max measurement time in ms (for L modes)
57 #define BH1750_MAX_MEAS_TIME_L 30
58 
59 // an enum for the operating mode to pass to init
60  typedef enum {
61  BH1750_OPMODE_H1_CONT, // continuous 1 lx high resolution
62  BH1750_OPMODE_H2_CONT, // continuous .5 lx high resolution
63  BH1750_OPMODE_L_CONT, // continuous 4 lx low resolution
64  BH1750_OPMODE_H1_ONCE, // onetime 1 lx high resolution
65  BH1750_OPMODE_H2_ONCE, // onetime .5 lx high resolution
66  BH1750_OPMODE_L_ONCE, // onetime 4 lx low resolution
67  } BH1750_OPMODES_T;
68 
69 #ifdef __cplusplus
70 }
71 #endif // __cplusplus