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