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"
67#define HEARTRATE_MAP_MIKROBUS( cfg, mikrobus ) \
68 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
69 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
70 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
77#define HEARTRATE_RETVAL uint8_t
79#define HEARTRATE_OK 0x00
80#define HEARTRATE_INIT_ERROR 0xFF
87#define SLAVE_ADDRESS 0x57
94#define HEARTRATE_INT_STATUS 0x00
95#define HEARTRATE_INT_ENABLE 0x01
96#define HEARTRATE_FIFO_WRITE_PTR 0x02
97#define HEARTRATE_OVER_FLOW_CNT 0x03
98#define HEARTRATE_FIFO_READ_PTR 0x04
99#define HEARTRATE_FIFO_DATA_REG 0x05
100#define HEARTRATE_MODE_CONFIG 0x06
101#define HEARTRATE_SPO2_CONFIG 0x07
102#define HEARTRATE_LED_CONFIG 0x09
103#define HEARTRATE_TEMP_INTEGER 0x16
104#define HEARTRATE_TEMP_FRACTION 0x17
105#define HEARTRATE_REVISION_ID 0xFE
106#define HEARTRATE_PART_ID 0xFF
113#define HEARTRATE_TEMP_EN 0x08
114#define HEARTRATE_HR_ONLY 0x02
115#define HEARTRATE_SPO2_EN 0x03
122#define HEARTRATE_SPO2_HI_RES_EN 0x40
129 #define HEARTRATE_ENA_A_FULL 0x80
130 #define HEARTRATE_ENA_TEP_RDY 0x40
131 #define HEARTRATE_ENA_HR_RDY 0x20
132 #define HEARTRATE_ENA_SO2_RDY 0x10
139#define HEARTRATE_PWR_RDY 0x01
146#define HEARTRATE_SAMPLES_50 0x00
147#define HEARTRATE_SAMPLES_100 0x04
148#define HEARTRATE_SAMPLES_167 0x08
149#define HEARTRATE_SAMPLES_200 0x0C
150#define HEARTRATE_SAMPLES_400 0x10
151#define HEARTRATE_SAMPLES_600 0x14
152#define HEARTRATE_SAMPLES_800 0x18
153#define HEARTRATE_SAMPLES_1000 0x1C
160#define HEARTRATE_PULSE_WIDTH_200 0x00
161#define HEARTRATE_PULSE_WIDTH_400 0x01
162#define HEARTRATE_PULSE_WIDTH_800 0x02
163#define HEARTRATE_PULSE_WIDTH_1600 0x03
170#define HEARTRATE_IR_CURRENT_0 0x00
171#define HEARTRATE_IR_CURRENT_44 0x01
172#define HEARTRATE_IR_CURRENT_76 0x02
173#define HEARTRATE_IR_CURRENT_110 0x03
174#define HEARTRATE_IR_CURRENT_142 0x04
175#define HEARTRATE_IR_CURRENT_174 0x05
176#define HEARTRATE_IR_CURRENT_208 0x06
177#define HEARTRATE_IR_CURRENT_240 0x07
178#define HEARTRATE_IR_CURRENT_271 0x08
179#define HEARTRATE_IR_CURRENT_306 0x09
180#define HEARTRATE_IR_CURRENT_338 0x0A
181#define HEARTRATE_IR_CURRENT_370 0x0B
182#define HEARTRATE_IR_CURRENT_402 0x0C
183#define HEARTRATE_IR_CURRENT_436 0x0D
184#define HEARTRATE_IR_CURRENT_468 0x0E
185#define HEARTRATE_IR_CURRENT_500 0x0F
187#define HEARTRATE_RED_CURRENT_0 0x00
188#define HEARTRATE_RED_CURRENT_44 0x10
189#define HEARTRATE_RED_CURRENT_76 0x20
190#define HEARTRATE_RED_CURRENT_110 0x30
191#define HEARTRATE_RED_CURRENT_142 0x40
192#define HEARTRATE_RED_CURRENT_174 0x50
193#define HEARTRATE_RED_CURRENT_208 0x60
194#define HEARTRATE_RED_CURRENT_240 0x70
195#define HEARTRATE_RED_CURRENT_271 0x80
196#define HEARTRATE_RED_CURRENT_306 0x90
197#define HEARTRATE_RED_CURRENT_338 0xA0
198#define HEARTRATE_RED_CURRENT_370 0xB0
199#define HEARTRATE_RED_CURRENT_402 0xC0
200#define HEARTRATE_RED_CURRENT_436 0xD0
201#define HEARTRATE_RED_CURRENT_468 0xE0
202#define HEARTRATE_RED_CURRENT_500 0xF0
#define HEARTRATE_RETVAL
Definition heartrate.h:77
uint8_t hr_get_status(heartrate_t *ctx)
Function for getting the value read from the interrupt status register.
uint8_t heartrate_get_part_id(heartrate_t *ctx)
Function for getting part ID.
void hr_temp_enable(heartrate_t *ctx, bool enable)
Single temperature reading function.
void hr_heartrate_spo2_data_ready_int_enable(heartrate_t *ctx, bool enable)
Function to enable/disable the SpO2 data ready.
void heartrate_cfg_setup(heartrate_cfg_t *cfg)
Config Object Initialization function.
uint8_t hr_set_led_pulse_width(heartrate_t *ctx, uint8_t _value)
Function for setting LED pulse width.
void heartrate_read_temp(heartrate_t *ctx, uint16_t *temp_value)
Function for reading temperature.
void hr_fifo_almost_full_int_enable(heartrate_t *ctx, bool enable)
Function to enable/disable the FIFO almost full interrupt.
uint8_t hr_spo2_set_sample_rate(heartrate_t *ctx, uint8_t sample_rate)
Function for setting.
void hr_heartrate_data_ready_int_enable(heartrate_t *ctx, bool enable)
Function to enable/disable heart rate data ready interrupt.
uint8_t heartrate_get_revision_id(heartrate_t *ctx)
Function for getting revision ID.
void heartrate_set_config(heartrate_t *ctx, uint8_t cfg)
Function for configuration heartrate chip.
uint8_t hr_set_red_current_level(heartrate_t *ctx, uint8_t level)
Function for setting Red LED.
uint8_t heartrate_data_ready(heartrate_t *ctx)
Function checking if the data is ready for reading.
void hr_spo2_high_res_enable(heartrate_t *ctx, bool enable)
Function for setting the SpO2 ADC resolution.
uint8_t hr_set_ir_current_level(heartrate_t *ctx, uint8_t level)
Function for setting.
void heartrate_generic_read(heartrate_t *ctx, uint8_t reg, uint16_t len, uint8_t *data_buf)
Generic read function.
uint8_t heartrate_get_config(heartrate_t *ctx)
Function for getting configuration of the chip.
uint8_t heartrate_get_status(heartrate_t *ctx)
Function for getting status of heartrate click.
HEARTRATE_RETVAL heartrate_init(heartrate_t *ctx, heartrate_cfg_t *cfg)
Initialization function.
void heartrate_default_cfg(heartrate_t *ctx)
Click Default Configuration function.
void hr_temp_ready_int_enable(heartrate_t *ctx, bool enable)
Function to enable/disable the temperature data ready interrupt.
void heartrate_set_interrupt(heartrate_t *ctx, uint8_t intrpts)
Function for setting interrupt for heartrate click.
uint8_t hr_read_diodes(heartrate_t *ctx, uint16_t *ir_buff, uint16_t *red_buff)
Function for reading the ADC values of the IR and RED LEDs from the FIFO buffer.
void hr_shut_down(heartrate_t *ctx, bool enable)
Shut down function.
int8_t hr_set_mode(heartrate_t *ctx, uint8_t mode)
Set mode function.
void heartrate_generic_write(heartrate_t *ctx, uint8_t reg, uint16_t len, uint8_t *data_buf)
Generic write function.
void hr_reset(heartrate_t *ctx)
Reset function.
uint8_t heartrate_read_ir_red(heartrate_t *ctx, uint16_t *ir_buff, uint16_t *red_buff)
Function for reading IR and RED values.
Click configuration structure definition.
Definition heartrate.h:234
uint32_t i2c_speed
Definition heartrate.h:246
pin_name_t scl
Definition heartrate.h:237
pin_name_t int_pin
Definition heartrate.h:242
pin_name_t sda
Definition heartrate.h:238
uint8_t i2c_address
Definition heartrate.h:247
Click ctx object definition.
Definition heartrate.h:215
digital_in_t int_pin
Definition heartrate.h:218
i2c_master_t i2c
Definition heartrate.h:222
uint8_t slave_address
Definition heartrate.h:226