LibDriver MAX30102
Loading...
Searching...
No Matches
driver_max30102_fifo.c
Go to the documentation of this file.
1
36
38
39static max30102_handle_t gs_handle;
40
49{
50 /* run irq handler */
51 if (max30102_irq_handler(&gs_handle) != 0)
52 {
53 return 1;
54 }
55 else
56 {
57 return 0;
58 }
59}
60
69uint8_t max30102_fifo_init(void (*fifo_receive_callback)(uint8_t type))
70{
71 uint8_t res;
72 max30102_bool_t enable;
73
74 /* link interface function */
82 DRIVER_MAX30102_LINK_RECEIVE_CALLBACK(&gs_handle, fifo_receive_callback);
83
84 /* init the max30102 */
85 res = max30102_init(&gs_handle);
86 if (res != 0)
87 {
88 max30102_interface_debug_print("max30102: init failed.\n");
89
90 return 1;
91 }
92
93 /* enable shutdown */
95 if (res != 0)
96 {
97 max30102_interface_debug_print("max30102: set shutdown failed.\n");
98 (void)max30102_deinit(&gs_handle);
99
100 return 1;
101 }
102
103 /* set fifo sample averaging */
105 if (res != 0)
106 {
107 max30102_interface_debug_print("max30102: set fifo sample averaging failed.\n");
108 (void)max30102_deinit(&gs_handle);
109
110 return 1;
111 }
112
113 /* set fifo roll */
115 if (res != 0)
116 {
117 max30102_interface_debug_print("max30102: set fifo roll failed.\n");
118 (void)max30102_deinit(&gs_handle);
119
120 return 1;
121 }
122
123 /* set fifo almost full */
125 if (res != 0)
126 {
127 max30102_interface_debug_print("max30102: set fifo almost full failed.\n");
128 (void)max30102_deinit(&gs_handle);
129
130 return 1;
131 }
132
133 /* set mode */
135 if (res != 0)
136 {
137 max30102_interface_debug_print("max30102: set mode failed.\n");
138 (void)max30102_deinit(&gs_handle);
139
140 return 1;
141 }
142
143 /* set spo2 adc range */
145 if (res != 0)
146 {
147 max30102_interface_debug_print("max30102: set spo2 adc range failed.\n");
148 (void)max30102_deinit(&gs_handle);
149
150 return 1;
151 }
152
153 /* set spo2 sample rate */
155 if (res != 0)
156 {
157 max30102_interface_debug_print("max30102: set spo2 sample rate failed.\n");
158 (void)max30102_deinit(&gs_handle);
159
160 return 1;
161 }
162
163 /* set adc resolution */
165 if (res != 0)
166 {
167 max30102_interface_debug_print("max30102: set adc resolution failed.\n");
168 (void)max30102_deinit(&gs_handle);
169
170 return 1;
171 }
172
173 /* set led red pulse amplitude */
175 if (res != 0)
176 {
177 max30102_interface_debug_print("max30102: set led red pulse amplitude failed.\n");
178 (void)max30102_deinit(&gs_handle);
179
180 return 1;
181 }
182
183 /* set led ir pulse amplitude */
185 if (res != 0)
186 {
187 max30102_interface_debug_print("max30102: set led ir pulse amplitude failed.\n");
188 (void)max30102_deinit(&gs_handle);
189
190 return 1;
191 }
192
193 /* set slot */
195 if (res != 0)
196 {
197 max30102_interface_debug_print("max30102: set slot failed.\n");
198 (void)max30102_deinit(&gs_handle);
199
200 return 1;
201 }
202
203 /* set slot */
205 if (res != 0)
206 {
207 max30102_interface_debug_print("max30102: set slot failed.\n");
208 (void)max30102_deinit(&gs_handle);
209
210 return 1;
211 }
212
213 /* set slot */
215 if (res != 0)
216 {
217 max30102_interface_debug_print("max30102: set slot failed.\n");
218 (void)max30102_deinit(&gs_handle);
219
220 return 1;
221 }
222
223 /* set slot */
225 if (res != 0)
226 {
227 max30102_interface_debug_print("max30102: set slot failed.\n");
228 (void)max30102_deinit(&gs_handle);
229
230 return 1;
231 }
232
233 /* set die temperature */
235 if (res != 0)
236 {
237 max30102_interface_debug_print("max30102: set die temperature failed.\n");
238 (void)max30102_deinit(&gs_handle);
239
240 return 1;
241 }
242
243 /* set interrupt */
245 if (res != 0)
246 {
247 max30102_interface_debug_print("max30102: set interrupt failed.\n");
248 (void)max30102_deinit(&gs_handle);
249
250 return 1;
251 }
252
253 /* set interrupt */
255 if (res != 0)
256 {
257 max30102_interface_debug_print("max30102: set interrupt failed.\n");
258 (void)max30102_deinit(&gs_handle);
259
260 return 1;
261 }
262
263 /* set interrupt */
265 if (res != 0)
266 {
267 max30102_interface_debug_print("max30102: set interrupt failed.\n");
268 (void)max30102_deinit(&gs_handle);
269
270 return 1;
271 }
272
273 /* set interrupt */
275 if (res != 0)
276 {
277 max30102_interface_debug_print("max30102: set interrupt failed.\n");
278 (void)max30102_deinit(&gs_handle);
279
280 return 1;
281 }
282
283 /* disable shutdown */
285 if (res != 0)
286 {
287 max30102_interface_debug_print("max30102: set shutdown failed.\n");
288 (void)max30102_deinit(&gs_handle);
289
290 return 1;
291 }
292
293 /* get status */
295 if (res != 0)
296 {
297 max30102_interface_debug_print("max30102: get interrupt status failed.\n");
298 (void)max30102_deinit(&gs_handle);
299
300 return 1;
301 }
302
303 return 0;
304}
305
314{
315 uint8_t res;
316
317 res = max30102_deinit(&gs_handle);
318 if (res != 0)
319 {
320 return 1;
321 }
322 else
323 {
324 return 0;
325 }
326}
327
338uint8_t max30102_fifo_read(uint32_t *raw_red, uint32_t *raw_ir, uint8_t *len)
339{
340 uint8_t res;
341
342 res = max30102_read(&gs_handle, raw_red, raw_ir, len);
343 if (res != 0)
344 {
345 return 1;
346 }
347 else
348 {
349 return 0;
350 }
351}
driver max30102 fifo header file
uint8_t max30102_set_slot(max30102_handle_t *handle, max30102_slot_t slot, max30102_led_t led)
set the led slot
uint8_t max30102_set_die_temperature(max30102_handle_t *handle, max30102_bool_t enable)
enable or disable die temperature
max30102_bool_t
max30102 bool enumeration definition
uint8_t max30102_set_fifo_roll(max30102_handle_t *handle, max30102_bool_t enable)
enable or disable the fifo roll
uint8_t max30102_get_interrupt_status(max30102_handle_t *handle, max30102_interrupt_status_t status, max30102_bool_t *enable)
get the interrupt status
uint8_t max30102_set_fifo_almost_full(max30102_handle_t *handle, uint8_t value)
set the fifo almost full value
uint8_t max30102_set_fifo_sample_averaging(max30102_handle_t *handle, max30102_sample_averaging_t sample)
set the fifo sample averaging
uint8_t max30102_set_led_red_pulse_amplitude(max30102_handle_t *handle, uint8_t amp)
set the red led pulse amplitude
uint8_t max30102_set_mode(max30102_handle_t *handle, max30102_mode_t mode)
set the mode
uint8_t max30102_set_shutdown(max30102_handle_t *handle, max30102_bool_t enable)
set the shutdown
uint8_t max30102_read(max30102_handle_t *handle, uint32_t *raw_red, uint32_t *raw_ir, uint8_t *len)
read the data
uint8_t max30102_deinit(max30102_handle_t *handle)
close the chip
uint8_t max30102_set_spo2_adc_range(max30102_handle_t *handle, max30102_spo2_adc_range_t range)
set the spo2 adc range
uint8_t max30102_set_spo2_sample_rate(max30102_handle_t *handle, max30102_spo2_sample_rate_t rate)
set the spo2 sample rate
uint8_t max30102_set_interrupt(max30102_handle_t *handle, max30102_interrupt_t type, max30102_bool_t enable)
set the interrupt bool
uint8_t max30102_set_led_ir_pulse_amplitude(max30102_handle_t *handle, uint8_t amp)
set the ir led pulse amplitude
uint8_t max30102_init(max30102_handle_t *handle)
initialize the chip
struct max30102_handle_s max30102_handle_t
max30102 handle structure definition
uint8_t max30102_irq_handler(max30102_handle_t *handle)
irq handler
uint8_t max30102_set_adc_resolution(max30102_handle_t *handle, max30102_adc_resolution_t resolution)
set the adc resolution
@ MAX30102_SLOT_1
@ MAX30102_SLOT_4
@ MAX30102_SLOT_2
@ MAX30102_SLOT_3
@ MAX30102_BOOL_FALSE
@ MAX30102_BOOL_TRUE
@ MAX30102_INTERRUPT_DIE_TEMP_RDY_EN
@ MAX30102_INTERRUPT_PPG_RDY_EN
@ MAX30102_INTERRUPT_FIFO_FULL_EN
@ MAX30102_INTERRUPT_ALC_OVF_EN
@ MAX30102_INTERRUPT_STATUS_FIFO_FULL
#define MAX30102_FIFO_DEFAULT_INTERRUPT_PPG_RDY_EN
#define MAX30102_FIFO_DEFAULT_SPO2_SAMPLE_RATE
#define MAX30102_FIFO_DEFAULT_SLOT4
#define MAX30102_FIFO_DEFAULT_LED_IR_PULSE_AMPLITUDE
#define MAX30102_FIFO_DEFAULT_INTERRUPT_DIE_TEMP_RDY_EN
#define MAX30102_FIFO_DEFAULT_MODE
uint8_t max30102_fifo_init(void(*fifo_receive_callback)(uint8_t type))
fifo example init
#define MAX30102_FIFO_DEFAULT_SAMPLE_AVERAGING
max30102 fifo example default definition
#define MAX30102_FIFO_DEFAULT_SLOT3
#define MAX30102_FIFO_DEFAULT_FIFO_ROLL
#define MAX30102_FIFO_DEFAULT_SLOT2
uint8_t max30102_fifo_irq_handler(void)
fifo example irq handler
#define MAX30102_FIFO_DEFAULT_SPO2_ADC_RANGE
#define MAX30102_FIFO_DEFAULT_DIE_TEMPERATURE
#define MAX30102_FIFO_DEFAULT_LED_RED_PULSE_AMPLITUDE
#define MAX30102_FIFO_DEFAULT_INTERRUPT_ALC_OVF_EN
uint8_t max30102_fifo_deinit(void)
fifo example deinit
#define MAX30102_FIFO_DEFAULT_ADC_RESOLUTION
#define MAX30102_FIFO_DEFAULT_FIFO_ALMOST_FULL
#define MAX30102_FIFO_DEFAULT_SLOT1
uint8_t max30102_fifo_read(uint32_t *raw_red, uint32_t *raw_ir, uint8_t *len)
read the data
uint8_t max30102_interface_iic_init(void)
interface iic bus init
void max30102_interface_debug_print(const char *const fmt,...)
interface print format data
uint8_t max30102_interface_iic_read(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
interface iic bus read
uint8_t max30102_interface_iic_deinit(void)
interface iic bus deinit
void max30102_interface_delay_ms(uint32_t ms)
interface delay ms
uint8_t max30102_interface_iic_write(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
interface iic bus write