LibDriver MAX30105
Loading...
Searching...
No Matches
driver_max30105.h
Go to the documentation of this file.
1
36
37#ifndef DRIVER_MAX30105_H
38#define DRIVER_MAX30105_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
103
115
126
141
152
166
177
181typedef struct max30105_handle_s
182{
183 uint8_t (*iic_init)(void);
184 uint8_t (*iic_deinit)(void);
185 uint8_t (*iic_read)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len);
186 uint8_t (*iic_write)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len);
187 void (*receive_callback)(uint8_t type);
188 void (*delay_ms)(uint32_t ms);
189 void (*debug_print)(const char *const fmt, ...);
190 uint8_t inited;
192 uint16_t raw;
194 uint8_t buf[288];
196
212
216
223
230#define DRIVER_MAX30105_LINK_INIT(HANDLE, STRUCTURE) memset(HANDLE, 0, sizeof(STRUCTURE))
231
238#define DRIVER_MAX30105_LINK_IIC_INIT(HANDLE, FUC) (HANDLE)->iic_init = FUC
239
246#define DRIVER_MAX30105_LINK_IIC_DEINIT(HANDLE, FUC) (HANDLE)->iic_deinit = FUC
247
254#define DRIVER_MAX30105_LINK_IIC_READ(HANDLE, FUC) (HANDLE)->iic_read = FUC
255
262#define DRIVER_MAX30105_LINK_IIC_WRITE(HANDLE, FUC) (HANDLE)->iic_write = FUC
263
270#define DRIVER_MAX30105_LINK_DELAY_MS(HANDLE, FUC) (HANDLE)->delay_ms = FUC
271
278#define DRIVER_MAX30105_LINK_DEBUG_PRINT(HANDLE, FUC) (HANDLE)->debug_print = FUC
279
286#define DRIVER_MAX30105_LINK_RECEIVE_CALLBACK(HANDLE, FUC) (HANDLE)->receive_callback = FUC
287
291
298
307uint8_t max30105_info(max30105_info_t *info);
308
320
334uint8_t max30105_init(max30105_handle_t *handle);
335
347uint8_t max30105_deinit(max30105_handle_t *handle);
348
365uint8_t max30105_read(max30105_handle_t *handle, uint32_t *raw_red, uint32_t *raw_ir, uint32_t *raw_green, uint8_t *len);
366
379uint8_t max30105_read_temperature(max30105_handle_t *handle, uint16_t *raw, float *temp);
380
394
408
422
435uint8_t max30105_set_fifo_write_pointer(max30105_handle_t *handle, uint8_t pointer);
436
448uint8_t max30105_get_fifo_write_pointer(max30105_handle_t *handle, uint8_t *pointer);
449
462uint8_t max30105_set_fifo_overflow_counter(max30105_handle_t *handle, uint8_t counter);
463
475uint8_t max30105_get_fifo_overflow_counter(max30105_handle_t *handle, uint8_t *counter);
476
489uint8_t max30105_set_fifo_read_pointer(max30105_handle_t *handle, uint8_t pointer);
490
502uint8_t max30105_get_fifo_read_pointer(max30105_handle_t *handle, uint8_t *pointer);
503
515uint8_t max30105_set_fifo_data(max30105_handle_t *handle, uint8_t data);
516
528uint8_t max30105_get_fifo_data(max30105_handle_t *handle, uint8_t *data);
529
542
555
568
581
594uint8_t max30105_set_fifo_almost_full(max30105_handle_t *handle, uint8_t value);
595
607uint8_t max30105_get_fifo_almost_full(max30105_handle_t *handle, uint8_t *value);
608
621
634
645uint8_t max30105_reset(max30105_handle_t *handle);
646
659
672
685
698
711
724
737
750
762uint8_t max30105_set_led_red_pulse_amplitude(max30105_handle_t *handle, uint8_t amp);
763
775uint8_t max30105_get_led_red_pulse_amplitude(max30105_handle_t *handle, uint8_t *amp);
776
788uint8_t max30105_set_led_ir_pulse_amplitude(max30105_handle_t *handle, uint8_t amp);
789
801uint8_t max30105_get_led_ir_pulse_amplitude(max30105_handle_t *handle, uint8_t *amp);
802
815
827uint8_t max30105_get_led_green_pulse_amplitude(max30105_handle_t *handle, uint8_t *amp);
828
841
854
868
882
895
908
920uint8_t max30105_set_proximity_interrupt_threshold(max30105_handle_t *handle, uint8_t threshold);
921
933uint8_t max30105_get_proximity_interrupt_threshold(max30105_handle_t *handle, uint8_t *threshold);
934
946uint8_t max30105_proximity_threshold_convert_to_register(max30105_handle_t *handle, uint32_t adc, uint8_t *reg);
947
959uint8_t max30105_proximity_threshold_convert_to_data(max30105_handle_t *handle, uint8_t reg, uint32_t *adc);
960
973uint8_t max30105_get_id(max30105_handle_t *handle, uint8_t *revision_id, uint8_t *part_id);
974
978
985
999uint8_t max30105_set_reg(max30105_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len);
1000
1014uint8_t max30105_get_reg(max30105_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len);
1015
1019
1023
1024#ifdef __cplusplus
1025}
1026#endif
1027
1028#endif
uint8_t max30105_set_fifo_data(max30105_handle_t *handle, uint8_t data)
set the fifo data
uint8_t max30105_init(max30105_handle_t *handle)
initialize the chip
uint8_t max30105_read(max30105_handle_t *handle, uint32_t *raw_red, uint32_t *raw_ir, uint32_t *raw_green, uint8_t *len)
read the data
uint8_t max30105_proximity_threshold_convert_to_data(max30105_handle_t *handle, uint8_t reg, uint32_t *adc)
convert the register raw data to the proximity threshold
uint8_t max30105_get_fifo_roll(max30105_handle_t *handle, max30105_bool_t *enable)
get the fifo roll status
max30105_interrupt_t
max30105 interrupt enumeration definition
uint8_t max30105_irq_handler(max30105_handle_t *handle)
irq handler
uint8_t max30105_get_led_red_pulse_amplitude(max30105_handle_t *handle, uint8_t *amp)
get the red led pulse amplitude
uint8_t max30105_get_adc_resolution(max30105_handle_t *handle, max30105_adc_resolution_t *resolution)
get the adc resolution
uint8_t max30105_get_id(max30105_handle_t *handle, uint8_t *revision_id, uint8_t *part_id)
get the chip id
uint8_t max30105_get_interrupt(max30105_handle_t *handle, max30105_interrupt_t type, max30105_bool_t *enable)
get the interrupt bool
uint8_t max30105_set_fifo_sample_averaging(max30105_handle_t *handle, max30105_sample_averaging_t sample)
set the fifo sample averaging
uint8_t max30105_get_fifo_sample_averaging(max30105_handle_t *handle, max30105_sample_averaging_t *sample)
get the fifo sample averaging
uint8_t max30105_set_fifo_almost_full(max30105_handle_t *handle, uint8_t value)
set the fifo almost full value
uint8_t max30105_get_led_ir_pulse_amplitude(max30105_handle_t *handle, uint8_t *amp)
get the ir led pulse amplitude
uint8_t max30105_info(max30105_info_t *info)
get chip's information
uint8_t max30105_set_led_red_pulse_amplitude(max30105_handle_t *handle, uint8_t amp)
set the red led pulse amplitude
uint8_t max30105_get_die_temperature(max30105_handle_t *handle, max30105_bool_t *enable)
get the die temperature status
uint8_t max30105_get_particle_sensing_adc_range(max30105_handle_t *handle, max30105_particle_sensing_adc_range_t *range)
get the particle sensing adc range
uint8_t max30105_set_shutdown(max30105_handle_t *handle, max30105_bool_t enable)
set the shutdown
uint8_t max30105_get_fifo_data(max30105_handle_t *handle, uint8_t *data)
get the fifo data
uint8_t max30105_get_mode(max30105_handle_t *handle, max30105_mode_t *mode)
get the mode
uint8_t max30105_get_fifo_write_pointer(max30105_handle_t *handle, uint8_t *pointer)
get the fifo write pointer
uint8_t max30105_set_fifo_overflow_counter(max30105_handle_t *handle, uint8_t counter)
set the fifo overflow counter
max30105_interrupt_status_t
max30105 interrupt status enumeration definition
struct max30105_handle_s max30105_handle_t
max30105 handle structure definition
uint8_t max30105_reset(max30105_handle_t *handle)
reset the chip
uint8_t max30105_proximity_threshold_convert_to_register(max30105_handle_t *handle, uint32_t adc, uint8_t *reg)
convert the proximity threshold to the register raw data
uint8_t max30105_get_fifo_read_pointer(max30105_handle_t *handle, uint8_t *pointer)
get the fifo read pointer
max30105_particle_sensing_sample_rate_t
max30105 particle sensing sample rate enumeration definition
uint8_t max30105_set_mode(max30105_handle_t *handle, max30105_mode_t mode)
set the mode
uint8_t max30105_get_shutdown(max30105_handle_t *handle, max30105_bool_t *enable)
get the shutdown
uint8_t max30105_get_proximity_interrupt_threshold(max30105_handle_t *handle, uint8_t *threshold)
get the proximity interrupt threshold
uint8_t max30105_set_fifo_roll(max30105_handle_t *handle, max30105_bool_t enable)
enable or disable the fifo roll
max30105_bool_t
max30105 bool enumeration definition
max30105_sample_averaging_t
max30105 sample averaging enumeration definition
uint8_t max30105_get_slot(max30105_handle_t *handle, max30105_slot_t slot, max30105_led_t *led)
get the led slot
max30105_adc_resolution_t
max30105 adc resolution enumeration definition
uint8_t max30105_get_led_proximity_pulse_amplitude(max30105_handle_t *handle, uint8_t *amp)
get the proximity led pulse amplitude
uint8_t max30105_set_led_proximity_pulse_amplitude(max30105_handle_t *handle, uint8_t amp)
set the proximity led pulse amplitude
uint8_t max30105_get_particle_sensing_sample_rate(max30105_handle_t *handle, max30105_particle_sensing_sample_rate_t *rate)
get the particle sensing sample rate
uint8_t max30105_get_fifo_almost_full(max30105_handle_t *handle, uint8_t *value)
get the fifo almost full value
uint8_t max30105_set_interrupt(max30105_handle_t *handle, max30105_interrupt_t type, max30105_bool_t enable)
set the interrupt bool
max30105_mode_t
max30105 mode enumeration definition
uint8_t max30105_set_fifo_read_pointer(max30105_handle_t *handle, uint8_t pointer)
set the fifo read pointer
max30105_slot_t
max30105 slot enumeration definition
uint8_t max30105_set_led_green_pulse_amplitude(max30105_handle_t *handle, uint8_t amp)
set the green led pulse amplitude
max30105_particle_sensing_adc_range_t
max30105 particle sensing adc range enumeration definition
uint8_t max30105_set_adc_resolution(max30105_handle_t *handle, max30105_adc_resolution_t resolution)
set the adc resolution
uint8_t max30105_set_particle_sensing_adc_range(max30105_handle_t *handle, max30105_particle_sensing_adc_range_t range)
set the particle sensing adc range
uint8_t max30105_set_proximity_interrupt_threshold(max30105_handle_t *handle, uint8_t threshold)
set the proximity interrupt threshold
uint8_t max30105_set_particle_sensing_sample_rate(max30105_handle_t *handle, max30105_particle_sensing_sample_rate_t rate)
set the particle sensing sample rate
max30105_led_t
max30105 led enumeration definition
struct max30105_info_s max30105_info_t
max30105 information structure definition
uint8_t max30105_get_led_green_pulse_amplitude(max30105_handle_t *handle, uint8_t *amp)
get the green led pulse amplitude
uint8_t max30105_get_fifo_overflow_counter(max30105_handle_t *handle, uint8_t *counter)
get the fifo overflow counter
uint8_t max30105_read_temperature(max30105_handle_t *handle, uint16_t *raw, float *temp)
read the temperature
uint8_t max30105_get_interrupt_status(max30105_handle_t *handle, max30105_interrupt_status_t status, max30105_bool_t *enable)
get the interrupt status
uint8_t max30105_deinit(max30105_handle_t *handle)
close the chip
uint8_t max30105_set_fifo_write_pointer(max30105_handle_t *handle, uint8_t pointer)
set the fifo write pointer
uint8_t max30105_set_led_ir_pulse_amplitude(max30105_handle_t *handle, uint8_t amp)
set the ir led pulse amplitude
uint8_t max30105_set_die_temperature(max30105_handle_t *handle, max30105_bool_t enable)
enable or disable die temperature
uint8_t max30105_set_slot(max30105_handle_t *handle, max30105_slot_t slot, max30105_led_t led)
set the led slot
@ MAX30105_INTERRUPT_FIFO_FULL_EN
@ MAX30105_INTERRUPT_DIE_TEMP_RDY_EN
@ MAX30105_INTERRUPT_ALC_OVF_EN
@ MAX30105_INTERRUPT_DATA_RDY_EN
@ MAX30105_INTERRUPT_PROX_INT_EN
@ MAX30105_INTERRUPT_STATUS_ALC_OVF
@ MAX30105_INTERRUPT_STATUS_DIE_TEMP_RDY
@ MAX30105_INTERRUPT_STATUS_FIFO_FULL
@ MAX30105_INTERRUPT_STATUS_DATA_RDY
@ MAX30105_INTERRUPT_STATUS_PWR_RDY
@ MAX30105_INTERRUPT_STATUS_PROX_INT
@ MAX30105_PARTICLE_SENSING_SAMPLE_RATE_1600_HZ
@ MAX30105_PARTICLE_SENSING_SAMPLE_RATE_50_HZ
@ MAX30105_PARTICLE_SENSING_SAMPLE_RATE_200_HZ
@ MAX30105_PARTICLE_SENSING_SAMPLE_RATE_3200_HZ
@ MAX30105_PARTICLE_SENSING_SAMPLE_RATE_800_HZ
@ MAX30105_PARTICLE_SENSING_SAMPLE_RATE_400_HZ
@ MAX30105_PARTICLE_SENSING_SAMPLE_RATE_1000_HZ
@ MAX30105_PARTICLE_SENSING_SAMPLE_RATE_100_HZ
@ MAX30105_BOOL_TRUE
@ MAX30105_BOOL_FALSE
@ MAX30105_SAMPLE_AVERAGING_1
@ MAX30105_SAMPLE_AVERAGING_8
@ MAX30105_SAMPLE_AVERAGING_2
@ MAX30105_SAMPLE_AVERAGING_4
@ MAX30105_SAMPLE_AVERAGING_32
@ MAX30105_SAMPLE_AVERAGING_16
@ MAX30105_ADC_RESOLUTION_15_BIT
@ MAX30105_ADC_RESOLUTION_17_BIT
@ MAX30105_ADC_RESOLUTION_18_BIT
@ MAX30105_ADC_RESOLUTION_16_BIT
@ MAX30105_MODE_RED_IR
@ MAX30105_MODE_RED
@ MAX30105_MODE_GREEN_RED_IR
@ MAX30105_SLOT_2
@ MAX30105_SLOT_4
@ MAX30105_SLOT_1
@ MAX30105_SLOT_3
@ MAX30105_PARTICLE_SENSING_ADC_RANGE_16384
@ MAX30105_PARTICLE_SENSING_ADC_RANGE_4096
@ MAX30105_PARTICLE_SENSING_ADC_RANGE_2048
@ MAX30105_PARTICLE_SENSING_ADC_RANGE_8192
@ MAX30105_LED_GREEN_PILOT_PA
@ MAX30105_LED_IR_LED2_PA
@ MAX30105_LED_RED_LED1_PA
@ MAX30105_LED_NONE
@ MAX30105_LED_IR_PILOT_PA
@ MAX30105_LED_GREEN_LED3_PA
@ MAX30105_LED_RED_PILOT_PA
uint8_t max30105_get_reg(max30105_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
get the chip register
uint8_t max30105_set_reg(max30105_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
set the chip register
max30105 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)
max30105 information structure definition
char manufacturer_name[32]