upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
max30100_regs.h
1 /*
2  * Author: Noel Eck <noel.eck@intel.com>
3  * Copyright (c) 2015 Intel Corporation.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining
6  * a copy of this software and associated documentation files (the
7  * "Software"), to deal in the Software without restriction, including
8  * without limitation the rights to use, copy, modify, merge, publish,
9  * distribute, sublicense, and/or sell copies of the Software, and to
10  * permit persons to whom the Software is furnished to do so, subject to
11  * the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be
14  * included in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24 
25 #pragma once
26 
27 #include <stdint.h>
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 #define MAX30100_I2C_ADDRESS 0x57
34 
35 /* Single IR/R sample */
36 typedef struct {
37  /* Raw IR (pulse) read value */
38  uint16_t IR;
39  /* Raw R (O2) read value */
40  uint16_t R;
42 
43 /* Function pointer for returning 1 IR/R sample */
44 typedef void (*func_sample_ready_handler)(max30100_value sample, void* arg);
45 
46 /* Sample state */
47 typedef enum {
48  /* NOT sampling */
49  MAX30100_SAMPLE_STATE_IDLE,
50  /* Take one sample/currently taking one sample */
51  MAX30100_SAMPLE_STATE_ONE_SHOT,
52  /* Sample continuously/currently sampling continuously */
53  MAX30100_SAMPLE_STATE_CONTINUOUS,
54  /* Sample continuously using buffer/currently sampling continuously using buffer*/
55  MAX30100_SAMPLE_STATE_CONTINUOUS_BUFFERED
56 } MAX30100_SAMPLE_STATE;
57 
58 /* Pulse oximeter and heart-rate sensor I2C registers */
59 typedef enum {
60  /* Interrupt status (RO) */
61  MAX30100_REG_INTERRUPT_STATUS = 0x00,
62  /* Interrupt enable */
63  MAX30100_REG_INTERRUPT_ENABLE = 0x01,
64  /* FIFO write pointer */
65  MAX30100_REG_FIFO_WR_PTR = 0x02,
66  /* FIFO overflow counter */
67  MAX30100_REG_FIFO_OVF_COUNTER = 0x03,
68  /* FIFO read pointer */
69  MAX30100_REG_FIFO_RD_PTR = 0x04,
70  /* FIFO data */
71  MAX30100_REG_FIFO_DATA = 0x05,
72  /* Mode configuration */
73  MAX30100_REG_MODE_CONFIG = 0x06,
74  /* SPO2 configuration */
75  MAX30100_REG_SPO2_CONFIG = 0x07,
76  /* LED configuration */
77  MAX30100_REG_LED_CONFIG = 0x09,
78  /* Temperature integer (2's compliment) */
79  MAX30100_REG_TEMP_INTEGER = 0x16,
80  /* Temperature fraction) */
81  MAX30100_REG_TEMP_FRACTION = 0x17,
82  /* Revision ID (RO)*/
83  MAX30100_REG_REV_ID = 0xFE,
84  /* Part ID */
85  MAX30100_REG_PART_ID = 0xFF
86 } MAX30100_REG;
87 
88 /* MAX30100_REG_INTERRUPT_STATUS register fields */
89 /* FIFO almost full, set to 1 when WR_PTR == RD_PTR - 1 */
90 #define MAX30100_A_FULL (1 << 7)
91 /* Temperature date ready flag */
92 #define MAX30100_TEMP_RDY (1 << 6)
93 /* Heartrate data ready flag */
94 #define MAX30100_HR_RDY (1 << 5)
95 /* HR and O2 data ready flag */
96 #define MAX30100_SPO2_RDY (1 << 4)
97 /* Power ready after brownout flag */
98 #define MAX30100_PWR_RDY (1 << 0)
99 
100 /* MAX30100_REG_INTERRUPT_ENABLE register fields */
101 /* Enable interrupt on FIFO almost full */
102 #define MAX30100_EN_A_FULL (1 << 7)
103 /* Enable interrupt on temperature date ready */
104 #define MAX30100_EN_TEMP_RDY (1 << 6)
105 /* Enable interrupt on HR data ready */
106 #define MAX30100_EN_HR_RDY (1 << 5)
107 /* Enable interrupt on HR and O2 data ready */
108 #define MAX30100_EN_SPO2_RDY (1 << 4)
109 
110 /* MAX30100_REG_MODE_CONFIG register fields */
111 /* Enable power-save mode */
112 #define MAX30100_SHDN (1 << 7)
113 /* Reset device */
114 #define MAX30100_RESET (1 << 6)
115 /* Initiate temperature reading */
116 #define MAX30100_TEMP_EN (1 << 3)
117 /* Device sample mode (HR, vs SpO2) */
118 typedef enum _MAX30100_MODE {
119 /* Turn off sampling */
120  MAX30100_MODE_DISABLED = 0x00,
121 /* Enable heartrate ONLY sampling */
122  MAX30100_MODE_HR_EN = 0x02,
123 /* Enable SpO2 sampling */
124  MAX30100_MODE_SPO2_EN = 0x03
125 } MAX30100_MODE;
126 
127 /* MAX30100_REG_SPO2_CONFIG register fields */
128 #define MAX30100_SPO2_HI_RES_EN (1 << 6)
129 typedef enum _MAX30100_SR {
130  MAX30100_SR_50_HZ = 0x00,
131  MAX30100_SR_100_HZ = 0x01,
132  MAX30100_SR_167_HZ = 0x02,
133  MAX30100_SR_200_HZ = 0x03,
134  MAX30100_SR_400_HZ = 0x04,
135  MAX30100_SR_600_HZ = 0x05,
136  MAX30100_SR_900_HZ = 0x06,
137  MAX30100_SR_1000_HZ = 0x07
138 } MAX30100_SR;
139 /* LED pulse width (microseconds) */
140 typedef enum _MAX30100_LED_PW {
141  MAX30100_LED_PW_200_US_13_BITS = 0x00,
142  MAX30100_LED_PW_400_US_14_BITS = 0x01,
143  MAX30100_LED_PW_800_US_15_BITS = 0x02,
144  MAX30100_LED_PW_1600_US_16_BITS = 0x03
145 } MAX30100_LED_PW;
146 
147 /* MAX30100_REG_LED_CONFIG register fields */
148 /* LED (IR and R) current (milliamps) */
149 typedef enum _MAX30100_LED_CURRENT {
150  MAX30100_LED_CURRENT_0_0_MA = 0x00,
151  MAX30100_LED_CURRENT_4_4_MA = 0x01,
152  MAX30100_LED_CURRENT_7_6_MA = 0x02,
153  MAX30100_LED_CURRENT_11_0_MA = 0x03,
154  MAX30100_LED_CURRENT_14_2_MA = 0x04,
155  MAX30100_LED_CURRENT_17_4_MA = 0x05,
156  MAX30100_LED_CURRENT_20_8_MA = 0x06,
157  MAX30100_LED_CURRENT_24_0_MA = 0x07,
158  MAX30100_LED_CURRENT_27_1_MA = 0x08,
159  MAX30100_LED_CURRENT_30_6_MA = 0x09,
160  MAX30100_LED_CURRENT_33_8_MA = 0x0a,
161  MAX30100_LED_CURRENT_37_0_MA = 0x0b,
162  MAX30100_LED_CURRENT_40_2_MA = 0x0c,
163  MAX30100_LED_CURRENT_43_6_MA = 0x0d,
164  MAX30100_LED_CURRENT_46_8_MA = 0x0e,
165  MAX30100_LED_CURRENT_50_0_MA = 0x0f
166 } MAX30100_LED_CURRENT;
167 
168 #ifdef __cplusplus
169 }
170 #endif
Definition: max30100_regs.h:36