42#ifdef PREINIT_SUPPORTED
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
52#include "drv_digital_out.h"
53#include "drv_digital_in.h"
54#include "drv_i2c_master.h"
66#define HEARTRATE4_MAP_MIKROBUS( cfg, mikrobus ) \
67 cfg.scl1 = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
68 cfg.sda1 = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
69 cfg.int1 = MIKROBUS( mikrobus, MIKROBUS_INT )
76#define HEARTRATE4_RETVAL uint8_t
78#define HEARTRATE4_OK 0x00
79#define HEARTRATE4_INIT_ERROR 0xFF
86#define HEARTRATE4_I2C_ADDRESS 0x57
98#define HEARTRATE4_INT_STAT1 0x00
99#define HEARTRATE4_INT_STAT2 0x01
100#define HEARTRATE4_INT_ENABLE1 0x02
101#define HEARTRATE4_INT_ENABLE2 0x03
108#define HEARTRATE4_FIFO_WRITE_PTR 0x04
109#define HEARTRATE4_FIFO_OVERFLOW 0x05
110#define HEARTRATE4_FIFO_READ_PTR 0x06
111#define HEARTRATE4_FIFO_DATA 0x07
112#define HEARTRATE4_BUFFER_LENGTH 32
119#define HEARTRATE4_FIFO_CONFIG 0x08
120#define HEARTRATE4_MODE_CONFIG 0x09
121#define HEARTRATE4_SPO2_CONFIG 0x0A
122#define HEARTRATE4_LED1_PULSE_AMP 0x0C
123#define HEARTRATE4_LED2_PULSE_AMP 0x0D
124#define HEARTRATE4_LED3_PULSE_AMP 0x0E
125#define HEARTRATE4_LED_PROX_AMP 0x10
126#define HEARTRATE4_MULTI_LED_CONFIG1 0x11
127#define HEARTRATE4_MULTI_LED_CONFIG2 0x12
128#define HEARTRATE4_MIN_POWER_LEVEL 0x01
129#define HEARTRATE4_AVG_POWER_LEVEL 0x1F
130#define HEARTRATE4_MAX_POWER_LEVEL 0xFF
137#define HEARTRATE4_DIE_TEMP_INT 0x1F
138#define HEARTRATE4_DIE_TEMP_FRAC 0x20
139#define HEARTRATE4_DIE_TEMP_CONFIG 0x21
146#define HEARTRATE4_PROX_INT_THRESH 0x30
153#define HEARTRATE4_REVISION_ID 0xFE
154#define HEARTRATE4_PART_ID 0xFF
167#define HEARTRATE4_INT_A_FULL_MASK (uint8_t)~0b10000000
168#define HEARTRATE4_INT_A_FULL_ENABLE 0x80
169#define HEARTRATE4_INT_A_FULL_DISABLE 0x00
170#define HEARTRATE4_INT_DATA_RDY_MASK (uint8_t)~0b01000000
171#define HEARTRATE4_INT_DATA_RDY_ENABLE 0x40
172#define HEARTRATE4_INT_DATA_RDY_DISABLE 0x00
173#define HEARTRATE4_INT_ALC_OVF_MASK (uint8_t)~0b00100000
174#define HEARTRATE4_INT_ALC_OVF_ENABLE 0x20
175#define HEARTRATE4_INT_ALC_OVF_DISABLE 0x00
176#define HEARTRATE4_INT_PROX_INT_MASK (uint8_t)~0b00010000
177#define HEARTRATE4_INT_PROX_INT_ENABLE 0x10
178#define HEARTRATE4_INT_PROX_INT_DISABLE 0x00
179#define HEARTRATE4_INT_DIE_TEMP_RDY_MASK (uint8_t)~0b00000010
180#define HEARTRATE4_INT_DIE_TEMP_RDY_ENABLE 0x02
181#define HEARTRATE4_INT_DIE_TEMP_RDY_DISABLE 0x00
188#define HEARTRATE4_SAMPLEAVG_MASK (uint8_t)~0b11100000
189#define HEARTRATE4_SAMPLEAVG_1 0x00
190#define HEARTRATE4_SAMPLEAVG_2 0x20
191#define HEARTRATE4_SAMPLEAVG_4 0x40
192#define HEARTRATE4_SAMPLEAVG_8 0x60
193#define HEARTRATE4_SAMPLEAVG_16 0x80
194#define HEARTRATE4_SAMPLEAVG_32 0xA0
195#define HEARTRATE4_ROLLOVER_MASK 0xEF
196#define HEARTRATE4_ROLLOVER_ENABLE 0x10
197#define HEARTRATE4_ROLLOVER_DISABLE 0x00
198#define HEARTRATE4_A_FULL_MASK 0xF0
205#define HEARTRATE4_SHUTDOWN_MASK 0x7F
206#define HEARTRATE4_SHUTDOWN 0x80
207#define HEARTRATE4_WAKEUP 0x00
208#define HEARTRATE4_RESET_MASK 0xBF
209#define HEARTRATE4_RESET 0x40
210#define HEARTRATE4_MODE_MASK 0xF8
211#define HEARTRATE4_MODE_REDONLY 0x02
212#define HEARTRATE4_MODE_REDIRONLY 0x03
213#define HEARTRATE4_MODE_MULTILED 0x07
220#define HEARTRATE4_ADCRANGE_MASK 0x9F
221#define HEARTRATE4_ADCRANGE_2048 0x00
222#define HEARTRATE4_ADCRANGE_4096 0x20
223#define HEARTRATE4_ADCRANGE_8192 0x40
224#define HEARTRATE4_ADCRANGE_16384 0x60
225#define HEARTRATE4_SAMPLERATE_MASK 0xE3
226#define HEARTRATE4_SAMPLERATE_50 0x00
227#define HEARTRATE4_SAMPLERATE_100 0x04
228#define HEARTRATE4_SAMPLERATE_200 0x08
229#define HEARTRATE4_SAMPLERATE_400 0x0C
230#define HEARTRATE4_SAMPLERATE_800 0x10
231#define HEARTRATE4_SAMPLERATE_1000 0x14
232#define HEARTRATE4_SAMPLERATE_1600 0x18
233#define HEARTRATE4_SAMPLERATE_3200 0x1C
234#define HEARTRATE4_PULSEWIDTH_MASK 0xFC
235#define HEARTRATE4_PULSEWIDTH_69 0x00
236#define HEARTRATE4_PULSEWIDTH_118 0x01
237#define HEARTRATE4_PULSEWIDTH_215 0x02
238#define HEARTRATE4_PULSEWIDTH_411 0x03
245#define HEARTRATE4_SLOT1_MASK 0xF8
246#define HEARTRATE4_SLOT2_MASK 0x8F
247#define HEARTRATE4_SLOT3_MASK 0xF8
248#define HEARTRATE4_SLOT4_MASK 0x8F
249#define HEARTRATE4_SLOT_NONE 0x00
250#define HEARTRATE4_SLOT_RED_LED 0x01
251#define HEARTRATE4_SLOT_IR_LED 0x02
252#define HEARTRATE4_SLOT_GREEN_LED 0x03
253#define HEARTRATE4_SLOT_NONE_PILOT 0x04
254#define HEARTRATE4_SLOT_RED_PILOT 0x05
255#define HEARTRATE4_SLOT_IR_PILOT 0x06
256#define HEARTRATE4_SLOT_GREEN_PILOT 0x07
#define HEARTRATE4_RETVAL
Definition heartrate4.h:76
uint16_t heartrate4_read_fifo_all_samples(heartrate4_t *ctx, uint8_t *buff)
Read all FIFO samples function.
float heartrate4_read_temp_c(heartrate4_t *ctx)
Read temperature in Centigrade function.
void heartrate4_write_data(heartrate4_t *ctx, uint8_t wr_addr, uint8_t wr_data)
Generic write function.
void heartrate4_setting_prox_and_amp(heartrate4_t *ctx, uint8_t flag, uint8_t write_data)
Set corresponding amplitude or proximity threshold function.
void heartrate4_enable_disable_interrupts(heartrate4_t *ctx, uint8_t interrupt_flag, uint8_t enable_flag)
Enable or disable interrupt function.
void heartrate4_multi_read(heartrate4_t *ctx, uint8_t rd_addr, uint8_t *buffer, uint8_t cnt)
Multi read function.
uint32_t heartrate4_get_red_val(heartrate4_t *ctx)
Get Red value function.
void heartrate4_set_registers(heartrate4_t *ctx, heartrate4_set_registers_t *registers)
Set registers values function.
uint8_t heartrate4_get_intrrupt(heartrate4_t *ctx, uint8_t flag)
Get desired interrupt function.
void heartrate4_clear_fifo(heartrate4_t *ctx)
Clearing FIFO pointers function.
void heartrate4_setting_function(heartrate4_t *ctx, uint8_t flag, uint8_t mode)
Set corresponding configuration register function.
uint8_t heartrate4_get_write_ptr(heartrate4_t *ctx)
Read the FIFO Write Pointer function.
void heartrate4_cfg_setup(heartrate4_cfg_t *cfg)
Config Object Initialization function.
void heartrate4_reset(heartrate4_t *ctx)
Reset device function.
uint8_t heartrate4_check_int_pow_and_temp(heartrate4_t *ctx, uint8_t flag)
Check interrupt, power ready or internal temperature ready flag function.
uint8_t heartrate4_check_int(heartrate4_t *ctx)
Get Interrupt state function.
uint8_t heartrate4_read_data(heartrate4_t *ctx, uint8_t rd_addr)
Generic read function.
void heartrate4_disable_slots(heartrate4_t *ctx)
Disable slots in MultiLED mode function.
void heartrate4_default_cfg(heartrate4_t *ctx)
Click Default Configuration function.
void heartrate4_enable_slot(heartrate4_t *ctx, uint8_t slot_num, uint8_t dev)
Define slots in MultiLED mode function.
float heartrate4_read_temp_f(heartrate4_t *ctx)
Read temperature in Fahrenheit function.
void heartrate4_fifo_setting(heartrate4_t *ctx, uint8_t flag, uint8_t samp_num)
Set FIFO configuration register function.
uint32_t heartrate4_read_fifo_oldest_sample(heartrate4_t *ctx)
Read oldest FIFO sample function.
HEARTRATE4_RETVAL heartrate4_init(heartrate4_t *ctx, heartrate4_cfg_t *cfg)
Initialization function.
uint8_t heartrate4_get_read_ptr(heartrate4_t *ctx)
Read the FIFO Read Pointer function.
void heartrate4_set_new_value(heartrate4_t *ctx, uint8_t reg, uint8_t mask, uint8_t value)
Set new value function.
Click configuration structure definition.
Definition heartrate4.h:289
pin_name_t int1
Definition heartrate4.h:297
uint32_t i2c_speed
Definition heartrate4.h:301
pin_name_t sda1
Definition heartrate4.h:293
pin_name_t scl1
Definition heartrate4.h:292
uint8_t i2c_address
Definition heartrate4.h:302
Click registers object definition.
Definition heartrate4.h:310
uint8_t mode
Definition heartrate4.h:314
uint8_t led_pow_lvl
Definition heartrate4.h:318
uint8_t avg_samp
Definition heartrate4.h:313
uint8_t adc_range
Definition heartrate4.h:315
uint8_t samp_rate
Definition heartrate4.h:316
uint8_t pulse_width
Definition heartrate4.h:317
Click ctx object definition.
Definition heartrate4.h:270
digital_in_t int1
Definition heartrate4.h:273
i2c_master_t i2c
Definition heartrate4.h:277
uint8_t slave_address
Definition heartrate4.h:281