upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
bh1792glc_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 __BH1792GLC_REGISTERS_H__
26 #define __BH1792GLC_REGISTERS_H__
27 /* registers */
28 #define BH1792_REGISTER_DUMP_START 0x0F
29 #define BH1792_MANUFACTURER_REG 0x0F
30 // WHO_AM_I -value
31 #define BH1792_PARTID_REG 0x10
32 // Soft reset
33 #define BH1792_RESET 0x40
34 // System control setting
35 #define BH1792_MEAS_CONTROL1 0x41
36 // LED 1 & 2 control register
37 #define BH1792_MEAS_CONTROL2 0x42
38 // LED 3 control register
39 #define BH1792_MEAS_CONTROL3 0x43
40 // IR Interrupt Threshold Value [7:0]
41 #define BH1792_MEAS_CONTROL4_L 0x44
42 // IR Interrupt Threshold Value [15:8]
43 #define BH1792_MEAS_CONTROL4_H 0x45
44 #define BH1792_MEAS_CONTROL5 0x46
45 #define BH1792_MEAS_START 0x47
46 #define BH1792_MEAS_SYNC 0x48
47 #define BH1792_FIFO_LEV 0x4B
48 // FIFO Output data 0 [7:0]
49 #define BH1792_FIFO_DATA0_L 0x4C
50 // FIFO Output data 0 [15:8]
51 #define BH1792_FIFO_DATA0_H 0x4D
52 // FIFO Output data 1 [7:0]
53 #define BH1792_FIFO_DATA1_L 0x4E
54 // FIFO Output data 1 [15:8]
55 #define BH1792_FIFO_DATA1_H 0x4F
56 // IR Data Count Value during no LED emission [7:0]
57 #define BH1792_IRDATA_LEDOFF_L 0x50
58 // IR Data Count Value during no LED emission [15:8]
59 #define BH1792_IRDATA_LEDOFF_H 0x51
60 // IR Data Count Value during LED emission [7:0]
61 #define BH1792_IRDATA_LEDON_L 0x52
62 // IR Data Count Value during LED emission [15:8]
63 #define BH1792_IRDATA_LEDON_H 0x53
64 // Green Data Count Value during no LED emission [7:0]
65 #define BH1792_DATAOUT_LEDOFF_L 0x54
66 // Green Data Count Value during no LED emission [15:8]
67 #define BH1792_DATAOUT_LEDOFF_H 0x55
68 // Green Data Count Value during LED emission [7:0]
69 #define BH1792_DATAOUT_LEDON_L 0x56
70 // Green Data Count Value during LED emission [15:8]
71 #define BH1792_DATAOUT_LEDON_H 0x57
72 // IR threshold judgement and measurement completion interrupt is cleared when reading this register.
73 #define BH1792_INT_CLEAR 0x58
74 #define BH1792_REGISTER_DUMP_END 0x58
75 /* registers bits */
76 #define BH1792_MANUFACTURER_REG_MANUFACTURER_ID (0xE0 << 0)
77 #define BH1792_PARTID_REG_PART_ID (0x0E << 0)
78 // 1 : Software reset is performed
79 #define BH1792_RESET_SWRESET (0x01 << 7)
80 // 1 : OSC block is active, 0: prohibited
81 #define BH1792_MEAS_CONTROL1_RDY (0x01 << 7)
82 // Green mode, leds 1 & 2 active
83 #define BH1792_MEAS_CONTROL1_SEL_ADC_GREEN (0x00 << 4)
84 // IR mode, led 3 active. Can be used only in single and non synch modes.
85 #define BH1792_MEAS_CONTROL1_SEL_ADC_IR (0x01 << 4)
86 // 32 Hz synchronous mode
87 #define BH1792_MEAS_CONTROL1_MSR_32HZ (0x00 << 0)
88 // 128 Hz synchronous mode
89 #define BH1792_MEAS_CONTROL1_MSR_128HZ (0x01 << 0)
90 // 64 Hz synchronous mode
91 #define BH1792_MEAS_CONTROL1_MSR_64HZ (0x02 << 0)
92 // 256 Hz synchronous mode
93 #define BH1792_MEAS_CONTROL1_MSR_256HZ (0x03 << 0)
94 #define BH1792_MEAS_CONTROL1_MSR_PROHIBITED (0x04 << 0)
95 // 1024 Hz synchronous mode
96 #define BH1792_MEAS_CONTROL1_MSR_1024HZ (0x05 << 0)
97 // non synchronized measurement mode
98 #define BH1792_MEAS_CONTROL1_MSR_NON_SYNCH_MODE (0x06 << 0)
99 // single measurement mode
100 #define BH1792_MEAS_CONTROL1_MSR_SINGLE_MEAS_MODE (0x07 << 0)
101 // LED driver mode, for usage see datasheet
102 #define BH1792_MEAS_CONTROL3_LED_EN2 (0x01 << 7)
103 // No interrupt output.
104 #define BH1792_MEAS_CONTROL5_INT_SEL_DISABLE (0x00 << 0)
105 // Watermark interrupt FIFO, fires when number of stored samples reaches 32. Cleared when number of samples falls below 32.
106 #define BH1792_MEAS_CONTROL5_INT_SEL_FIFO_WATERMARK (0x01 << 0)
107 // IR threshold judgement interrupt. Used in non synchroniozed mode.
108 #define BH1792_MEAS_CONTROL5_INT_SEL_IR_THRESHOLD (0x02 << 0)
109 // Measurement completion interrupt. In single mode.
110 #define BH1792_MEAS_CONTROL5_INT_SEL_ON_COMPLETE (0x03 << 0)
111 // Flag of start measurement. MEAS_ST=1 after RDY=1 starts measurement. In single measurement mode MEAS_ST=1 restarts measurement.
112 #define BH1792_MEAS_START_MEAS_ST (0x01 << 0)
113 // Used in synhcronized measurement mode. Write once per second.
114 #define BH1792_MEAS_SYNC_MEAS_SYNC (0x01 << 0)
115  /*registers bit masks */
116 #define BH1792_MANUFACTURER_REG_MANUFACTURER_MASK 0xFF
117 #define BH1792_PARTID_REG_PART_MASK 0xFF
118 // Select LED omitting frequency
119 #define BH1792_MEAS_CONTROL1_SEL_ADC_MASK 0x10
120 // Measurement mode
121 #define BH1792_MEAS_CONTROL1_MSR_MASK 0x07
122 #define BH1792_MEAS_CONTROL2_LED_EN1_MASK 0xC0
123 #define BH1792_MEAS_CONTROL2_LED_CURRENT1_MASK 0x3F
124 #define BH1792_MEAS_CONTROL3_LED_CURRENT2_MASK 0x3F
125 // Interrupt function select
126 #define BH1792_MEAS_CONTROL5_INT_SEL_MASK 0x03
127 #define BH1792_FIFO_LEV_LEVEL_MASK 0x3F
128 #endif
129