Optical pulse wave sensor BH1790GLC driver. The original code contributed by Hideki Tanaka.

Dependents:   rohm-bh1790glc-hello rohm-SensorShield-example

Fork of BH1790GLC by Hideki Tanaka

Committer:
MikkoZ
Date:
Mon Jun 19 20:13:11 2017 +0000
Revision:
2:4446bf1de21b
Parent:
1:32bb2624bed8
Cleaned register definitions.

Who changed what in which revision?

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