39#ifdef PREINIT_SUPPORTED
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_i2c_master.h"
73#define HEARTRATE11_REG_STATUS_0 0x00
74#define HEARTRATE11_REG_STATUS_1 0x01
75#define HEARTRATE11_REG_PS_DATA_0 0x02
76#define HEARTRATE11_REG_PS_DATA_1 0x03
77#define HEARTRATE11_REG_LS_CLEAR_DATA_0 0x04
78#define HEARTRATE11_REG_LS_CLEAR_DATA_1 0x05
79#define HEARTRATE11_REG_LS_CLEAR_DATA_2 0x06
80#define HEARTRATE11_REG_LS_GREEN_DATA_0 0x07
81#define HEARTRATE11_REG_LS_GREEN_DATA_1 0x08
82#define HEARTRATE11_REG_LS_GREEN_DATA_2 0x09
83#define HEARTRATE11_REG_LS_BLUE_DATA_0 0x0A
84#define HEARTRATE11_REG_LS_BLUE_DATA_1 0x0B
85#define HEARTRATE11_REG_LS_BLUE_DATA_2 0x0C
86#define HEARTRATE11_REG_LS_RED_DATA_0 0x0D
87#define HEARTRATE11_REG_LS_RED_DATA_1 0x0E
88#define HEARTRATE11_REG_LS_RED_DATA_2 0x0F
89#define HEARTRATE11_REG_COMP_DATA_0 0x10
90#define HEARTRATE11_REG_COMP_DATA_1 0x11
91#define HEARTRATE11_REG_COMP_DATA_2 0x12
92#define HEARTRATE11_REG_MAIN_CTRL_0 0x15
93#define HEARTRATE11_REG_MAIN_CTRL_1 0x16
94#define HEARTRATE11_REG_PS_LED_CURR_0 0x17
95#define HEARTRATE11_REG_PS_LED_CURR_1 0x18
96#define HEARTRATE11_REG_PS_CAN_PULSES 0x19
97#define HEARTRATE11_REG_PS_PWIDTH_PERIOD 0x1A
98#define HEARTRATE11_REG_PS_CAN_DIG_0 0x1B
99#define HEARTRATE11_REG_PS_CAN_DIG_1 0x1C
100#define HEARTRATE11_REG_PS_MOV_AVG_HYS 0x1D
101#define HEARTRATE11_REG_PS_THRES_UP_0 0x1E
102#define HEARTRATE11_REG_PS_THRES_UP_1 0x1F
103#define HEARTRATE11_REG_PS_THRES_LOW_0 0x20
104#define HEARTRATE11_REG_PS_THRES_LOW_1 0x21
105#define HEARTRATE11_REG_LS_RES_PERIOD 0x22
106#define HEARTRATE11_REG_LS_GAIN 0x23
107#define HEARTRATE11_REG_LS_THRES_UP_0 0x24
108#define HEARTRATE11_REG_LS_THRES_UP_1 0x25
109#define HEARTRATE11_REG_LS_THRES_UP_2 0x26
110#define HEARTRATE11_REG_LS_THRES_LOW_0 0x27
111#define HEARTRATE11_REG_LS_THRES_LOW_1 0x28
112#define HEARTRATE11_REG_LS_THRES_LOW_2 0x29
113#define HEARTRATE11_REG_LS_THRES_VAR 0x2A
114#define HEARTRATE11_REG_INT_CFG_0 0x2B
115#define HEARTRATE11_REG_INT_CFG_1 0x2C
116#define HEARTRATE11_REG_INT_PST 0x2D
117#define HEARTRATE11_REG_PPG_PS_GAIN 0x2E
118#define HEARTRATE11_REG_PPG_PS_CFG 0x2F
119#define HEARTRATE11_REG_PPG_IRLED_CURR_0 0x30
120#define HEARTRATE11_REG_PPG_IRLED_CURR_1 0x31
121#define HEARTRATE11_REG_PPG_RLED_CURR_0 0x32
122#define HEARTRATE11_REG_PPG_RLED_CURR_1 0x33
123#define HEARTRATE11_REG_PPG_CAN_ANA 0x34
124#define HEARTRATE11_REG_PPG_AVG 0x35
125#define HEARTRATE11_REG_PPG_PWIDTH_PERIOD 0x36
126#define HEARTRATE11_REG_FIFO_CFG 0x37
127#define HEARTRATE11_REG_FIFO_WR_PTR 0x38
128#define HEARTRATE11_REG_FIFO_RD_PTR 0x39
129#define HEARTRATE11_REG_FIFO_OVF_CNT 0x3A
130#define HEARTRATE11_REG_FIFO_DATA 0x3B
131#define HEARTRATE11_REG_PART_ID 0x3D
149#define HEARTRATE11_POR_STATUS 0x80
150#define HEARTRATE11_LS_INT_STATUS 0x02
151#define HEARTRATE11_LS_NEW_DATA 0x01
157#define HEARTRATE11_TS_DATA_STATUS 0x80
158#define HEARTRATE11_FIFO_AFULL_STATUS 0x20
159#define HEARTRATE11_PPG_DATA_STATUS 0x10
160#define HEARTRATE11_PS_LOGIC_STATUS 0x04
161#define HEARTRATE11_PS_INT_STATUS 0x02
162#define HEARTRATE11_PS_NEW_DATA 0x01
168#define HEARTRATE11_SW_RESET 0x80
169#define HEARTRATE11_LS_SAI_ON 0x08
170#define HEARTRATE11_LS_SAI_OFF 0x00
171#define HEARTRATE11_ALS_MODE 0x00
172#define HEARTRATE11_RGB_MODE 0x02
173#define HEARTRATE11_LS_OFF 0x00
174#define HEARTRATE11_LS_ON 0x01
180#define HEARTRATE11_PS_SAI_ON 0x08
181#define HEARTRATE11_PS_SAI_OFF 0x00
182#define HEARTRATE11_PS_MODE 0x00
183#define HEARTRATE11_HR_MODE 0x02
184#define HEARTRATE11_SPO2_MODE 0x04
185#define HEARTRATE11_PPG_PS_ON 0x01
186#define HEARTRATE11_PPG_PS_OFF 0x00
192#define HEARTRATE11_PS_LED 0
193#define HEARTRATE11_IR_LED 1
194#define HEARTRATE11_RED_LED 2
195#define HEARTRATE11_IR_LED_DEFAULT_CURRENT 50.0
196#define HEARTRATE11_PS_IR_LED_MAX_CURRENT 250.0
197#define HEARTRATE11_RED_LED_MAX_CURRENT 125.0
198#define HEARTRATE11_PS_IR_LED_CURRENT_RES 0x03FF
199#define HEARTRATE11_RED_LED_CURRENT_RES 0x01FF
200#define HEARTRATE11_ROUND_TO_NEAREST_INT 0.5
206#define HEARTRATE11_PS_CAN_ANA_OFF 0x00
207#define HEARTRATE11_PS_CAN_ANA_ON 0x40
208#define HEARTRATE11_PS_PULSES( x ) ( ( x ) & ( 0x07 ) ) << 3 )
209#define HEARTRATE11_PS_CAN_PULSES_RESERVED 0x02
215#define HEARTRATE11_PS_PWIDTH_26US 0x00
216#define HEARTRATE11_PS_PWIDTH_42US 0x10
217#define HEARTRATE11_PS_PWIDTH_71US 0x20
218#define HEARTRATE11_PS_RATE_3p125MS 0x00
219#define HEARTRATE11_PS_RATE_6p25MS 0x01
220#define HEARTRATE11_PS_RATE_12p5MS 0x02
221#define HEARTRATE11_PS_RATE_25MS 0x03
222#define HEARTRATE11_PS_RATE_50MS 0x04
223#define HEARTRATE11_PS_RATE_100MS 0x05
224#define HEARTRATE11_PS_RATE_200MS 0x06
225#define HEARTRATE11_PS_RATE_400MS 0x07
231#define HEARTRATE11_PS_MOV_AVG_ON 0x80
232#define HEARTRATE11_PS_MOV_AVG_OFF 0x00
233#define HEARTRATE11_PS_HYS_LEVEL( x ) ( x >> 1 )
239#define HEARTRATE11_LS_RES_20BIT_400MS 0x00
240#define HEARTRATE11_LS_RES_19BIT_200MS 0x10
241#define HEARTRATE11_LS_RES_18BIT_100MS 0x20
242#define HEARTRATE11_LS_RES_17BIT_50MS 0x30
243#define HEARTRATE11_LS_RES_16BIT_25MS 0x40
244#define HEARTRATE11_LS_RES_13BIT_3p125MS 0x50
245#define HEARTRATE11_LS_RATE_25MS 0x00
246#define HEARTRATE11_LS_RATE_50MS 0x01
247#define HEARTRATE11_LS_RATE_100MS 0x02
248#define HEARTRATE11_LS_RATE_200MS 0x03
249#define HEARTRATE11_LS_RATE_500MS 0x04
250#define HEARTRATE11_LS_RATE_1000MS 0x05
251#define HEARTRATE11_LS_RATE_2000MS 0x06
257#define HEARTRATE11_LS_GAIN_1 0x00
258#define HEARTRATE11_LS_GAIN_3 0x01
259#define HEARTRATE11_LS_GAIN_6 0x02
265#define HEARTRATE11_LS_INT_SEL_C 0x00
266#define HEARTRATE11_LS_INT_SEL_G 0x10
267#define HEARTRATE11_LS_INT_SEL_R 0x20
268#define HEARTRATE11_LS_INT_SEL_B 0x30
269#define HEARTRATE11_LS_THRES_INT_MODE 0x00
270#define HEARTRATE11_LS_VAR_INT_MODE 0x02
271#define HEARTRATE11_LS_INT_OFF 0x00
272#define HEARTRATE11_LS_INT_ON 0x01
278#define HEARTRATE11_AFULL_INT_OFF 0x00
279#define HEARTRATE11_AFULL_INT_ON 0x20
280#define HEARTRATE11_PPG_INT_OFF 0x00
281#define HEARTRATE11_PPG_INT_ON 0x10
282#define HEARTRATE11_PS_INT_LOGIC 0x02
283#define HEARTRATE11_PS_INT_OFF 0x00
284#define HEARTRATE11_PS_INT_ON 0x01
290#define HEARTRATE11_LS_PERSIST( x ) ( ( x & 0x0F ) << 4 )
291#define HEARTRATE11_PS_PERSIST( x ) ( x & 0x0F)
297#define HEARTRATE11_PPG_PS_GAIN_1 0x00
298#define HEARTRATE11_PPG_PS_GAIN_1p5 0x10
299#define HEARTRATE11_PPG_PS_GAIN_2 0x20
300#define HEARTRATE11_PPG_PS_GAIN_4 0x30
301#define HEARTRATE11_PPG_PS_GAIN_RESERVED 0x09
307#define HEARTRATE11_PPG_POW_SAVE_OFF 0x00
308#define HEARTRATE11_PPG_POW_SAVE_ON 0x40
309#define HEARTRATE11_LED_FLIP_OFF 0x00
310#define HEARTRATE11_LED_FLIP_ON 0x08
316#define HEARTRATE11_PPG_CH1_CAN_ANA_OFF 0x00
317#define HEARTRATE11_PPG_CH1_CAN_ANA_ON 0x04
318#define HEARTRATE11_PPG_CH2_CAN_ANA_OFF 0x00
319#define HEARTRATE11_PPG_CH2_CAN_ANA_ON 0x04
325#define HEARTRATE11_PPG_AVG_1 0x00
326#define HEARTRATE11_PPG_AVG_2 0x10
327#define HEARTRATE11_PPG_AVG_4 0x20
328#define HEARTRATE11_PPG_AVG_8 0x30
329#define HEARTRATE11_PPG_AVG_16 0x40
330#define HEARTRATE11_PPG_AVG_32 0x50
331#define HEARTRATE11_PPG_AVG_RESERVED 0x0A
337#define HEARTRATE11_PPG_PWIDTH_130US 0x30
338#define HEARTRATE11_PPG_PWIDTH_247US 0x40
339#define HEARTRATE11_PPG_PWIDTH_481US 0x50
340#define HEARTRATE11_PPG_PWIDTH_949US 0x60
341#define HEARTRATE11_PPG_RATE_0p3125MS 0x00
342#define HEARTRATE11_PPG_RATE_0p625MS 0x01
343#define HEARTRATE11_PPG_RATE_1MS 0x02
344#define HEARTRATE11_PPG_RATE_1p25MS 0x03
345#define HEARTRATE11_PPG_RATE_2p5MS 0x04
346#define HEARTRATE11_PPG_RATE_5MS 0x05
347#define HEARTRATE11_PPG_RATE_10MS 0x06
348#define HEARTRATE11_PPG_RATE_20MS 0x07
354#define HEARTRATE11_FIFO_ROLL_OFF 0x00
355#define HEARTRATE11_FIFO_ROLL_ON 0x10
356#define HEARTRATE11_FIFO_AFULL_WARNING( x ) ( x & 0x0F )
362#define HEARTRATE11_FIFO_INDEX( x ) ( x & 0x1F )
369#define HEARTRATE11_DEVICE_ADDRESS 0x53
387#define HEARTRATE11_MAP_MIKROBUS( cfg, mikrobus ) \
388 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
389 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
390 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
err_t heartrate11_reset_device(heartrate11_t *ctx)
Heart Rate 11 reset device function.
uint8_t heartrate11_get_int_pin(heartrate11_t *ctx)
Heart Rate 11 get int pin function.
err_t heartrate11_read_register(heartrate11_t *ctx, uint8_t reg, uint8_t *data_out)
Heart Rate 11 read register function.
err_t heartrate11_read_fifo(heartrate11_t *ctx, uint32_t *fifo_data)
Heart Rate 11 read fifo function.
err_t heartrate11_default_cfg(heartrate11_t *ctx)
Heart Rate 11 default configuration function.
err_t heartrate11_generic_read(heartrate11_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
Heart Rate 11 I2C reading function.
err_t heartrate11_generic_write(heartrate11_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
Heart Rate 11 I2C writing function.
void heartrate11_cfg_setup(heartrate11_cfg_t *cfg)
Heart Rate 11 configuration object setup function.
err_t heartrate11_write_register(heartrate11_t *ctx, uint8_t reg, uint8_t data_in)
Heart Rate 11 write register function.
err_t heartrate11_init(heartrate11_t *ctx, heartrate11_cfg_t *cfg)
Heart Rate 11 initialization function.
err_t heartrate11_set_led_current(heartrate11_t *ctx, uint8_t led, float current)
Heart Rate 11 set led current function.
heartrate11_return_value_t
Heart Rate 11 Click return value data.
Definition heartrate11.h:433
@ HEARTRATE11_OK
Definition heartrate11.h:434
@ HEARTRATE11_ERROR
Definition heartrate11.h:435
Heart Rate 11 Click configuration object.
Definition heartrate11.h:417
uint32_t i2c_speed
Definition heartrate11.h:423
pin_name_t scl
Definition heartrate11.h:418
pin_name_t int_pin
Definition heartrate11.h:421
pin_name_t sda
Definition heartrate11.h:419
uint8_t i2c_address
Definition heartrate11.h:424
Heart Rate 11 Click context object.
Definition heartrate11.h:400
digital_in_t int_pin
Definition heartrate11.h:402
i2c_master_t i2c
Definition heartrate11.h:405
uint8_t slave_address
Definition heartrate11.h:408