Thundersoft / Mbed OS BH1790GLC_for_TTMxx
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers bh1790glc.h Source File

bh1790glc.h

00001 /*
00002 The MIT License (MIT)
00003 Copyright (c) 2017 Rohm Semiconductor
00004 
00005 Permission is hereby granted, free of charge, to any person obtaining a
00006 copy of this software and associated documentation files (the
00007 "Software"), to deal in the Software without restriction, including
00008 without limitation the rights to use, copy, modify, merge, publish,
00009 distribute, sublicense, and/or sell copies of the Software, and to
00010 permit persons to whom the Software is furnished to do so, subject to
00011 the following conditions:
00012 
00013 The above copyright notice and this permission notice shall be included
00014 in all copies or substantial portions of the Software.
00015 
00016 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00017 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00018 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00019 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
00020 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
00021 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
00022 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00023 */
00024 
00025 #ifndef _BH1790GLC_H_
00026 #define _BH1790GLC_H_
00027 
00028 
00029 #include "bh1790glc_registers.h"
00030 #define BH1790GLC_DEFAULT_SLAVE_ADDRESS (0x5B)
00031 #define BH1790GLC_MID_VAL               (0xE0)
00032 
00033 #include "mbed.h"
00034 #include "RegisterWriter.h"
00035 
00036 /** BH1790GLC class
00037  *
00038  *  BH1790GLC: an I2C bus optical sensor for heart rate monitor library
00039  *
00040  *  BH1790GLC is optical sensor for heart rate monitor IC in
00041  *  which LED driver and green light detection photo-diode
00042  *  are incorporated. This device drives LED and provides
00043  *  the intensity of light reflected from body.
00044  *
00045  *  For more information about BH1790GLC:
00046  *    http://www.rohm.com/web/global/datasheet/BH1790GLC/bh1790glc-e
00047  *    
00048  *    http://rohmfs.rohm.com/en/products/databook/applinote/ic/sensor/optical_sensor_for_heart_rate_monitor/bh1790glc-evk-001-manual-e.pdf
00049  *    http://rohmfs.rohm.com/en/products/databook/applinote/ic/sensor/optical_sensor_for_heart_rate_monitor/bh1790glc-software-manual-e.pdf
00050  *
00051  *  This was ported from Arduino library by H.Tanaka and rewritten to match other Rohm mbed drivers by M.Koivunen.
00052  */
00053 
00054 class BH1790GLC
00055 {
00056 public:
00057     /** Create a BH1790GLC instance connected to specified I2C object with specified address
00058     *
00059     * @param i2c_obj RegisterWriter object (instance)
00060     * @param sad I2C-bus address
00061     * @param wai Who Am I -value
00062     */
00063     BH1790GLC(RegisterWriter &i2c_obj, uint8_t sad = BH1790GLC_DEFAULT_SLAVE_ADDRESS, uint8_t wai = BH1790GLC_PART_ID_WIA_ID);
00064 
00065     /** Destructor of BH1790GLC
00066      */
00067     ~BH1790GLC();
00068 
00069     void init(void);
00070     int set_default_on(void);
00071     int getresults_raw(uint8_t *data);
00072     int getresults(uint16_t *data);
00073 
00074     uint8_t getDeviceID();
00075     //int write(uint8_t memory_address,uint8_t *data,uint8_t size);
00076     //int read(uint8_t memory_address,uint8_t *data, uint8_t size);
00077 private:
00078     RegisterWriter i2c_rw;
00079     uint8_t _sad;
00080     uint8_t _wai;
00081 };
00082 #endif