upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
bh1749_registers.h
1 /*
2 The MIT License (MIT)
3 Copyright (c) 2017 Rohm Semiconductor
4 
5 Permission is hereby granted, free of charge, to any person obtaining a
6 copy of this software and associated documentation files (the
7 "Software"), to deal in the Software without restriction, including
8 without limitation the rights to use, copy, modify, merge, publish,
9 distribute, sublicense, and/or sell copies of the Software, and to
10 permit persons to whom the Software is furnished to do so, subject to
11 the following conditions:
12 
13 The above copyright notice and this permission notice shall be included
14 in all copies or substantial portions of the Software.
15 
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24 
25 #ifndef __BH1749_REGISTERS_H__
26 #define __BH1749_REGISTERS_H__
27 /* registers */
28 #define BH1749_REGISTER_DUMP_START 0x40
29 #define BH1749_SYSTEM_CONTROL 0x40
30 #define BH1749_MODE_CONTROL1 0x41
31 #define BH1749_MODE_CONTROL2 0x42
32 // Least significant byte of uint16 RED measurement value
33 #define BH1749_RED_DATA_LSBS 0x50
34 // Most significant byte of uint16 RED measurement value
35 #define BH1749_RED_DATA_MSBS 0x51
36 // Least significant byte of uint16 GREEN measurement value
37 #define BH1749_GREEN_DATA_LSBS 0x52
38 // Most significant byte of uint16 GREEN measurement value
39 #define BH1749_GREEN_DATA_MSBS 0x53
40 // Least significant byte of uint16 BLUE measurement value
41 #define BH1749_BLUE_DATA_LSBS 0x54
42 // Most significant byte of uint16 BLUE measurement value
43 #define BH1749_BLUE_DATA_MSBS 0x55
44 // Least significant byte of uint16 IR measurement value
45 #define BH1749_IR_DATA_LSBS 0x58
46 // Most significant byte of uint16 IR measurement value
47 #define BH1749_IR_DATA_MSBS 0x59
48 // Least significant byte of uint16 GREEN2 measurement value
49 #define BH1749_GREEN2_DATA_LSBS 0x5A
50 // Most significant byte of uint16 GREEN2 measurement value
51 #define BH1749_GREEN2_DATA_MSBS 0x5B
52 // Interrupt control register
53 #define BH1749_INTERRUPT 0x60
54 // Interrupt status update control register
55 #define BH1749_PERSISTENCE 0x61
56 // Least significant byte of interrupt threshold high level
57 #define BH1749_TH_LSBS 0x62
58 // Most significant byte of interrupt threshold high level
59 #define BH1749_TH_MSBS 0x63
60 // Least significant byte of interrupt threshold low level
61 #define BH1749_TL_LSBS 0x64
62 // Most significant byte of interrupt threshold low level
63 #define BH1749_TL_MSBS 0x65
64 #define BH1749_ID_REG 0x92
65 #define BH1749_REGISTER_DUMP_END 0x92
66 /* registers bits */
67 // Software reset is not done
68 #define BH1749_SYSTEM_CONTROL_SW_RESET_NOT_DONE (0x00 << 7)
69 // Software reset is done
70 #define BH1749_SYSTEM_CONTROL_SW_RESET_DONE (0x01 << 7)
71 // INT pin status is not changed
72 #define BH1749_SYSTEM_CONTROL_INT_NO_ACTION (0x00 << 6)
73 // INT pin becomes inactive (high impedance)
74 #define BH1749_SYSTEM_CONTROL_INT_RESET (0x01 << 6)
75 #define BH1749_SYSTEM_CONTROL_PART_ID (0x0D << 0)
76 #define BH1749_MODE_CONTROL1_RESERVED7_WRITE0 (0x00 << 7)
77 #define BH1749_MODE_CONTROL1_IR_GAIN_RESERVED0 (0x00 << 5)
78 #define BH1749_MODE_CONTROL1_IR_GAIN_1X (0x01 << 5)
79 #define BH1749_MODE_CONTROL1_IR_GAIN_RESERVED1 (0x02 << 5)
80 #define BH1749_MODE_CONTROL1_IR_GAIN_32X (0x03 << 5)
81 #define BH1749_MODE_CONTROL1_RGB_GAIN_RESERVED0 (0x00 << 3)
82 #define BH1749_MODE_CONTROL1_RGB_GAIN_1X (0x01 << 3)
83 #define BH1749_MODE_CONTROL1_RGB_GAIN_RESERVED1 (0x02 << 3)
84 #define BH1749_MODE_CONTROL1_RGB_GAIN_32X (0x03 << 3)
85 // Reserved value
86 #define BH1749_MODE_CONTROL1_ODR_RESERVED0 (0x00 << 0)
87 // Reserved value
88 #define BH1749_MODE_CONTROL1_ODR_RESERVED1 (0x01 << 0)
89 // 120ms measurement time
90 #define BH1749_MODE_CONTROL1_ODR_8P333 (0x02 << 0)
91 // 240ms measurement time
92 #define BH1749_MODE_CONTROL1_ODR_4P167 (0x03 << 0)
93 // Reserved value
94 #define BH1749_MODE_CONTROL1_ODR_RESERVED2 (0x04 << 0)
95 // 35ms measurement time
96 #define BH1749_MODE_CONTROL1_ODR_28P6 (0x05 << 0)
97 // Reserved value
98 #define BH1749_MODE_CONTROL1_ODR_RESERVED3 (0x06 << 0)
99 // Reserved value
100 #define BH1749_MODE_CONTROL1_ODR_RESERVED4 (0x07 << 0)
101 #define BH1749_MODE_CONTROL2_VALID_NO (0x00 << 7)
102 #define BH1749_MODE_CONTROL2_VALID_YES (0x01 << 7)
103 #define BH1749_MODE_CONTROL2_RESERVED65_WRITE00 (0x00 << 5)
104 #define BH1749_MODE_CONTROL2_RGB_MEASUREMENT_INACTIVE (0x00 << 4)
105 #define BH1749_MODE_CONTROL2_RGB_MEASUREMENT_ACTIVE (0x01 << 4)
106 #define BH1749_MODE_CONTROL2_RESERVED30_WRITE0000 (0x00 << 0)
107 #define BH1749_INTERRUPT_STATUS_INACTIVE (0x00 << 7)
108 #define BH1749_INTERRUPT_STATUS_ACTIVE (0x01 << 7)
109 #define BH1749_INTERRUPT_RESERVED64_WRITE000 (0x00 << 4)
110 // red channel
111 #define BH1749_INTERRUPT_SOURCE_SELECT_RED (0x00 << 2)
112 // green channel
113 #define BH1749_INTERRUPT_SOURCE_SELECT_GREEN (0x01 << 2)
114 // blue channel
115 #define BH1749_INTERRUPT_SOURCE_SELECT_BLUE (0x02 << 2)
116 // Reserved value
117 #define BH1749_INTERRUPT_SOURCE_RESERVED0 (0x03 << 2)
118 #define BH1749_INTERRUPT_RESERVED1_WRITE0 (0x00 << 1)
119 #define BH1749_INTERRUPT_EN_DISABLE (0x00 << 0)
120 #define BH1749_INTERRUPT_EN_ENABLE (0x01 << 0)
121 #define BH1749_PERSISTENCE_RESERVED72_WRITE000000 (0x00 << 2)
122 // Interrupt status becomes active at each measurement end.
123 #define BH1749_PERSISTENCE_MODE_STATUS_ACTIVE_AFTER_MEASUREMENT (0x00 << 0)
124 // Interrupt status is updated at each measurement end.
125 #define BH1749_PERSISTENCE_MODE_STATUS_UPDATE_AFTER_MEASUREMENT (0x01 << 0)
126 // Interrupt status is updated if 4 consecutive threshold judgements are the same
127 #define BH1749_PERSISTENCE_MODE_STATUS_UPDATE_AFTER_4_SAME (0x02 << 0)
128 // Interrupt status is updated if 8 consecutive threshold judgements are the same
129 #define BH1749_PERSISTENCE_MODE_STATUS_UPDATE_AFTER_8_SAME (0x03 << 0)
130 // Manufacturer ID
131 #define BH1749_ID_REG_MANUFACTURER_ID (0xE0 << 0)
132  /*registers bit masks */
133 #define BH1749_SYSTEM_CONTROL_SW_RESET_MASK 0x80
134 
135 #define BH1749_SYSTEM_CONTROL_INT_MASK 0x40
136 
137 #define BH1749_SYSTEM_CONTROL_PART_MASK 0x3F
138 #define BH1749_MODE_CONTROL1_RESERVED7_MASK 0x80
139 #define BH1749_MODE_CONTROL1_IR_GAIN_MASK 0x60
140 #define BH1749_MODE_CONTROL1_RGB_GAIN_MASK 0x18
141 #define BH1749_MODE_CONTROL1_ODR_MASK 0x07
142 // Measurement data update flag. Sets to 0 if MODE_CONTROL1/2 reg,
143 // MODE_CONTROL2, INTERRUPT, T(H/L)_(LSB/MSB) is written or
144 // MODE_CONTROL2 read. In specification named as VALID.
145 #define BH1749_MODE_CONTROL2_VALID_MASK 0x80
146 #define BH1749_MODE_CONTROL2_RESERVED65_MASK 0x60
147 #define BH1749_MODE_CONTROL2_RGB_MEASUREMENT_MASK 0x10
148 #define BH1749_MODE_CONTROL2_RESERVED30_MASK 0x0F
149 #define BH1749_INTERRUPT_STATUS_MASK 0x80
150 #define BH1749_INTERRUPT_RESERVED64_MASK 0x70
151 #define BH1749_INTERRUPT_SOURCE_MASK 0x0C
152 // Write 0
153 #define BH1749_INTERRUPT_RESERVED1_MASK 0x02
154 #define BH1749_INTERRUPT_EN_MASK 0x01
155 #define BH1749_PERSISTENCE_RESERVED72_MASK 0xFC
156 #define BH1749_PERSISTENCE_MODE_MASK 0x03
157 
158 #define BH1749_ID_REG_MANUFACTURER_MASK 0xFF
159 #endif
160