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

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

Fork of BH1790GLC by Hideki Tanaka

Files at this revision

API Documentation at this revision

Comitter:
MikkoZ
Date:
Fri Jun 16 11:56:37 2017 +0000
Parent:
0:68b1bd50b38b
Child:
2:4446bf1de21b
Commit message:
Initial version of bh1790glc driver; ; Tested ok with bh1790glc-hello

Changed in this revision

BH1790GLC.cpp Show diff for this revision Revisions of this file
BH1790GLC.h Show diff for this revision Revisions of this file
bh1790glc.cpp Show annotated file Show diff for this revision Revisions of this file
bh1790glc.h Show annotated file Show diff for this revision Revisions of this file
bh1790glc_registers.h Show annotated file Show diff for this revision Revisions of this file
--- a/BH1790GLC.cpp	Mon Jun 12 08:48:38 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,101 +0,0 @@
-/*****************************************************************************
-  BH1790GLC.cpp
-
- Copyright (c) 2016 ROHM Co.,Ltd.
-
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
-
- The above copyright notice and this permission notice shall be included in
- all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- THE SOFTWARE.
-******************************************************************************/
-
-
-#include "BH1790GLC.h"
-
-BH1790GLC::BH1790GLC( PinName sda, PinName scl, char address )
-    : i2c_p( new I2C( sda, scl ) ), i2c( *i2c_p ), adr( address )
-{
-    init();
-}
-
-BH1790GLC::BH1790GLC( I2C &i2c_obj, char address )
-    : i2c_p( NULL ), i2c( i2c_obj ), adr( address )
-{
-    init();
-}
-
-BH1790GLC::~BH1790GLC()
-{
-    if ( NULL != i2c_p )
-        delete i2c_p;
-}
-
-void BH1790GLC::init(void)
-{
-}
-
-int BH1790GLC::meas_start(void)
-{
-    int rc;
-    char val[3];
-    val[0] = BH1790GLC_MEAS_CONTROL1_VAL;
-    val[1] = BH1790GLC_MEAS_CONTROL2_VAL;
-    val[2] = BH1790GLC_MEAS_START_VAL;
-    rc = write(BH1790GLC_MEAS_CONTROL1, val, sizeof(val));
-    return (rc);
-}
-
-int BH1790GLC::get_rawval(char *data)
-{
-    int rc;
-    rc = read(BH1790GLC_DATAOUT_LEDOFF, data, 4);
-    return (rc);
-}
-
-int BH1790GLC::get_val(unsigned short *data)
-{
-    int rc;
-    char val[4];
-    rc = get_rawval(val);
-    data[0] = ((unsigned short)val[1] << 8) | (val[0]);
-    data[1] = ((unsigned short)val[3] << 8) | (val[2]);
-    return (rc);
-}
-
-int BH1790GLC::write(char memory_address, char *data, int size)
-{
-    int rc;
-    char cmd[size];
-    cmd[0] = memory_address;
-    for (int i=0; i<size; i++) {
-        cmd[i+1] = data[i];
-    }
-    rc = i2c.write( adr, cmd, size+1,true);
-    return (rc);
-}
-
-int BH1790GLC::read(char memory_address, char *data, int size)
-{
-    int rc;
-    char cmd[size];
-    cmd[0] = memory_address;
-    rc = i2c.write( adr, cmd, 1, false);
-    if (rc !=0){
-        return (rc);
-    }
-    rc = i2c.read ( adr, data, size);
-    return (rc);
-}
\ No newline at end of file
--- a/BH1790GLC.h	Mon Jun 12 08:48:38 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,100 +0,0 @@
-/*****************************************************************************
-  BH1790GLC.h
-
- Copyright (c) 2016 ROHM Co.,Ltd.
-
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
-
- The above copyright notice and this permission notice shall be included in
- all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- THE SOFTWARE.
-******************************************************************************/
-#ifndef _BH1790GLC_H_
-#define _BH1790GLC_H_
-
-#define BH1790GLC_DEVICE_ADDRESS      (0x5B<<1)    
-#define BH1790GLC_MID_VAL             (0xE0)
-#define BH1790GLC_PID_VAL             (0x0D)
-
-#define BH1790GLC_MANUFACTURER_ID     (0x0F)
-#define BH1790GLC_PART_ID             (0x10)
-#define BH1790GLC_MEAS_CONTROL1       (0x41)
-#define BH1790GLC_DATAOUT_LEDOFF      (0x54)
-
-#define BH1790GLC_MEAS_CONTROL1_RDY                     (1 << 7)
-#define BH1790GLC_MEAS_CONTROL1_LED_LIGHTING_FREQ_128HZ (0 << 2)
-#define BH1790GLC_MEAS_CONTROL1_RCYCLE_32HZ             (2 << 0)
-
-#define BH1790GLC_MEAS_CONTROL2_LED_EN_00               (0 << 6)
-#define BH1790GLC_MEAS_CONTROL2_LED_ON_TIME_0_3MS       (0 << 5)
-#define BH1790GLC_MEAS_CONTROL2_LED_CURRENT_10MA        (12 << 0)
-
-#define BH1790GLC_MEAS_START_MEAS_ST                    (1 << 0)
-
-#define BH1790GLC_MEAS_CONTROL1_VAL   (BH1790GLC_MEAS_CONTROL1_RDY | BH1790GLC_MEAS_CONTROL1_LED_LIGHTING_FREQ_128HZ | BH1790GLC_MEAS_CONTROL1_RCYCLE_32HZ)
-#define BH1790GLC_MEAS_CONTROL2_VAL   (BH1790GLC_MEAS_CONTROL2_LED_EN_00 | BH1790GLC_MEAS_CONTROL2_LED_ON_TIME_0_3MS | BH1790GLC_MEAS_CONTROL2_LED_CURRENT_10MA)
-#define BH1790GLC_MEAS_START_VAL      (BH1790GLC_MEAS_START_MEAS_ST)
-
-#include "mbed.h"
-
-/** BH1790GLC class
- *
- *  BH1790GLC: an I2C bus optical sensor for heart rate monitor library
- *
- *  BH1790GLC is optical sensor for heart rate monitor IC in
- *  which LED driver and green light detection photo-diode
- *  are incorporated. This device drives LED and provides
- *  the intensity of light reflected from body.
- *
- *  For more information about BH1790GLC:
- *    http://www.rohm.com/web/global/datasheet/BH1790GLC/bh1790glc-e
- *    
- *  This was ported from Arduino library by H.Tanaka
- *    http://rohmfs.rohm.com/en/products/databook/applinote/ic/sensor/optical_sensor_for_heart_rate_monitor/bh1790glc-evk-001-manual-e.pdf
- *    http://rohmfs.rohm.com/en/products/databook/applinote/ic/sensor/optical_sensor_for_heart_rate_monitor/bh1790glc-software-manual-e.pdf
- */
-
-class BH1790GLC
-{
-public:
-    /** Create a BH1790GLC instance connected to specified I2C pins with specified address
-     *
-     * @param sda I2C-bus SDA pin
-     * @param scl I2C-bus SCL pin
-     * @param i2c_address I2C-bus address (default: 0x5B<<1)
-     */
-    BH1790GLC(PinName sda, PinName scl, char address = BH1790GLC_DEVICE_ADDRESS);
-    /** Create a BH1790GLC instance connected to specified I2C object with specified address
-    *
-    * @param i2c_obj I2C object (instance)
-    * @param i2c_address I2C-bus address (default: 0x5B<<1)
-    */
-    BH1790GLC(I2C &i2c_obj, char address = BH1790GLC_DEVICE_ADDRESS);
-    /** Destructor of BH1790GLC
-     */
-    ~BH1790GLC();
-
-    void init(void);
-    int meas_start(void);
-    int get_rawval(char *data);
-    int get_val(unsigned short *data);
-    int write(char memory_address,char *data,int size);
-    int read(char memory_address,char *data, int size);
-private:
-    I2C *i2c_p;
-    I2C &i2c;
-    char adr;
-};
-#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bh1790glc.cpp	Fri Jun 16 11:56:37 2017 +0000
@@ -0,0 +1,121 @@
+/*
+The MIT License (MIT)
+Copyright (c) 2017 Rohm Semiconductor
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+
+#include "RegisterWriter/RegisterWriter/rohm_hal2.h"
+#include "RegisterWriter/RegisterWriter/RegisterWriter.h"
+
+#include "rohm-bh1790glc-driver/bh1790glc_registers.h"
+#include "rohm-bh1790glc-driver/bh1790glc.h"
+
+BH1790GLC::BH1790GLC(RegisterWriter &i2c_obj, uint8_t sad, uint8_t wai) : i2c_rw(i2c_obj) {
+    /* Note that bh1790glc writes need to be single write command, not two separate. */
+    _sad = sad;
+    _wai = wai;        
+}
+
+BH1790GLC::~BH1790GLC()
+{
+}
+
+/* Check if sensor is found and setup default configuration for default measurements
+ *
+ * @return error true/false
+ */
+int BH1790GLC::set_default_on(void)
+{
+    int error;
+    uint8_t id;
+    uint8_t part_id;
+    uint8_t setup[3];
+
+    error = i2c_rw.read_register(_sad, BH1790GLC_PART_ID, &part_id, 1);
+    error = error || i2c_rw.read_register(_sad, BH1790GLC_MANUFACTURER_ID, &id, 1);
+    if (error) {
+        DEBUG_printf("read error.\r\n");
+        return (error);
+    }
+
+    if (part_id != BH1790GLC_PART_ID_WIA_ID) {
+        DEBUG_printf("PartID [%02X] doesn't match BH1790GLC.\r\n", part_id);
+    } else {
+        DEBUG_printf("PartID [%02X] OK.\r\n", part_id);
+    }
+
+    if (id != BH1790GLC_MID_VAL) {
+        DEBUG_printf("Manufacturer id [%02X] doesn't match!\r\n", id);
+    } else {
+        DEBUG_printf("Manufacturer id [%02X] OK.\r\n", id);
+    }
+
+    setup[0] = (BH1790GLC_MEAS_CONTROL1_RDY_ENABLE | BH1790GLC_MEAS_CONTROL1_LED_LIGHTING_FREQ_128HZ | BH1790GLC_MEAS_CONTROL1_RCYCLE_32HZ);
+    setup[1] = (BH1790GLC_MEAS_CONTROL2_LED1_EN_PULSED | BH1790GLC_MEAS_CONTROL2_LED_ON_TIME_216T_OSC | BH1790GLC_MEAS_CONTROL2_LED_CURRENT_10MA);
+    setup[2] = BH1790GLC_MEAS_START_MEAS_ST_START;
+    error = i2c_rw.write_register(_sad, BH1790GLC_MEAS_CONTROL1, setup, (uint8_t)sizeof(setup));
+    if (error) {
+        DEBUG_printf("BH1790GLC_MEAS_CONTROL1 write failed.\r\n");
+    }
+
+    return (error);
+}
+/*
+ * @return error true/false
+ */
+int BH1790GLC::getresults_raw(uint8_t *data)
+{
+    return i2c_rw.read_register(_sad, BH1790GLC_DATAOUT_LEDOFF_L, data, 4);
+}
+
+/*
+ * @return error true/false
+ */
+int BH1790GLC::getresults(uint16_t *data)
+{
+    int error;
+    uint8_t val[4];
+
+    error = getresults_raw(val);
+    if (error) {
+        return error;
+    }
+    data[0] = ((unsigned short)val[1] << 8) | (val[0]);
+    data[1] = ((unsigned short)val[3] << 8) | (val[2]);
+
+    return false;
+}
+
+//int BH1790GLC::write(char memory_address, char *data, int size)
+//{
+//   int rc;
+//    rc = i2c_rw.write_register(_sad, memory_address, data, size );
+//    return !rc;
+//}
+//
+//int BH1790GLC::read(uint8_t memory_address, uint8_t *data, uint8_t size)
+//{
+//    int rc;
+//    rc = i2c_rw.read_register(_sad, memory_address, data, size);
+//    
+//    return !rc;
+//}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bh1790glc.h	Fri Jun 16 11:56:37 2017 +0000
@@ -0,0 +1,83 @@
+/*
+The MIT License (MIT)
+Copyright (c) 2017 Rohm Semiconductor
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef _BH1790GLC_H_
+#define _BH1790GLC_H_
+
+#include "RegisterWriter/RegisterWriter/rohm_hal2.h"
+#include "RegisterWriter/RegisterWriter/RegisterWriter.h"
+
+#include "bh1790glc_registers.h"
+#define BH1790GLC_DEFAULT_SLAVE_ADDRESS (0x5B)
+
+#define BH1790GLC_DEVICE_ADDRESS      (BH1790GLC_DEFAULT_SLAVE_ADDRESS<<1)
+#define BH1790GLC_MID_VAL             (0xE0)
+
+#include "mbed.h"
+
+/** BH1790GLC class
+ *
+ *  BH1790GLC: an I2C bus optical sensor for heart rate monitor library
+ *
+ *  BH1790GLC is optical sensor for heart rate monitor IC in
+ *  which LED driver and green light detection photo-diode
+ *  are incorporated. This device drives LED and provides
+ *  the intensity of light reflected from body.
+ *
+ *  For more information about BH1790GLC:
+ *    http://www.rohm.com/web/global/datasheet/BH1790GLC/bh1790glc-e
+ *    
+ *    http://rohmfs.rohm.com/en/products/databook/applinote/ic/sensor/optical_sensor_for_heart_rate_monitor/bh1790glc-evk-001-manual-e.pdf
+ *    http://rohmfs.rohm.com/en/products/databook/applinote/ic/sensor/optical_sensor_for_heart_rate_monitor/bh1790glc-software-manual-e.pdf
+ *
+ *  This was ported from Arduino library by H.Tanaka and rewritten to match other Rohm mbed drivers by M.Koivunen.
+ */
+
+class BH1790GLC
+{
+public:
+    /** Create a BH1790GLC instance connected to specified I2C object with specified address
+    *
+    * @param i2c_obj RegisterWriter object (instance)
+    * @param sad I2C-bus address
+    * @param wai Who Am I -value
+    */
+    BH1790GLC(RegisterWriter &i2c_obj, uint8_t sad = BH1790GLC_DEFAULT_SLAVE_ADDRESS, uint8_t wai = BH1790GLC_PART_ID_WIA_ID);
+
+    /** Destructor of BH1790GLC
+     */
+    ~BH1790GLC();
+
+    void init(void);
+    int set_default_on(void);
+    int getresults_raw(uint8_t *data);
+    int getresults(uint16_t *data);
+    //int write(uint8_t memory_address,uint8_t *data,uint8_t size);
+    //int read(uint8_t memory_address,uint8_t *data, uint8_t size);
+private:
+    RegisterWriter i2c_rw;
+    uint8_t _sad;
+    uint8_t _wai;
+};
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bh1790glc_registers.h	Fri Jun 16 11:56:37 2017 +0000
@@ -0,0 +1,94 @@
+/*
+The MIT License (MIT)
+Copyright (c) 2017 Rohm Semiconductor
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef __BH1790GLC_REGISTERS_H__
+#define __BH1790GLC_REGISTERS_H__
+/* registers */
+#define BH1790GLC_REGISTER_DUMP_START 0x0F
+#define BH1790GLC_MANUFACTURER_ID 0x0F
+#define BH1790GLC_PART_ID 0x10
+// Soft reset
+#define BH1790GLC_RESET 0x40
+// System control setting
+#define BH1790GLC_MEAS_CONTROL1 0x41
+// Measurement control setting
+#define BH1790GLC_MEAS_CONTROL2 0x42
+// Measurement start
+#define BH1790GLC_MEAS_START 0x43
+#define BH1790GLC_DATAOUT_LEDOFF_L 0x54
+#define BH1790GLC_DATAOUT_LEDOFF_H 0x55
+#define BH1790GLC_DATAOUT_LEDON_L 0x56
+// Restarts measurement.
+#define BH1790GLC_DATAOUT_LEDON_H 0x57
+#define BH1790GLC_REGISTER_DUMP_END 0x57
+/* registers bits */
+// WHO_AM_I -value
+#define BH1790GLC_PART_ID_WIA_ID (0x0D << 0)
+// 1 : Software reset is performed
+#define BH1790GLC_RESET_SWRESET (0x01 << 7)
+// OSC block is inactive
+#define BH1790GLC_MEAS_CONTROL1_RDY_DISABLE (0x00 << 7)
+// OSC block is active
+#define BH1790GLC_MEAS_CONTROL1_RDY_ENABLE (0x01 << 7)
+#define BH1790GLC_MEAS_CONTROL1_LED_LIGHTING_FREQ_128HZ (0x00 << 2)
+#define BH1790GLC_MEAS_CONTROL1_LED_LIGHTING_FREQ_64HZ (0x01 << 2)
+#define BH1790GLC_MEAS_CONTROL1_RCYCLE_PROHIBITED1 (0x00 << 0)
+#define BH1790GLC_MEAS_CONTROL1_RCYCLE_64HZ (0x01 << 0)
+#define BH1790GLC_MEAS_CONTROL1_RCYCLE_32HZ (0x02 << 0)
+#define BH1790GLC_MEAS_CONTROL1_RCYCLE_PROHIBITED2 (0x03 << 0)
+#define BH1790GLC_MEAS_CONTROL2_LED2_EN_PULSED (0x00 << 7)
+#define BH1790GLC_MEAS_CONTROL2_LED2_EN_CONSTANT (0x01 << 7)
+#define BH1790GLC_MEAS_CONTROL2_LED1_EN_PULSED (0x00 << 6)
+#define BH1790GLC_MEAS_CONTROL2_LED1_EN_CONSTANT (0x01 << 6)
+// us
+#define BH1790GLC_MEAS_CONTROL2_LED_ON_TIME_216T_OSC (0x00 << 5)
+// us
+#define BH1790GLC_MEAS_CONTROL2_LED_ON_TIME_432T_OSC (0x01 << 5)
+#define BH1790GLC_MEAS_CONTROL2_LED_CURRENT_0MA (0x00 << 0)
+#define BH1790GLC_MEAS_CONTROL2_LED_CURRENT_1MA (0x08 << 0)
+#define BH1790GLC_MEAS_CONTROL2_LED_CURRENT_2MA (0x09 << 0)
+#define BH1790GLC_MEAS_CONTROL2_LED_CURRENT_3MA (0x0A << 0)
+#define BH1790GLC_MEAS_CONTROL2_LED_CURRENT_6MA (0x0B << 0)
+#define BH1790GLC_MEAS_CONTROL2_LED_CURRENT_10MA (0x0C << 0)
+#define BH1790GLC_MEAS_CONTROL2_LED_CURRENT_20MA (0x0D << 0)
+#define BH1790GLC_MEAS_CONTROL2_LED_CURRENT_30MA (0x0E << 0)
+#define BH1790GLC_MEAS_CONTROL2_LED_CURRENT_60MA (0x0F << 0)
+#define BH1790GLC_MEAS_START_MEAS_ST_STOP (0x00 << 0)
+#define BH1790GLC_MEAS_START_MEAS_ST_START (0x01 << 0)
+ /*registers bit masks */
+#define BH1790GLC_PART_ID_WIA_MASK 0xFF
+// 1 : OSC block is active
+#define BH1790GLC_MEAS_CONTROL1_RDY_MASK 0x80
+// Select LED omitting frequency
+#define BH1790GLC_MEAS_CONTROL1_LED_LIGHTING_FREQ_MASK 0x04
+#define BH1790GLC_MEAS_CONTROL1_RCYCLE_MASK 0x03
+#define BH1790GLC_MEAS_CONTROL2_LED2_EN_MASK 0x80
+#define BH1790GLC_MEAS_CONTROL2_LED1_EN_MASK 0x40
+#define BH1790GLC_MEAS_CONTROL2_LED_ON_TIME_MASK 0x20
+// LED lighting current
+#define BH1790GLC_MEAS_CONTROL2_LED_CURRENT_MASK 0x0F
+#define BH1790GLC_MEAS_START_MEAS_ST_MASK 0x01
+#endif
+
+