BH1790GLC

Committer:
ThunderSoft
Date:
Thu Mar 21 08:52:45 2019 +0000
Revision:
1:e9033991d204
Add BH1790GLC code for TT_Mxx.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ThunderSoft 1:e9033991d204 1 /*
ThunderSoft 1:e9033991d204 2 The MIT License (MIT)
ThunderSoft 1:e9033991d204 3 Copyright (c) 2017 Rohm Semiconductor
ThunderSoft 1:e9033991d204 4
ThunderSoft 1:e9033991d204 5 Permission is hereby granted, free of charge, to any person obtaining a
ThunderSoft 1:e9033991d204 6 copy of this software and associated documentation files (the
ThunderSoft 1:e9033991d204 7 "Software"), to deal in the Software without restriction, including
ThunderSoft 1:e9033991d204 8 without limitation the rights to use, copy, modify, merge, publish,
ThunderSoft 1:e9033991d204 9 distribute, sublicense, and/or sell copies of the Software, and to
ThunderSoft 1:e9033991d204 10 permit persons to whom the Software is furnished to do so, subject to
ThunderSoft 1:e9033991d204 11 the following conditions:
ThunderSoft 1:e9033991d204 12
ThunderSoft 1:e9033991d204 13 The above copyright notice and this permission notice shall be included
ThunderSoft 1:e9033991d204 14 in all copies or substantial portions of the Software.
ThunderSoft 1:e9033991d204 15
ThunderSoft 1:e9033991d204 16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
ThunderSoft 1:e9033991d204 17 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
ThunderSoft 1:e9033991d204 18 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
ThunderSoft 1:e9033991d204 19 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
ThunderSoft 1:e9033991d204 20 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
ThunderSoft 1:e9033991d204 21 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
ThunderSoft 1:e9033991d204 22 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
ThunderSoft 1:e9033991d204 23 */
ThunderSoft 1:e9033991d204 24
ThunderSoft 1:e9033991d204 25 #ifndef __BH1790GLC_REGISTERS_H__
ThunderSoft 1:e9033991d204 26 #define __BH1790GLC_REGISTERS_H__
ThunderSoft 1:e9033991d204 27 /* registers */
ThunderSoft 1:e9033991d204 28 #define BH1790GLC_REGISTER_DUMP_START 0x0F
ThunderSoft 1:e9033991d204 29 #define BH1790GLC_MANUFACTURER_ID 0x0F
ThunderSoft 1:e9033991d204 30 #define BH1790GLC_PART_ID 0x10
ThunderSoft 1:e9033991d204 31 // Soft reset
ThunderSoft 1:e9033991d204 32 #define BH1790GLC_RESET 0x40
ThunderSoft 1:e9033991d204 33 // System control setting
ThunderSoft 1:e9033991d204 34 #define BH1790GLC_MEAS_CONTROL1 0x41
ThunderSoft 1:e9033991d204 35 // Measurement control setting
ThunderSoft 1:e9033991d204 36 #define BH1790GLC_MEAS_CONTROL2 0x42
ThunderSoft 1:e9033991d204 37 // Measurement start
ThunderSoft 1:e9033991d204 38 #define BH1790GLC_MEAS_START 0x43
ThunderSoft 1:e9033991d204 39 #define BH1790GLC_DATAOUT_LEDOFF_L 0x54
ThunderSoft 1:e9033991d204 40 #define BH1790GLC_DATAOUT_LEDOFF_H 0x55
ThunderSoft 1:e9033991d204 41 #define BH1790GLC_DATAOUT_LEDON_L 0x56
ThunderSoft 1:e9033991d204 42 // Restarts measurement.
ThunderSoft 1:e9033991d204 43 #define BH1790GLC_DATAOUT_LEDON_H 0x57
ThunderSoft 1:e9033991d204 44 #define BH1790GLC_REGISTER_DUMP_END 0x57
ThunderSoft 1:e9033991d204 45 /* registers bits */
ThunderSoft 1:e9033991d204 46 // WHO_AM_I -value
ThunderSoft 1:e9033991d204 47 #define BH1790GLC_PART_ID_WIA_ID (0x0D << 0)
ThunderSoft 1:e9033991d204 48 // 1 : Software reset is performed
ThunderSoft 1:e9033991d204 49 #define BH1790GLC_RESET_SWRESET (0x01 << 7)
ThunderSoft 1:e9033991d204 50 // OSC block is inactive
ThunderSoft 1:e9033991d204 51 #define BH1790GLC_MEAS_CONTROL1_RDY_DISABLE (0x00 << 7)
ThunderSoft 1:e9033991d204 52 // OSC block is active
ThunderSoft 1:e9033991d204 53 #define BH1790GLC_MEAS_CONTROL1_RDY_ENABLE (0x01 << 7)
ThunderSoft 1:e9033991d204 54 #define BH1790GLC_MEAS_CONTROL1_LED_LIGHTING_FREQ_128HZ (0x00 << 2)
ThunderSoft 1:e9033991d204 55 #define BH1790GLC_MEAS_CONTROL1_LED_LIGHTING_FREQ_64HZ (0x01 << 2)
ThunderSoft 1:e9033991d204 56 #define BH1790GLC_MEAS_CONTROL1_RCYCLE_PROHIBITED1 (0x00 << 0)
ThunderSoft 1:e9033991d204 57 #define BH1790GLC_MEAS_CONTROL1_RCYCLE_64HZ (0x01 << 0)
ThunderSoft 1:e9033991d204 58 #define BH1790GLC_MEAS_CONTROL1_RCYCLE_32HZ (0x02 << 0)
ThunderSoft 1:e9033991d204 59 #define BH1790GLC_MEAS_CONTROL1_RCYCLE_PROHIBITED2 (0x03 << 0)
ThunderSoft 1:e9033991d204 60 #define BH1790GLC_MEAS_CONTROL2_LED2_EN_PULSED (0x00 << 7)
ThunderSoft 1:e9033991d204 61 #define BH1790GLC_MEAS_CONTROL2_LED2_EN_CONSTANT (0x01 << 7)
ThunderSoft 1:e9033991d204 62 #define BH1790GLC_MEAS_CONTROL2_LED1_EN_PULSED (0x00 << 6)
ThunderSoft 1:e9033991d204 63 #define BH1790GLC_MEAS_CONTROL2_LED1_EN_CONSTANT (0x01 << 6)
ThunderSoft 1:e9033991d204 64 // us
ThunderSoft 1:e9033991d204 65 #define BH1790GLC_MEAS_CONTROL2_LED_ON_TIME_216T_OSC (0x00 << 5)
ThunderSoft 1:e9033991d204 66 // us
ThunderSoft 1:e9033991d204 67 #define BH1790GLC_MEAS_CONTROL2_LED_ON_TIME_432T_OSC (0x01 << 5)
ThunderSoft 1:e9033991d204 68 #define BH1790GLC_MEAS_CONTROL2_LED_CURRENT_0MA (0x00 << 0)
ThunderSoft 1:e9033991d204 69 #define BH1790GLC_MEAS_CONTROL2_LED_CURRENT_1MA (0x08 << 0)
ThunderSoft 1:e9033991d204 70 #define BH1790GLC_MEAS_CONTROL2_LED_CURRENT_2MA (0x09 << 0)
ThunderSoft 1:e9033991d204 71 #define BH1790GLC_MEAS_CONTROL2_LED_CURRENT_3MA (0x0A << 0)
ThunderSoft 1:e9033991d204 72 #define BH1790GLC_MEAS_CONTROL2_LED_CURRENT_6MA (0x0B << 0)
ThunderSoft 1:e9033991d204 73 #define BH1790GLC_MEAS_CONTROL2_LED_CURRENT_10MA (0x0C << 0)
ThunderSoft 1:e9033991d204 74 #define BH1790GLC_MEAS_CONTROL2_LED_CURRENT_20MA (0x0D << 0)
ThunderSoft 1:e9033991d204 75 #define BH1790GLC_MEAS_CONTROL2_LED_CURRENT_30MA (0x0E << 0)
ThunderSoft 1:e9033991d204 76 #define BH1790GLC_MEAS_CONTROL2_LED_CURRENT_60MA (0x0F << 0)
ThunderSoft 1:e9033991d204 77 #define BH1790GLC_MEAS_START_MEAS_ST_STOP (0x00 << 0)
ThunderSoft 1:e9033991d204 78 #define BH1790GLC_MEAS_START_MEAS_ST_START (0x01 << 0)
ThunderSoft 1:e9033991d204 79 /*registers bit masks */
ThunderSoft 1:e9033991d204 80 #define BH1790GLC_PART_ID_WIA_MASK 0xFF
ThunderSoft 1:e9033991d204 81 // 1 : OSC block is active
ThunderSoft 1:e9033991d204 82 #define BH1790GLC_MEAS_CONTROL1_RDY_MASK 0x80
ThunderSoft 1:e9033991d204 83 // Select LED omitting frequency
ThunderSoft 1:e9033991d204 84 #define BH1790GLC_MEAS_CONTROL1_LED_LIGHTING_FREQ_MASK 0x04
ThunderSoft 1:e9033991d204 85 #define BH1790GLC_MEAS_CONTROL1_RCYCLE_MASK 0x03
ThunderSoft 1:e9033991d204 86 #define BH1790GLC_MEAS_CONTROL2_LED2_EN_MASK 0x80
ThunderSoft 1:e9033991d204 87 #define BH1790GLC_MEAS_CONTROL2_LED1_EN_MASK 0x40
ThunderSoft 1:e9033991d204 88 #define BH1790GLC_MEAS_CONTROL2_LED_ON_TIME_MASK 0x20
ThunderSoft 1:e9033991d204 89 // LED lighting current
ThunderSoft 1:e9033991d204 90 #define BH1790GLC_MEAS_CONTROL2_LED_CURRENT_MASK 0x0F
ThunderSoft 1:e9033991d204 91 #define BH1790GLC_MEAS_START_MEAS_ST_MASK 0x01
ThunderSoft 1:e9033991d204 92 #endif
ThunderSoft 1:e9033991d204 93
ThunderSoft 1:e9033991d204 94
ThunderSoft 1:e9033991d204 95