LibDriver MAX30102
Loading...
Searching...
No Matches
driver_max30102.h
Go to the documentation of this file.
1
36
37#ifndef DRIVER_MAX30102_H
38#define DRIVER_MAX30102_H
39
40#include <stdio.h>
41#include <stdint.h>
42#include <string.h>
43
44#ifdef __cplusplus
45extern "C"{
46#endif
47
53
58
62typedef enum
63{
67
80
90
102
113
124
139
150
160
171
175typedef struct max30102_handle_s
176{
177 uint8_t (*iic_init)(void);
178 uint8_t (*iic_deinit)(void);
179 uint8_t (*iic_read)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len);
180 uint8_t (*iic_write)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len);
181 void (*receive_callback)(uint8_t type);
182 void (*delay_ms)(uint32_t ms);
183 void (*debug_print)(const char *const fmt, ...);
184 uint8_t inited;
186 uint16_t raw;
188 uint8_t buf[192];
190
206
210
217
224#define DRIVER_MAX30102_LINK_INIT(HANDLE, STRUCTURE) memset(HANDLE, 0, sizeof(STRUCTURE))
225
232#define DRIVER_MAX30102_LINK_IIC_INIT(HANDLE, FUC) (HANDLE)->iic_init = FUC
233
240#define DRIVER_MAX30102_LINK_IIC_DEINIT(HANDLE, FUC) (HANDLE)->iic_deinit = FUC
241
248#define DRIVER_MAX30102_LINK_IIC_READ(HANDLE, FUC) (HANDLE)->iic_read = FUC
249
256#define DRIVER_MAX30102_LINK_IIC_WRITE(HANDLE, FUC) (HANDLE)->iic_write = FUC
257
264#define DRIVER_MAX30102_LINK_DELAY_MS(HANDLE, FUC) (HANDLE)->delay_ms = FUC
265
272#define DRIVER_MAX30102_LINK_DEBUG_PRINT(HANDLE, FUC) (HANDLE)->debug_print = FUC
273
280#define DRIVER_MAX30102_LINK_RECEIVE_CALLBACK(HANDLE, FUC) (HANDLE)->receive_callback = FUC
281
285
292
301uint8_t max30102_info(max30102_info_t *info);
302
316uint8_t max30102_init(max30102_handle_t *handle);
317
329uint8_t max30102_deinit(max30102_handle_t *handle);
330
346uint8_t max30102_read(max30102_handle_t *handle, uint32_t *raw_red, uint32_t *raw_ir, uint8_t *len);
347
360uint8_t max30102_read_temperature(max30102_handle_t *handle, uint16_t *raw, float *temp);
361
373
387
401
415
428uint8_t max30102_set_fifo_write_pointer(max30102_handle_t *handle, uint8_t pointer);
429
441uint8_t max30102_get_fifo_write_pointer(max30102_handle_t *handle, uint8_t *pointer);
442
455uint8_t max30102_set_fifo_overflow_counter(max30102_handle_t *handle, uint8_t counter);
456
468uint8_t max30102_get_fifo_overflow_counter(max30102_handle_t *handle, uint8_t *counter);
469
482uint8_t max30102_set_fifo_read_pointer(max30102_handle_t *handle, uint8_t pointer);
483
495uint8_t max30102_get_fifo_read_pointer(max30102_handle_t *handle, uint8_t *pointer);
496
508uint8_t max30102_set_fifo_data(max30102_handle_t *handle, uint8_t data);
509
521uint8_t max30102_get_fifo_data(max30102_handle_t *handle, uint8_t *data);
522
535
548
561
574
587uint8_t max30102_set_fifo_almost_full(max30102_handle_t *handle, uint8_t value);
588
600uint8_t max30102_get_fifo_almost_full(max30102_handle_t *handle, uint8_t *value);
601
614
627
638uint8_t max30102_reset(max30102_handle_t *handle);
639
652
665
678
691
704
717
730
743
755uint8_t max30102_set_led_red_pulse_amplitude(max30102_handle_t *handle, uint8_t amp);
756
768uint8_t max30102_get_led_red_pulse_amplitude(max30102_handle_t *handle, uint8_t *amp);
769
781uint8_t max30102_set_led_ir_pulse_amplitude(max30102_handle_t *handle, uint8_t amp);
782
794uint8_t max30102_get_led_ir_pulse_amplitude(max30102_handle_t *handle, uint8_t *amp);
795
809
823
836
849
862uint8_t max30102_get_id(max30102_handle_t *handle, uint8_t *revision_id, uint8_t *part_id);
863
867
874
888uint8_t max30102_set_reg(max30102_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len);
889
903uint8_t max30102_get_reg(max30102_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len);
904
908
912
913#ifdef __cplusplus
914}
915#endif
916
917#endif
uint8_t max30102_set_slot(max30102_handle_t *handle, max30102_slot_t slot, max30102_led_t led)
set the led slot
uint8_t max30102_get_slot(max30102_handle_t *handle, max30102_slot_t slot, max30102_led_t *led)
get the led slot
uint8_t max30102_set_fifo_read_pointer(max30102_handle_t *handle, uint8_t pointer)
set the fifo read pointer
max30102_slot_t
max30102 slot enumeration definition
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_get_fifo_write_pointer(max30102_handle_t *handle, uint8_t *pointer)
get the fifo write pointer
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(max30102_handle_t *handle, max30102_interrupt_t type, max30102_bool_t *enable)
get the interrupt bool
uint8_t max30102_reset(max30102_handle_t *handle)
reset the chip
uint8_t max30102_get_mode(max30102_handle_t *handle, max30102_mode_t *mode)
get the mode
uint8_t max30102_get_fifo_roll(max30102_handle_t *handle, max30102_bool_t *enable)
get the fifo roll status
uint8_t max30102_get_fifo_data(max30102_handle_t *handle, uint8_t *data)
get the fifo data
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_get_led_red_pulse_amplitude(max30102_handle_t *handle, uint8_t *amp)
get the red led pulse amplitude
uint8_t max30102_info(max30102_info_t *info)
get chip's information
uint8_t max30102_set_fifo_sample_averaging(max30102_handle_t *handle, max30102_sample_averaging_t sample)
set the fifo sample averaging
uint8_t max30102_read_temperature(max30102_handle_t *handle, uint16_t *raw, float *temp)
read the temperature
uint8_t max30102_set_led_red_pulse_amplitude(max30102_handle_t *handle, uint8_t amp)
set the red led pulse amplitude
uint8_t max30102_get_fifo_sample_averaging(max30102_handle_t *handle, max30102_sample_averaging_t *sample)
get the fifo sample averaging
uint8_t max30102_set_mode(max30102_handle_t *handle, max30102_mode_t mode)
set the mode
uint8_t max30102_get_spo2_adc_range(max30102_handle_t *handle, max30102_spo2_adc_range_t *range)
get the spo2 adc range
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_get_led_ir_pulse_amplitude(max30102_handle_t *handle, uint8_t *amp)
get the ir led pulse amplitude
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_get_fifo_read_pointer(max30102_handle_t *handle, uint8_t *pointer)
get the fifo read pointer
max30102_spo2_adc_range_t
max30102 spo2 adc range enumeration definition
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_get_fifo_overflow_counter(max30102_handle_t *handle, uint8_t *counter)
get the fifo overflow counter
max30102_interrupt_t
max30102 interrupt enumeration definition
uint8_t max30102_set_interrupt(max30102_handle_t *handle, max30102_interrupt_t type, max30102_bool_t enable)
set the interrupt bool
uint8_t max30102_get_die_temperature(max30102_handle_t *handle, max30102_bool_t *enable)
get the die temperature status
uint8_t max30102_set_led_ir_pulse_amplitude(max30102_handle_t *handle, uint8_t amp)
set the ir led pulse amplitude
uint8_t max30102_get_id(max30102_handle_t *handle, uint8_t *revision_id, uint8_t *part_id)
get the chip id
struct max30102_info_s max30102_info_t
max30102 information structure definition
uint8_t max30102_init(max30102_handle_t *handle)
initialize the chip
max30102_spo2_sample_rate_t
max30102 spo2 sample rate enumeration definition
uint8_t max30102_set_fifo_data(max30102_handle_t *handle, uint8_t data)
set the fifo data
uint8_t max30102_get_spo2_sample_rate(max30102_handle_t *handle, max30102_spo2_sample_rate_t *rate)
get the spo2 sample rate
max30102_sample_averaging_t
max30102 sample averaging enumeration definition
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
uint8_t max30102_get_fifo_almost_full(max30102_handle_t *handle, uint8_t *value)
get the fifo almost full value
max30102_interrupt_status_t
max30102 interrupt status enumeration definition
uint8_t max30102_set_fifo_write_pointer(max30102_handle_t *handle, uint8_t pointer)
set the fifo write pointer
uint8_t max30102_set_fifo_overflow_counter(max30102_handle_t *handle, uint8_t counter)
set the fifo overflow counter
max30102_led_t
max30102 led enumeration definition
max30102_adc_resolution_t
max30102 adc resolution enumeration definition
uint8_t max30102_get_adc_resolution(max30102_handle_t *handle, max30102_adc_resolution_t *resolution)
get the adc resolution
max30102_mode_t
max30102 mode enumeration definition
uint8_t max30102_get_shutdown(max30102_handle_t *handle, max30102_bool_t *enable)
get the shutdown
@ MAX30102_SLOT_1
@ MAX30102_SLOT_4
@ MAX30102_SLOT_2
@ MAX30102_SLOT_3
@ MAX30102_BOOL_FALSE
@ MAX30102_BOOL_TRUE
@ MAX30102_SPO2_ADC_RANGE_16384
@ MAX30102_SPO2_ADC_RANGE_2048
@ MAX30102_SPO2_ADC_RANGE_4096
@ MAX30102_SPO2_ADC_RANGE_8192
@ MAX30102_INTERRUPT_DIE_TEMP_RDY_EN
@ MAX30102_INTERRUPT_PPG_RDY_EN
@ MAX30102_INTERRUPT_FIFO_FULL_EN
@ MAX30102_INTERRUPT_ALC_OVF_EN
@ MAX30102_SPO2_SAMPLE_RATE_1600_HZ
@ MAX30102_SPO2_SAMPLE_RATE_3200_HZ
@ MAX30102_SPO2_SAMPLE_RATE_50_HZ
@ MAX30102_SPO2_SAMPLE_RATE_1000_HZ
@ MAX30102_SPO2_SAMPLE_RATE_100_HZ
@ MAX30102_SPO2_SAMPLE_RATE_200_HZ
@ MAX30102_SPO2_SAMPLE_RATE_800_HZ
@ MAX30102_SPO2_SAMPLE_RATE_400_HZ
@ MAX30102_SAMPLE_AVERAGING_16
@ MAX30102_SAMPLE_AVERAGING_32
@ MAX30102_SAMPLE_AVERAGING_4
@ MAX30102_SAMPLE_AVERAGING_1
@ MAX30102_SAMPLE_AVERAGING_2
@ MAX30102_SAMPLE_AVERAGING_8
@ MAX30102_INTERRUPT_STATUS_FIFO_FULL
@ MAX30102_INTERRUPT_STATUS_ALC_OVF
@ MAX30102_INTERRUPT_STATUS_DIE_TEMP_RDY
@ MAX30102_INTERRUPT_STATUS_PPG_RDY
@ MAX30102_INTERRUPT_STATUS_PWR_RDY
@ MAX30102_LED_RED
@ MAX30102_LED_NONE
@ MAX30102_LED_IR
@ MAX30102_ADC_RESOLUTION_17_BIT
@ MAX30102_ADC_RESOLUTION_16_BIT
@ MAX30102_ADC_RESOLUTION_15_BIT
@ MAX30102_ADC_RESOLUTION_18_BIT
@ MAX30102_MODE_HEART_RATE
@ MAX30102_MODE_SPO2
@ MAX30102_MODE_MULTI_LED
uint8_t max30102_set_reg(max30102_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
set the chip register
uint8_t max30102_get_reg(max30102_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
get the chip register
max30102 handle structure definition
void(* delay_ms)(uint32_t ms)
void(* receive_callback)(uint8_t type)
void(* debug_print)(const char *const fmt,...)
uint8_t(* iic_init)(void)
uint8_t(* iic_write)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
uint8_t(* iic_read)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
uint8_t(* iic_deinit)(void)
max30102 information structure definition
char manufacturer_name[32]