Rohm BH1726 ALS sensor driver.

Dependents:   rohm-bh1726-hello rohm-tileshield-6sensor-demo

Fork of rohm-bh1745 by Rohm

Committer:
MikkoZ
Date:
Mon Sep 19 12:24:27 2016 +0000
Revision:
3:6eb91c7c6560
Parent:
2:40307a303153
Updated SAD to work with other sensor tiles on Rohm Tile-shield.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MikkoZ 2:40307a303153 1 /* Copyright 2016 Rohm Semiconductor
MikkoZ 2:40307a303153 2
MikkoZ 2:40307a303153 3 Licensed under the Apache License, Version 2.0 (the "License");
MikkoZ 2:40307a303153 4 you may not use this file except in compliance with the License.
MikkoZ 2:40307a303153 5 You may obtain a copy of the License at
MikkoZ 2:40307a303153 6
MikkoZ 2:40307a303153 7 http://www.apache.org/licenses/LICENSE-2.0
MikkoZ 2:40307a303153 8
MikkoZ 2:40307a303153 9 Unless required by applicable law or agreed to in writing, software
MikkoZ 2:40307a303153 10 distributed under the License is distributed on an "AS IS" BASIS,
MikkoZ 2:40307a303153 11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
MikkoZ 2:40307a303153 12 See the License for the specific language governing permissions and
MikkoZ 2:40307a303153 13 limitations under the License.
MikkoZ 2:40307a303153 14 */
MikkoZ 2:40307a303153 15 #ifndef BH1726_H
MikkoZ 2:40307a303153 16 #define BH1726_H
MikkoZ 2:40307a303153 17
MikkoZ 2:40307a303153 18 /* registers */
MikkoZ 2:40307a303153 19 #define BH1726_REGISTER_DUMP_START 0x80
MikkoZ 2:40307a303153 20 #define BH1726_CONTROL 0x80
MikkoZ 2:40307a303153 21 // ADC Light integration time. Cycle = 256-itime; integration time= cycle x 2.7ms; measurement time = 2ms + integration time
MikkoZ 2:40307a303153 22 #define BH1726_TIMING 0x81
MikkoZ 2:40307a303153 23 #define BH1726_INTERRUPT 0x82
MikkoZ 2:40307a303153 24 #define BH1726_TH_LOW_LSBS 0x83
MikkoZ 2:40307a303153 25 #define BH1726_TH_LOW_MSBS 0x84
MikkoZ 2:40307a303153 26 #define BH1726_TH_UP_LSBS 0x85
MikkoZ 2:40307a303153 27 #define BH1726_TH_UP_MSBS 0x86
MikkoZ 2:40307a303153 28 #define BH1726_GAIN 0x87
MikkoZ 2:40307a303153 29 #define BH1726_ID 0x92
MikkoZ 2:40307a303153 30 #define BH1726_DATA0_LSBS 0x94
MikkoZ 2:40307a303153 31 #define BH1726_DATA0_MSBS 0x95
MikkoZ 2:40307a303153 32 #define BH1726_DATA1_LSBS 0x96
MikkoZ 2:40307a303153 33 #define BH1726_DATA1_MSBS 0x97
MikkoZ 2:40307a303153 34 #define BH1726_WAIT 0x98
MikkoZ 2:40307a303153 35 // special command, no data
MikkoZ 2:40307a303153 36 #define BH1726_INTERRUPT_OUTPUT_RESET 0xE1
MikkoZ 2:40307a303153 37 // special command, no data
MikkoZ 2:40307a303153 38 #define BH1726_SOFTWARE_RESET 0xE4
MikkoZ 2:40307a303153 39 #define BH1726_REGISTER_DUMP_END 0x98
MikkoZ 2:40307a303153 40 /* registers bits */
MikkoZ 2:40307a303153 41 #define BH1726_CONTROL_ADC_INTR_INACTIVE (0x00 << 5)
MikkoZ 2:40307a303153 42 #define BH1726_CONTROL_ADC_INTR_ACTIVE (0x01 << 5)
MikkoZ 2:40307a303153 43 #define BH1726_CONTROL_ADC_VALID_FALSE (0x00 << 4)
MikkoZ 2:40307a303153 44 // Updated since last reading
MikkoZ 2:40307a303153 45 #define BH1726_CONTROL_ADC_VALID_TRUE (0x01 << 4)
MikkoZ 2:40307a303153 46 #define BH1726_CONTROL_ADC_EN_FALSE (0x00 << 1)
MikkoZ 2:40307a303153 47 #define BH1726_CONTROL_ADC_EN_TRUE (0x01 << 1)
MikkoZ 2:40307a303153 48 #define BH1726_CONTROL_POWER_OFF (0x00 << 0)
MikkoZ 2:40307a303153 49 #define BH1726_CONTROL_POWER_ON (0x01 << 0)
MikkoZ 2:40307a303153 50 // 691.2ms
MikkoZ 2:40307a303153 51 #define BH1726_TIMING_ITIME_256CYCLE (0x00 << 0)
MikkoZ 2:40307a303153 52 // 399.6ms
MikkoZ 2:40307a303153 53 #define BH1726_TIMING_ITIME_148CYCLE (0x6C << 0)
MikkoZ 2:40307a303153 54 // 199.8ms
MikkoZ 2:40307a303153 55 #define BH1726_TIMING_ITIME_74CYCLE (0xB6 << 0)
MikkoZ 2:40307a303153 56 // 135ms
MikkoZ 2:40307a303153 57 #define BH1726_TIMING_ITIME_50CYCLE (0xCE << 0)
MikkoZ 2:40307a303153 58 // 102.6ms
MikkoZ 2:40307a303153 59 #define BH1726_TIMING_ITIME_38CYCLE (0xDA << 0)
MikkoZ 2:40307a303153 60 // 51.3ms
MikkoZ 2:40307a303153 61 #define BH1726_TIMING_ITIME_19CYCLE (0xED << 0)
MikkoZ 2:40307a303153 62 // 5.4ms
MikkoZ 2:40307a303153 63 #define BH1726_TIMING_ITIME_2CYCLE (0xFE << 0)
MikkoZ 2:40307a303153 64 // 2.7ms
MikkoZ 2:40307a303153 65 #define BH1726_TIMING_ITIME_1CYCLE (0xFF << 0)
MikkoZ 2:40307a303153 66 #define BH1726_INTERRUPT_INT_LATCH_YES (0x00 << 5)
MikkoZ 2:40307a303153 67 #define BH1726_INTERRUPT_INT_LATCH_NO (0x01 << 5)
MikkoZ 2:40307a303153 68 #define BH1726_INTERRUPT_INT_EN_FALSE (0x00 << 4)
MikkoZ 2:40307a303153 69 #define BH1726_INTERRUPT_INT_EN_TRUE (0x01 << 4)
MikkoZ 2:40307a303153 70 #define BH1726_INTERRUPT_PERSIST_DRDY (0x00 << 0)
MikkoZ 2:40307a303153 71 #define BH1726_INTERRUPT_PERSIST_AFTER_1 (0x01 << 0)
MikkoZ 2:40307a303153 72 #define BH1726_INTERRUPT_PERSIST_AFTER_2 (0x02 << 0)
MikkoZ 2:40307a303153 73 #define BH1726_INTERRUPT_PERSIST_AFTER_3 (0x03 << 0)
MikkoZ 2:40307a303153 74 #define BH1726_INTERRUPT_PERSIST_AFTER_4 (0x04 << 0)
MikkoZ 2:40307a303153 75 #define BH1726_GAIN_GAIN0_X1 (0x00 << 2)
MikkoZ 2:40307a303153 76 #define BH1726_GAIN_GAIN0_X2 (0x01 << 2)
MikkoZ 2:40307a303153 77 #define BH1726_GAIN_GAIN0_X64 (0x02 << 2)
MikkoZ 2:40307a303153 78 #define BH1726_GAIN_GAIN0_X128 (0x03 << 2)
MikkoZ 2:40307a303153 79 #define BH1726_GAIN_GAIN1_X1 (0x00 << 0)
MikkoZ 2:40307a303153 80 #define BH1726_GAIN_GAIN1_X2 (0x01 << 0)
MikkoZ 2:40307a303153 81 #define BH1726_GAIN_GAIN1_X64 (0x02 << 0)
MikkoZ 2:40307a303153 82 #define BH1726_GAIN_GAIN1_X128 (0x03 << 0)
MikkoZ 2:40307a303153 83 #define BH1726_ID_NUMBER_FOR_PART (0x72 << 0)
MikkoZ 2:40307a303153 84 #define BH1726_WAIT_WAIT_NO (0x00 << 0)
MikkoZ 2:40307a303153 85 // after each measurement (low current consumption mode)
MikkoZ 2:40307a303153 86 #define BH1726_WAIT_WAIT_300MS (0x01 << 0)
MikkoZ 2:40307a303153 87 /*registers bit masks */
MikkoZ 2:40307a303153 88 #define BH1726_CONTROL_ADC_INTR_MASK 0x20
MikkoZ 2:40307a303153 89 #define BH1726_CONTROL_ADC_VALID_MASK 0x10
MikkoZ 2:40307a303153 90
MikkoZ 2:40307a303153 91 #define BH1726_CONTROL_ADC_EN_MASK 0x02
MikkoZ 2:40307a303153 92 #define BH1726_CONTROL_POWER_MASK 0x01
MikkoZ 2:40307a303153 93 #define BH1726_TIMING_ITIME_MASK 0xFF
MikkoZ 2:40307a303153 94
MikkoZ 2:40307a303153 95 #define BH1726_INTERRUPT_INT_LATCH_MASK 0x20
MikkoZ 2:40307a303153 96 #define BH1726_INTERRUPT_INT_EN_MASK 0x10
MikkoZ 2:40307a303153 97 #define BH1726_INTERRUPT_PERSIST_MASK 0x0F
MikkoZ 2:40307a303153 98 #define BH1726_GAIN_GAIN0_MASK 0x0C
MikkoZ 2:40307a303153 99 #define BH1726_GAIN_GAIN1_MASK 0x03
MikkoZ 2:40307a303153 100 #define BH1726_ID_NUMBER_MASK 0xFF
MikkoZ 2:40307a303153 101 #define BH1726_WAIT_WAIT_MASK 0x01
MikkoZ 2:40307a303153 102
MikkoZ 2:40307a303153 103 #endif /* BH1726_H */