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

Committer:
MikkoZ
Date:
Fri Jun 16 11:56:37 2017 +0000
Revision:
1:32bb2624bed8
Child:
2:4446bf1de21b
Initial version of bh1790glc driver; ; Tested ok with bh1790glc-hello

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