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_H_
ThunderSoft 1:e9033991d204 26 #define _BH1790GLC_H_
ThunderSoft 1:e9033991d204 27
ThunderSoft 1:e9033991d204 28
ThunderSoft 1:e9033991d204 29 #include "bh1790glc_registers.h"
ThunderSoft 1:e9033991d204 30 #define BH1790GLC_DEFAULT_SLAVE_ADDRESS (0x5B)
ThunderSoft 1:e9033991d204 31 #define BH1790GLC_MID_VAL (0xE0)
ThunderSoft 1:e9033991d204 32
ThunderSoft 1:e9033991d204 33 #include "mbed.h"
ThunderSoft 1:e9033991d204 34 #include "RegisterWriter.h"
ThunderSoft 1:e9033991d204 35
ThunderSoft 1:e9033991d204 36 /** BH1790GLC class
ThunderSoft 1:e9033991d204 37 *
ThunderSoft 1:e9033991d204 38 * BH1790GLC: an I2C bus optical sensor for heart rate monitor library
ThunderSoft 1:e9033991d204 39 *
ThunderSoft 1:e9033991d204 40 * BH1790GLC is optical sensor for heart rate monitor IC in
ThunderSoft 1:e9033991d204 41 * which LED driver and green light detection photo-diode
ThunderSoft 1:e9033991d204 42 * are incorporated. This device drives LED and provides
ThunderSoft 1:e9033991d204 43 * the intensity of light reflected from body.
ThunderSoft 1:e9033991d204 44 *
ThunderSoft 1:e9033991d204 45 * For more information about BH1790GLC:
ThunderSoft 1:e9033991d204 46 * http://www.rohm.com/web/global/datasheet/BH1790GLC/bh1790glc-e
ThunderSoft 1:e9033991d204 47 *
ThunderSoft 1:e9033991d204 48 * http://rohmfs.rohm.com/en/products/databook/applinote/ic/sensor/optical_sensor_for_heart_rate_monitor/bh1790glc-evk-001-manual-e.pdf
ThunderSoft 1:e9033991d204 49 * http://rohmfs.rohm.com/en/products/databook/applinote/ic/sensor/optical_sensor_for_heart_rate_monitor/bh1790glc-software-manual-e.pdf
ThunderSoft 1:e9033991d204 50 *
ThunderSoft 1:e9033991d204 51 * This was ported from Arduino library by H.Tanaka and rewritten to match other Rohm mbed drivers by M.Koivunen.
ThunderSoft 1:e9033991d204 52 */
ThunderSoft 1:e9033991d204 53
ThunderSoft 1:e9033991d204 54 class BH1790GLC
ThunderSoft 1:e9033991d204 55 {
ThunderSoft 1:e9033991d204 56 public:
ThunderSoft 1:e9033991d204 57 /** Create a BH1790GLC instance connected to specified I2C object with specified address
ThunderSoft 1:e9033991d204 58 *
ThunderSoft 1:e9033991d204 59 * @param i2c_obj RegisterWriter object (instance)
ThunderSoft 1:e9033991d204 60 * @param sad I2C-bus address
ThunderSoft 1:e9033991d204 61 * @param wai Who Am I -value
ThunderSoft 1:e9033991d204 62 */
ThunderSoft 1:e9033991d204 63 BH1790GLC(RegisterWriter &i2c_obj, uint8_t sad = BH1790GLC_DEFAULT_SLAVE_ADDRESS, uint8_t wai = BH1790GLC_PART_ID_WIA_ID);
ThunderSoft 1:e9033991d204 64
ThunderSoft 1:e9033991d204 65 /** Destructor of BH1790GLC
ThunderSoft 1:e9033991d204 66 */
ThunderSoft 1:e9033991d204 67 ~BH1790GLC();
ThunderSoft 1:e9033991d204 68
ThunderSoft 1:e9033991d204 69 void init(void);
ThunderSoft 1:e9033991d204 70 int set_default_on(void);
ThunderSoft 1:e9033991d204 71 int getresults_raw(uint8_t *data);
ThunderSoft 1:e9033991d204 72 int getresults(uint16_t *data);
ThunderSoft 1:e9033991d204 73
ThunderSoft 1:e9033991d204 74 uint8_t getDeviceID();
ThunderSoft 1:e9033991d204 75 //int write(uint8_t memory_address,uint8_t *data,uint8_t size);
ThunderSoft 1:e9033991d204 76 //int read(uint8_t memory_address,uint8_t *data, uint8_t size);
ThunderSoft 1:e9033991d204 77 private:
ThunderSoft 1:e9033991d204 78 RegisterWriter i2c_rw;
ThunderSoft 1:e9033991d204 79 uint8_t _sad;
ThunderSoft 1:e9033991d204 80 uint8_t _wai;
ThunderSoft 1:e9033991d204 81 };
ThunderSoft 1:e9033991d204 82 #endif