Measuring plethysmogram with BH1792GLC (Rohm Semiconductor) and calculating pulse rate

Dependencies:   USBDevice mbed

Committer:
t_tatsuoka
Date:
Mon Feb 05 21:28:19 2018 +0000
Revision:
1:90f70c146a26
Parent:
0:18d735a66926
Ver. 1.0.1 ???beep?????????????????????????

Who changed what in which revision?

UserRevisionLine numberNew contents of line
t_tatsuoka 0:18d735a66926 1 /**
t_tatsuoka 0:18d735a66926 2 * @file Bh1792glcReg.h
t_tatsuoka 0:18d735a66926 3 * @brief BH1792GLC registers.
t_tatsuoka 0:18d735a66926 4 * Ported from Rohm Semiconductor Arduino library.
t_tatsuoka 0:18d735a66926 5 * @date 2018.02.03
t_tatsuoka 0:18d735a66926 6 * @version 1.0.0
t_tatsuoka 0:18d735a66926 7 */
t_tatsuoka 0:18d735a66926 8 #ifndef _INC_Bh1792glcReg
t_tatsuoka 0:18d735a66926 9 #define _INC_Bh1792glcReg
t_tatsuoka 0:18d735a66926 10
t_tatsuoka 0:18d735a66926 11 /* registers */
t_tatsuoka 0:18d735a66926 12
t_tatsuoka 0:18d735a66926 13 // Error Codes
t_tatsuoka 0:18d735a66926 14 #define BH1792_SUCCESS (0) // BH1792 operation is successful
t_tatsuoka 0:18d735a66926 15 #define BH1792_I2C_ERR (-1) // I2C error with BH1792
t_tatsuoka 0:18d735a66926 16 #define BH1792_NOT_EXIST (-2) // BH1792 does not exist
t_tatsuoka 0:18d735a66926 17 #define BH1792_FIFO_FULL (-3) // BH1792 FIFO is full
t_tatsuoka 0:18d735a66926 18
t_tatsuoka 0:18d735a66926 19 // Slave Address
t_tatsuoka 0:18d735a66926 20 #define BH1792_SLAVE_ADDR (0x5BU) // 7bit Slave Address
t_tatsuoka 0:18d735a66926 21
t_tatsuoka 0:18d735a66926 22 // Register Address
t_tatsuoka 0:18d735a66926 23 #define BH1792_ADDR_MANUFACTURERID (0x0FU) // R : Manufacturer ID
t_tatsuoka 0:18d735a66926 24 #define BH1792_ADDR_PARTID (0x10U) // R : PART ID
t_tatsuoka 0:18d735a66926 25 #define BH1792_ADDR_RESET (0x40U) // R/W : RESET
t_tatsuoka 0:18d735a66926 26 #define BH1792_ADDR_MEAS_CTRL1 (0x41U) // R/W : Measurement Control1
t_tatsuoka 0:18d735a66926 27 #define BH1792_ADDR_MEAS_CTRL2 (0x42U) // R/W : Measurement Control2
t_tatsuoka 0:18d735a66926 28 #define BH1792_ADDR_MEAS_CTRL3 (0x43U) // R/W : Measurement Control3
t_tatsuoka 0:18d735a66926 29 #define BH1792_ADDR_MEAS_CTRL4_LSBS (0x44U) // R/W : Lower byte of Measurement Control4
t_tatsuoka 0:18d735a66926 30 #define BH1792_ADDR_MEAS_CTRL4_MSBS (0x45U) // R/W : Upper byte of Measurement Control4
t_tatsuoka 0:18d735a66926 31 #define BH1792_ADDR_MEAS_CTRL5 (0x46U) // R/W : Measurement Control5
t_tatsuoka 0:18d735a66926 32 #define BH1792_ADDR_MEAS_START (0x47U) // R/W : Measurement Start
t_tatsuoka 0:18d735a66926 33 #define BH1792_ADDR_MEAS_SYNC (0x48U) // W : Measurement Synchronization
t_tatsuoka 0:18d735a66926 34 #define BH1792_ADDR_FIFO_LEV (0x4BU) // R : FIFO Level
t_tatsuoka 0:18d735a66926 35 #define BH1792_ADDR_FIFO_DATA0_LSBS (0x4CU) // R : Lower byte of FIFO Data0
t_tatsuoka 0:18d735a66926 36 #define BH1792_ADDR_FIFO_DATA0_MSBS (0x4DU) // R : Upper byte of FIFO Data0
t_tatsuoka 0:18d735a66926 37 #define BH1792_ADDR_FIFO_DATA1_LSBS (0x4EU) // R : Lower byte of FIFO Data1
t_tatsuoka 0:18d735a66926 38 #define BH1792_ADDR_FIFO_DATA1_MSBS (0x4FU) // R : Upper byte of FIFO Data1
t_tatsuoka 0:18d735a66926 39 #define BH1792_ADDR_IRDATA_LEDOFF_LSBS (0x50U) // R : Lower byte of IRDATA LEDOFF
t_tatsuoka 0:18d735a66926 40 #define BH1792_ADDR_IRDATA_LEDOFF_MSBS (0x51U) // R : Upper byte of IRDATA LEDOFF
t_tatsuoka 0:18d735a66926 41 #define BH1792_ADDR_IRDATA_LEDON_LSBS (0x52U) // R : Lower byte of IRDATA LEDON
t_tatsuoka 0:18d735a66926 42 #define BH1792_ADDR_IRDATA_LEDON_MSBS (0x53U) // R : Upper byte of IRDATA LEDON
t_tatsuoka 0:18d735a66926 43 #define BH1792_ADDR_GDATA_LEDOFF_LSBS (0x54U) // R : Lower byte of GDATA LEDOFF
t_tatsuoka 0:18d735a66926 44 #define BH1792_ADDR_GDATA_LEDOFF_MSBS (0x55U) // R : Upper byte of GDATA LEDOFF
t_tatsuoka 0:18d735a66926 45 #define BH1792_ADDR_GDATA_LEDON_LSBS (0x56U) // R : Lower byte of GDATA LEDON
t_tatsuoka 0:18d735a66926 46 #define BH1792_ADDR_GDATA_LEDON_MSBS (0x57U) // R : Upper byte of GDATA LEDON
t_tatsuoka 0:18d735a66926 47 #define BH1792_ADDR_INT_CLEAR (0x58U) // R : Interrupt Clear
t_tatsuoka 0:18d735a66926 48
t_tatsuoka 0:18d735a66926 49 // Register Parameters
t_tatsuoka 0:18d735a66926 50 // MANUFACTURER ID (0Fh)
t_tatsuoka 0:18d735a66926 51 #define BH1792_PRM_MANUFACTURERID (0xE0U)
t_tatsuoka 0:18d735a66926 52
t_tatsuoka 0:18d735a66926 53 // PART ID (10h)
t_tatsuoka 0:18d735a66926 54 #define BH1792_PRM_PARTID (0x0EU)
t_tatsuoka 0:18d735a66926 55
t_tatsuoka 0:18d735a66926 56 // RESET (40h)
t_tatsuoka 0:18d735a66926 57 // 7bit: SWRESET
t_tatsuoka 0:18d735a66926 58 #define BH1792_PRM_SWRESET (0x01U) // Software reset is performed
t_tatsuoka 0:18d735a66926 59
t_tatsuoka 0:18d735a66926 60 // MEAS_CTRL1 (41h)
t_tatsuoka 0:18d735a66926 61 // 7bit: RDY
t_tatsuoka 0:18d735a66926 62 #define BH1792_PRM_RDY (0x01U) // OSC block is active
t_tatsuoka 0:18d735a66926 63 // 6bit: SEL_LED
t_tatsuoka 0:18d735a66926 64 #define BH1792_PRM_SEL_LED (0x00U) // LED1=Green, LED2=Green, LED3=IR
t_tatsuoka 0:18d735a66926 65 // 4bit: SEL_ADC
t_tatsuoka 0:18d735a66926 66 #define BH1792_PRM_SEL_ADC_GREEN (0x00U) // ADC1=Green
t_tatsuoka 0:18d735a66926 67 #define BH1792_PRM_SEL_ADC_IR (0x01U) // ADC2=IR
t_tatsuoka 0:18d735a66926 68 // 2-0bit: MSR
t_tatsuoka 0:18d735a66926 69 #define BH1792_PRM_MSR_32HZ (0x00U) // LED_Freq= 128Hz, OUTPUT_Freq= 32Hz, FIFO=Stored
t_tatsuoka 0:18d735a66926 70 #define BH1792_PRM_MSR_128HZ (0x01U) // LED_Freq= 128Hz, OUTPUT_Freq= 128Hz, FIFO=Stored
t_tatsuoka 0:18d735a66926 71 #define BH1792_PRM_MSR_64HZ (0x02U) // LED_Freq= 256Hz, OUTPUT_Freq= 64Hz, FIFO=Stored
t_tatsuoka 0:18d735a66926 72 #define BH1792_PRM_MSR_256HZ (0x03U) // LED_Freq= 256Hz, OUTPUT_Freq= 256Hz, FIFO=Stored
t_tatsuoka 0:18d735a66926 73 #define BH1792_PRM_MSR_1024HZ (0x05U) // LED_Freq=1024Hz, OUTPUT_Freq=1024Hz, FIFO=Stored
t_tatsuoka 0:18d735a66926 74 #define BH1792_PRM_MSR_NON_SYNC (0x06U) // LED_Freq= 4Hz, OUTPUT_Freq= 4Hz, FIFO=Not Stored
t_tatsuoka 0:18d735a66926 75 #define BH1792_PRM_MSR_SINGLE (0x07U) // LED_Freq= -Hz, OUTPUT_Freq= -Hz, FIFO=Not Stored
t_tatsuoka 0:18d735a66926 76
t_tatsuoka 0:18d735a66926 77 // MEAS_CTRL2 (42h)
t_tatsuoka 0:18d735a66926 78 // 7-6bit: LED_EN1
t_tatsuoka 0:18d735a66926 79 #define BH1792_PRM_LED_EN1_0 (0x00U) // Selection of LED Driver Mode
t_tatsuoka 0:18d735a66926 80 #define BH1792_PRM_LED_EN1_1 (0x01U)
t_tatsuoka 0:18d735a66926 81 #define BH1792_PRM_LED_EN1_2 (0x02U)
t_tatsuoka 0:18d735a66926 82 #define BH1792_PRM_LED_EN1_3 (0x03U)
t_tatsuoka 0:18d735a66926 83 // 5-0bit: LED_CURRENT1
t_tatsuoka 0:18d735a66926 84 #define BH1792_PRM_LED_CUR1_MIN (0x00U) // LED1 MIN Current : 0mA
t_tatsuoka 0:18d735a66926 85 #define BH1792_PRM_LED_CUR1_MAX (0x3FU) // LED1 MAX Current : 63mA
t_tatsuoka 0:18d735a66926 86 #define BH1792_PRM_LED_CUR1_MA(x) (x) // LED1 Current Range: 0-63mA
t_tatsuoka 0:18d735a66926 87
t_tatsuoka 0:18d735a66926 88 // MEAS_CTRL3 (43h)
t_tatsuoka 0:18d735a66926 89 // 7bit: LED_EN2
t_tatsuoka 0:18d735a66926 90 #define BH1792_PRM_LED_EN2_0 (0x00U) // Selection of LED Driver Mode
t_tatsuoka 0:18d735a66926 91 #define BH1792_PRM_LED_EN2_1 (0x01U)
t_tatsuoka 0:18d735a66926 92 // 5-0bit: LED_CURRENT2
t_tatsuoka 0:18d735a66926 93 #define BH1792_PRM_LED_CUR2_MIN (0x00U) // LED2 MIN Current : 0mA
t_tatsuoka 0:18d735a66926 94 #define BH1792_PRM_LED_CUR2_MAX (0x3FU) // LED2 MAX Current : 63mA
t_tatsuoka 0:18d735a66926 95 #define BH1792_PRM_LED_CUR2_MA(x) (x) // LED2 Current Range: 0-63mA
t_tatsuoka 0:18d735a66926 96
t_tatsuoka 0:18d735a66926 97 // MEAS_CTRL5 (46h)
t_tatsuoka 0:18d735a66926 98 // 1-0bit: INT_SEL
t_tatsuoka 0:18d735a66926 99 #define BH1792_PRM_INT_SEL_DISABLE (0x00U) // No interrupt
t_tatsuoka 0:18d735a66926 100 #define BH1792_PRM_INT_SEL_WTM (0x01U) // FIFO watermark interrupt
t_tatsuoka 0:18d735a66926 101 #define BH1792_PRM_INT_SEL_IR (0x02U) // IR Threshold interrupt of Non-Sync Measurement Mode
t_tatsuoka 0:18d735a66926 102 #define BH1792_PRM_INT_SEL_SGL (0x03U) // Completion interrupt of Single Measurement Mode
t_tatsuoka 0:18d735a66926 103
t_tatsuoka 0:18d735a66926 104 // MEAS_START (47h)
t_tatsuoka 0:18d735a66926 105 // 0bit: MEAS_ST
t_tatsuoka 0:18d735a66926 106 #define BH1792_PRM_MEAS_ST (0x01U) // Measurement start
t_tatsuoka 0:18d735a66926 107
t_tatsuoka 0:18d735a66926 108 // MEAS_SYNC (48h)
t_tatsuoka 0:18d735a66926 109 // 0bit: MEAS_SYNC
t_tatsuoka 0:18d735a66926 110 #define BH1792_PRM_MEAS_SYNC (0x01U) // Measurement synchronization
t_tatsuoka 0:18d735a66926 111
t_tatsuoka 0:18d735a66926 112 // FIFO_LEVEL (4Bh)
t_tatsuoka 0:18d735a66926 113 // 5-0bit: FIFO_LEV
t_tatsuoka 0:18d735a66926 114 #define BH1792_PRM_FIFO_LEV_EMPTY (0x00U) // FIFO Length = 0 (Empty)
t_tatsuoka 0:18d735a66926 115 #define BH1792_PRM_FIFO_LEV_WTM (0x20U) // FIFO Length = 32 (Watermark)
t_tatsuoka 0:18d735a66926 116 #define BH1792_PRM_FIFO_LEV_FULL (0x23U) // FIFO Length = 35 (Full)
t_tatsuoka 0:18d735a66926 117
t_tatsuoka 0:18d735a66926 118 #endif /* INC_Bh1792glcReg */