heartrate2 2.0.0.0
heartrate2.h
Go to the documentation of this file.
1/*
2 * MikroSDK - MikroE Software Development Kit
3 * Copyright© 2020 MikroElektronika d.o.o.
4 *
5 * Permission is hereby granted, free of charge, to any person
6 * obtaining a copy of this software and associated documentation
7 * files (the "Software"), to deal in the Software without restriction,
8 * including without limitation the rights to use, copy, modify, merge,
9 * publish, distribute, sublicense, and/or sell copies of the Software,
10 * and to permit persons to whom the Software is furnished to do so,
11 * subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
22 * OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
33// ----------------------------------------------------------------------------
34
35#ifndef HEARTRATE2_H
36#define HEARTRATE2_H
37
42#ifdef PREINIT_SUPPORTED
43#include "preinit.h"
44#endif
45
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
48 #include "delays.h"
49 #endif
50#endif
51
52#include "drv_digital_out.h"
53#include "drv_digital_in.h"
54#include "drv_i2c_master.h"
55
56// -------------------------------------------------------------- PUBLIC MACROS
66#define HEARTRATE2_MAP_MIKROBUS( cfg, mikrobus ) \
67 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
68 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
69 cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN ); \
70 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
71 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
78#define HEARTRATE2_RETVAL uint8_t
79
80#define HEARTRATE2_OK_OK 0x00
81#define HEARTRATE2_INIT_ERROR 0xFF
88#define HEARTRATE2_SLAVE_ADDRESS 0x62
95#define HEARTRATE2_REG_INT_STATUS_1 0x00
96#define HEARTRATE2_REG_INT_STATUS_2 0x01
97#define HEARTRATE2_REG_INT_ENABLE_1 0x02
98#define HEARTRATE2_REG_INT_ENABLE_2 0x03
99#define HEARTRATE2_REG_FIFO_WRITE_PTR 0x04
100#define HEARTRATE2_REG_FIFO_READ_PTR 0x05
101#define HEARTRATE2_REG_OVERFLOW_CNT 0x06
102#define HEARTRATE2_REG_FIFO_DATA_CNT 0x07
103#define HEARTRATE2_REG_FIFO_DATA_REG 0x08
104#define HEARTRATE2_REG_FIFO_CFG_1 0x09
105#define HEARTRATE2_REG_FIFO_CFG_2 0x0A
106#define HEARTRATE2_REG_SYSTEM_CTRL 0x0D
107#define HEARTRATE2_REG_PPG_SYNC_CTRL 0x10
108#define HEARTRATE2_REG_PPG_CFG_1 0x11
109#define HEARTRATE2_REG_PPG_CFG_2 0x12
110#define HEARTRATE2_REG_PPG_CFG_3 0x13
111#define HEARTRATE2_REG_PROX_INT_THRESHOLD 0x14
112#define HEARTRATE2_REG_PHOTO_DIODE_BIAS 0x15
113#define HEARTRATE2_REG_PICKET_FENCE 0x16
114#define HEARTRATE2_REG_LED_SQUENCE_REG_1 0x20
115#define HEARTRATE2_REG_LED_SQUENCE_REG_2 0x21
116#define HEARTRATE2_REG_LED_SQUENCE_REG_3 0x22
117#define HEARTRATE2_REG_LED_1_PA 0x23
118#define HEARTRATE2_REG_LED_2_PA 0x24
119#define HEARTRATE2_REG_LED_3_PA 0x25
120#define HEARTRATE2_REG_LED_PILOT_PA 0x29
121#define HEARTRATE2_REG_LED_RANGE_1 0x2A
122#define HEARTRATE2_REG_S1_HI_RES_DAC_1 0x2C
123#define HEARTRATE2_REG_S2_HI_RES_DAC_1 0x2D
124#define HEARTRATE2_REG_S3_HI_RES_DAC_1 0x2E
125#define HEARTRATE2_REG_S4_HI_RES_DAC_1 0x2F
126#define HEARTRATE2_REG_S5_HI_RES_DAC_1 0x30
127#define HEARTRATE2_REG_S6_HI_RES_DAC_1 0x31
128#define HEARTRATE2_REG_DIE_TEMP_CFG 0x40
129#define HEARTRATE2_REG_DIE_TEMP_INT 0x41
130#define HEARTRATE2_REG_DIE_TEMP_FRAC 0x42
131#define HEARTRATE2_REG_DAC_CALIBRATION_EN 0x50
132#define HEARTRATE2_REG_SHA_CMD 0xF0
133#define HEARTRATE2_REG_SHA_CFG 0xF1
134#define HEARTRATE2_REG_MEM_CTRL 0xF2
135#define HEARTRATE2_REG_MEM_INDEX 0xF3
136#define HEARTRATE2_REG_MEM_DATA 0xF4
137#define HEARTRATE2_REG_REV_ID 0xFE
138#define HEARTRATE2_REG_PART_ID 0xFF
145#define HEARTRATE2_SYS_CTRL_SW_RESET 0x01
146#define HEARTRATE2_SYS_CTRL_SHUT_DOWN 0x02
147#define HEARTRATE2_SYS_CTRL_POWER_ON 0x00
148#define HEARTRATE2_SYS_CTRL_LOW_PWR_MODE 0x04
149#define HEARTRATE2_SYS_CTRL_SINGLE_PPG 0x08
150#define HEARTRATE2_SYS_CTRL_DUAL_PPG 0x00
157#define HEARTRATE2_PPG_CFG_1_ALC_ENABLE 0x00
158#define HEARTRATE2_PPG_CFG_1_ALC_DISABLE 0x80
159#define HEARTRATE2_PPG_CFG_1_ADD_OFFSET 0x40
160#define HEARTRATE2_PPG_CFG_1_NO_OFFSET 0x00
161#define HEARTRATE2_PPG_CFG_1_ADC_RANGE_4096 0x00
162#define HEARTRATE2_PPG_CFG_1_ADC_RANGE_8192 0x04
163#define HEARTRATE2_PPG_CFG_1_ADC_RANGE_16384 0x08
164#define HEARTRATE2_PPG_CFG_1_ADC_RANGE_32768 0x0C
165#define HEARTRATE2_PPG_CFG_1_PPG_TINT_21p3 0x00
166#define HEARTRATE2_PPG_CFG_1_PPG_TINT_35p9 0x01
167#define HEARTRATE2_PPG_CFG_1_PPG_TINT_65p2 0x02
168#define HEARTRATE2_PPG_CFG_1_PPG_TINT_123p8 0x03
175#define HEARTRATE2_PPG_CFG_2_CLK_FREQ_24p995_N1 0x00
176#define HEARTRATE2_PPG_CFG_2_CLK_FREQ_50p027_N1 0x08
177#define HEARTRATE2_PPG_CFG_2_CLK_FREQ_84p021_N1 0x10
178#define HEARTRATE2_PPG_CFG_2_CLK_FREQ_99p902_N1 0x18
179#define HEARTRATE2_PPG_CFG_2_CLK_FREQ_199p805_N1 0x20
180#define HEARTRATE2_PPG_CFG_2_CLK_FREQ_399p610_N1 0x28
181#define HEARTRATE2_PPG_CFG_2_CLK_FREQ_24p995_N2 0x30
182#define HEARTRATE2_PPG_CFG_2_CLK_FREQ_50p027_N2 0x38
183#define HEARTRATE2_PPG_CFG_2_CLK_FREQ_84p021_N2 0x40
184#define HEARTRATE2_PPG_CFG_2_CLK_FREQ_99p902_N2 0x48
185#define HEARTRATE2_PPG_CFG_2_CLK_FREQ_8p000_N1 0x50
186#define HEARTRATE2_PPG_CFG_2_CLK_FREQ_16p000_N1 0x58
187#define HEARTRATE2_PPG_CFG_2_CLK_FREQ_32p000_N1 0x60
188#define HEARTRATE2_PPG_CFG_2_CLK_FREQ_64p000_N1 0x68
189#define HEARTRATE2_PPG_CFG_2_CLK_FREQ_128p000_N1 0x70
190#define HEARTRATE2_PPG_CFG_2_CLK_FREQ_256p000_N1 0x78
191#define HEARTRATE2_PPG_CFG_2_CLK_FREQ_512p000_N1 0x80
192#define HEARTRATE2_PPG_CFG_2_CLK_FREQ_1024p000_N1 0x88
193#define HEARTRATE2_PPG_CFG_2_CLK_FREQ_2048p000_N1 0x90
194#define HEARTRATE2_PPG_CFG_2_CLK_FREQ_4096p000_N1 0x98
195#define HEARTRATE2_PPG_CFG_2_SMP_AVG_1 0x00
196#define HEARTRATE2_PPG_CFG_2_SMP_AVG_2 0x01
197#define HEARTRATE2_PPG_CFG_2_SMP_AVG_4 0x02
198#define HEARTRATE2_PPG_CFG_2_SMP_AVG_8 0x03
199#define HEARTRATE2_PPG_CFG_2_SMP_AVG_16 0x04
200#define HEARTRATE2_PPG_CFG_2_SMP_AVG_32 0x05
201#define HEARTRATE2_PPG_CFG_2_SMP_AVG_64 0x06
202#define HEARTRATE2_PPG_CFG_2_SMP_AVG_128 0x07
209#define HEARTRATE2_PPG_CFG_3_LED_SETLNG_4 0x00
210#define HEARTRATE2_PPG_CFG_3_LED_SETLNG_6 0x40
211#define HEARTRATE2_PPG_CFG_3_LED_SETLNG_8 0x80
212#define HEARTRATE2_PPG_CFG_3_LED_SETLNG_12 0xC0
213#define HEARTRATE2_PPG_CFG_3_FILTER_CDM 0x00
214#define HEARTRATE2_PPG_CFG_3_FILTER_FDM 0x20
215#define HEARTRATE2_PPG_CFG_3_BURST_RATE_8HZ 0x00
216#define HEARTRATE2_PPG_CFG_3_BURST_RATE_32HZ 0x02
217#define HEARTRATE2_PPG_CFG_3_BURST_RATE_84HZ 0x04
218#define HEARTRATE2_PPG_CFG_3_BURST_RATE_256HZ 0x06
219#define HEARTRATE2_PPG_CFG_3_BURST_ENABLE 0x01
220#define HEARTRATE2_PPG_CFG_3_BURST_DISABLE 0x00
227#define HEARTRATE2_PHOTO_DIODE_BIAS1_0_65_PF 0x01
228#define HEARTRATE2_PHOTO_DIODE_BIAS1_65_130_PF 0x05
229#define HEARTRATE2_PHOTO_DIODE_BIAS1_130_260_PF 0x06
230#define HEARTRATE2_PHOTO_DIODE_BIAS1_260_520_PF 0x07
231#define HEARTRATE2_PHOTO_DIODE_BIAS2_0_65_PF 0x10
232#define HEARTRATE2_PHOTO_DIODE_BIAS2_65_130_PF 0x50
233#define HEARTRATE2_PHOTO_DIODE_BIAS2_130_260_PF 0x60
234#define HEARTRATE2_PHOTO_DIODE_BIAS2_260_520_PF 0x70
241#define HEARTRATE2_LED_RANGE1_LED1_CURRENT_31_MA 0x00
242#define HEARTRATE2_LED_RANGE1_LED1_CURRENT_62_MA 0x01
243#define HEARTRATE2_LED_RANGE1_LED1_CURRENT_93_MA 0x02
244#define HEARTRATE2_LED_RANGE1_LED1_CURRENT_124_MA 0x03
245#define HEARTRATE2_LED_RANGE1_LED2_CURRENT_31_MA 0x00
246#define HEARTRATE2_LED_RANGE1_LED2_CURRENT_62_MA 0x04
247#define HEARTRATE2_LED_RANGE1_LED2_CURRENT_93_MA 0x08
248#define HEARTRATE2_LED_RANGE1_LED2_CURRENT_124_MA 0x0C
249#define HEARTRATE2_LED_RANGE1_LED3_CURRENT_31_MA 0x00
250#define HEARTRATE2_LED_RANGE1_LED3_CURRENT_62_MA 0x10
251#define HEARTRATE2_LED_RANGE1_LED3_CURRENT_93_MA 0x20
252#define HEARTRATE2_LED_RANGE1_LED3_CURRENT_124_MA 0x30
259#define HEARTRATE2_FIFO_CFG_2_FLUSH_FIFO 0x10
260#define HEARTRATE2_FIFO_CFG_2_FIFO_READ_DATA_CLR 0x08
261#define HEARTRATE2_FIFO_CFG_2_FIFO_STAT_DATA_CLR 0x00
262#define HEARTRATE2_FIFO_CFG_2_FULL_TYPE_RPT 0x00
263#define HEARTRATE2_FIFO_CFG_2_FULL_TYPE_ONCE 0x04
264#define HEARTRATE2_FIFO_CFG_2_FIFO_ROLL_OVER 0x02
265#define HEARTRATE2_FIFO_CFG_2_FIFO_STOP 0x00
272#define HEARTRATE2_INT_1_FULL 0x80
273#define HEARTRATE2_INT_1_NOT_FULL 0x00
274#define HEARTRATE2_INT_1_DATA_RDY 0x40
275#define HEARTRATE2_INT_1_DATA_NOT_RDY 0x00
276#define HEARTRATE2_INT_1_ALC_OVERFLOW 0x20
277#define HEARTRATE2_INT_1_ALC_NORMAL 0x00
278#define HEARTRATE2_INT_1_PROXIMITY_INT 0x10
279#define HEARTRATE2_INT_1_PROXIMITY_NORMAL 0x00
280#define HEARTRATE2_INT_1_LED_COMPLIANT 0x08
281#define HEARTRATE2_INT_1_LED_NOT_COMPLIANT 0x00
282#define HEARTRATE2_INT_1_DIE_TEMP_RDY 0x04
283#define HEARTRATE2_INT_1_DIE_TEMP_NOT_RDY 0x00
284#define HEARTRATE2_INT_1_PWR_RDY 0x01
285#define HEARTRATE2_INT_1_PWR_NOT_RDY 0x00
292#define HEARTRATE2_INT_1_FULL 0x80
293#define HEARTRATE2_INT_1_NOT_FULL 0x00
294#define HEARTRATE2_INT_1_DATA_RDY 0x40
295#define HEARTRATE2_INT_1_DATA_NOT_RDY 0x00
296#define HEARTRATE2_INT_1_ALC_OVERFLOW 0x20
297#define HEARTRATE2_INT_1_ALC_NORMAL 0x00
298#define HEARTRATE2_INT_1_PROXIMITY_INT 0x10
299#define HEARTRATE2_INT_1_PROXIMITY_NORMAL 0x00
300#define HEARTRATE2_INT_1_LED_COMPLIANT 0x08
301#define HEARTRATE2_INT_1_LED_NOT_COMPLIANT 0x00
302#define HEARTRATE2_INT_1_DIE_TEMP_RDY 0x04
303#define HEARTRATE2_INT_1_DIE_TEMP_NOT_RDY 0x00
304#define HEARTRATE2_INT_1_PWR_RDY 0x01
305#define HEARTRATE2_INT_1_PWR_NOT_RDY 0x00
306#define HEARTRATE2_INT_2_SHA_AUTHENTICATION_DONE 0x01
307#define HEARTRATE2_INT_2_SHA_AUTHENTICATION_NOT_DONE 0x00
314#define HEARTRATE2_FIFO_TAG_PPG1_LEDC1 0x01
315#define HEARTRATE2_FIFO_TAG_PPG1_LEDC2 0x02
316#define HEARTRATE2_FIFO_TAG_PPG1_LEDC3 0x03
317#define HEARTRATE2_FIFO_TAG_PPG1_LEDC4 0x04
318#define HEARTRATE2_FIFO_TAG_PPG1_LEDC5 0x05
319#define HEARTRATE2_FIFO_TAG_PPG1_LEDC6 0x06
320#define HEARTRATE2_FIFO_TAG_PPF1_LEDC1 0x0D
321#define HEARTRATE2_FIFO_TAG_PPF1_LEDC2 0x0E
322#define HEARTRATE2_FIFO_TAG_PPF1_LEDC3 0x0F
323#define HEARTRATE2_FIFO_TAG_PROX1 0x19
324#define HEARTRATE2_FIFO_TAG_SUB_DAC_UPDATE 0x1D
325#define HEARTRATE2_FIFO_TAG_INVALID_DATA 0x1E
326#define HEARTRATE2_FIFO_TAG_TIME_STAMP 0x1F
333#define HEARTRATE2_LEDSQ_GREEN 0x1
334#define HEARTRATE2_LEDSQ_IR 0x2
335#define HEARTRATE2_LEDSQ_RED 0x3
336#define HEARTRATE2_LEDSQ_PILOT_LED1 0x8
337#define HEARTRATE2_LEDSQ_DIRECT_AMBIENT 0x9
338#define HEARTRATE2_LEDSQ_OFF 0x0
345#define HEARTRATE2_DEV_ID 0x36
346#define HEARTRATE2_ERROR 0xEE
347#define HEARTRATE2_OK 0xFF
354#define HEARTRATE2_INT_ENABLE 0x01
355#define HEARTRATE2_INT_DISABLE 0x00
362#define HEARTRATE2_PPG_CFG_ALC_EN 0x01
363#define HEARTRATE2_PPG_CFG_ALC_DS 0x00
370#define HEARTRATE2_PPG_CFG_OFFSET_ADD 0x01
371#define HEARTRATE2_PPG_CFG_OFFSET_NO 0x00
378#define HEARTRATE2_PPG_CFG_TINT_14p8_US 0x00
379#define HEARTRATE2_PPG_CFG_TINT_29p4_US 0x01
380#define HEARTRATE2_PPG_CFG_TINT_58p7_US 0x02
381#define HEARTRATE2_PPG_CFG_TINT_117p3_US 0x03
388#define HEARTRATE2_PPG_CFG_LED_RANGE_4k 0x00
389#define HEARTRATE2_PPG_CFG_LED_RANGE_8k 0x01
390#define HEARTRATE2_PPG_CFG_LED_RANGE_16k 0x02
391#define HEARTRATE2_PPG_CFG_LED_RANGE_32k 0x03
398#define HEARTRATE2_PPG_CFG_SMP_RATE_P1_24sps 0x00
399#define HEARTRATE2_PPG_CFG_SMP_RATE_P1_50sps 0x01
400#define HEARTRATE2_PPG_CFG_SMP_RATE_P1_84sps 0x02
401#define HEARTRATE2_PPG_CFG_SMP_RATE_P1_99sps 0x03
402#define HEARTRATE2_PPG_CFG_SMP_RATE_P1_199sps 0x04
403#define HEARTRATE2_PPG_CFG_SMP_RATE_P1_399sps 0x05
404#define HEARTRATE2_PPG_CFG_SMP_RATE_P2_24sps 0x06
405#define HEARTRATE2_PPG_CFG_SMP_RATE_P2_50sps 0x07
406#define HEARTRATE2_PPG_CFG_SMP_RATE_P2_84sps 0x08
407#define HEARTRATE2_PPG_CFG_SMP_RATE_P2_99sps 0x09
408#define HEARTRATE2_PPG_CFG_SMP_RATE_P1_8sps 0x0A
409#define HEARTRATE2_PPG_CFG_SMP_RATE_P1_16sps 0x0B
410#define HEARTRATE2_PPG_CFG_SMP_RATE_P1_32sps 0x0C
411#define HEARTRATE2_PPG_CFG_SMP_RATE_P1_64sps 0x0D
412#define HEARTRATE2_PPG_CFG_SMP_RATE_P1_128sps 0x0E
413#define HEARTRATE2_PPG_CFG_SMP_RATE_P1_256sps 0x0F
414#define HEARTRATE2_PPG_CFG_SMP_RATE_P1_512sps 0x10
415#define HEARTRATE2_PPG_CFG_SMP_RATE_P1_1024sps 0x11
416#define HEARTRATE2_PPG_CFG_SMP_RATE_P1_2048sps 0x12
417#define HEARTRATE2_PPG_CFG_SMP_RATE_P1_4096sps 0x13
424#define HEARTRATE2_PPG_CFG_SMP_AVG_1 0x00
425#define HEARTRATE2_PPG_CFG_SMP_AVG_2 0x01
426#define HEARTRATE2_PPG_CFG_SMP_AVG_4 0x02
427#define HEARTRATE2_PPG_CFG_SMP_AVG_8 0x03
428#define HEARTRATE2_PPG_CFG_SMP_AVG_16 0x04
429#define HEARTRATE2_PPG_CFG_SMP_AVG_32 0x05
430#define HEARTRATE2_PPG_CFG_SMP_AVG_64 0x06
431#define HEARTRATE2_PPG_CFG_SMP_AVG_128 0x07
438#define HEARTRATE2_LED_RANGE_CURRENT_31_MA 0x00
439#define HEARTRATE2_LED_RANGE_CURRENT_62_MA 0x01
440#define HEARTRATE2_LED_RANGE_CURRENT_93_MA 0x02
441#define HEARTRATE2_LED_RANGE_CURRENT_124_MA 0x03
448#define HEARTRATE2_CONFIG_GREEN 0xAA
449#define HEARTRATE2_CONFIG_IR 0xBB
450#define HEARTRATE2_CONFIG_RED 0xCC
457#define HEARTRATE2_PIN_HIGH 1
458#define HEARTRATE2_PIN_LOW 0
465#define HEARTRATE2_TEMPERATURE_RESOLUTION 0.0625f
466#define HEARTRATE2_TEMPERATURE_MASK 0x0F
473#define HEARTRATE2_FIFO_DATA_MASK 0x07FFFF
474#define HEARTRATE2_FIFO_RES 19
475#define HEARTRATE2_FIFO_TAG_MASK 0x1F
482#define HEARTRATE2_LEDSQ_SHIFT 4
489#define HEARTRATE2_INT_SHIFT_FULL 7
490#define HEARTRATE2_INT_SHIFT_DATA_RDY 6
491#define HEARTRATE2_INT_SHIFT_ALC_OVF 5
492#define HEARTRATE2_INT_SHIFT_PROXY 4
493#define HEARTRATE2_INT_SHIFT_LED_COMPLIANT 3
494#define HEARTRATE2_INT_SHIFT_DIE_TEMEP 2
495#define HEARTRATE2_INT_SHIFT_PWR_RDY 0
496#define HEARTRATE2_INT_SHIFT_SHA 0
497#define HEARTRATE2_INT_MASK 0x01
504#define HEARTRATE2_PPG_CFG_ALC 7
505#define HEARTRATE2_PPG_CFG_OFFSET 6
506#define HEARTRATE2_PPG_CFG_ADC_RANGE 2
507#define HEARTRATE2_PPG_CFG_TINT 0
508#define HEARTRATE2_PPG_CFG_SMP_RATE 3
509#define HEARTRATE2_PPG_CFG_SMP_AVG 0
516#define HEARTRATE2_LED_RANGE_SHIFT_GREEN 0
517#define HEARTRATE2_LED_RANGE_SHIFT_IR 2
518#define HEARTRATE2_LED_RANGE_SHIFT_RED 4
521 // End group macro
522// --------------------------------------------------------------- PUBLIC TYPES
531typedef struct
532{
533 uint32_t data_val;
534 uint8_t tag;
536
540typedef struct
541{
542 uint8_t ledsq1;
543 uint8_t ledsq2;
544 uint8_t ledsq3;
545 uint8_t ledsq4;
546 uint8_t ledsq5;
547 uint8_t ledsq6;
549
553typedef struct
554{
555 uint8_t green;
556 uint8_t ir;
557 uint8_t red;
559
563typedef struct
564{
565 uint8_t green;
566 uint8_t ir;
567 uint8_t red;
569
573typedef struct
574{
575 uint8_t alc;
576 uint8_t offset;
577 uint8_t ppg_tint;
578 uint8_t led_range;
579 uint8_t smp_rate;
580 uint8_t smp_freq;
582
586typedef struct
587{
588 uint8_t full_fifo;
589 uint8_t data_rdy;
590 uint8_t alc_ovf;
591 uint8_t proxy;
593 uint8_t die_temp;
594 uint8_t pwr_rdy;
595 uint8_t sha;
597
601typedef struct
602{
603 // Output pins
604
605 digital_out_t cs;
606
607 // Input pins
608
609 digital_in_t an;
610 digital_in_t int_pin;
611
612 // Modules
613
614 i2c_master_t i2c;
615
616 // ctx variable
617
619
621
625typedef struct
626{
627 // Communication gpio pins
628
629 pin_name_t scl;
630 pin_name_t sda;
631
632 // Additional gpio pins
633
634 pin_name_t an;
635 pin_name_t cs;
636 pin_name_t int_pin;
637
638 // static variable
639
640 uint32_t i2c_speed;
641 uint8_t i2c_address;
642
644
645 // End types group
646// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
647
653#ifdef __cplusplus
654extern "C"{
655#endif
656
666
676
688void heartrate2_default_cfg ( heartrate2_t *ctx, uint8_t cfg_led );
689
699void heartrate2_generic_write ( heartrate2_t *ctx, uint8_t reg_adr, uint8_t write_data );
700
709uint8_t heartrate2_generic_read ( heartrate2_t *ctx, uint8_t reg_adr );
710
721void heartrate2_read_buf ( heartrate2_t *ctx, uint8_t reg_adr, uint8_t *read_buf, uint8_t buf_size );
722
732
744
753
765
775
787
799
811
821
830
839
847void heartrate2_set_en ( heartrate2_t *ctx, uint8_t state );
848
849#ifdef __cplusplus
850}
851#endif
852#endif // _HEARTRATE2_H_
853
854 // End public_function group
856
857// ------------------------------------------------------------------------- END
#define HEARTRATE2_RETVAL
Definition heartrate2.h:78
void heartrate2_generic_write(heartrate2_t *ctx, uint8_t reg_adr, uint8_t write_data)
Generic write function.
void heartrate2_ledpa_config(heartrate2_t *ctx, heartrate2_ledpa_t *ledpa)
Function for configurating led pa registers.
uint8_t heartrate2_get_int(heartrate2_t *ctx)
Function for reading int pin status.
uint8_t heartrate2_led_sequence_config(heartrate2_t *ctx, heartrate2_ledsq_cfg_t *ledsq)
Function for configurating led sequence registers.
void heartrate2_read_buf(heartrate2_t *ctx, uint8_t reg_adr, uint8_t *read_buf, uint8_t buf_size)
Function for reading data buffer from registar.
void heartrate2_int_status(heartrate2_t *ctx, heartrate2_int_t *int_status)
Function for reading interrupt status.
uint8_t heartrate2_get_gp(heartrate2_t *ctx)
Function for reading gp pin status.
uint8_t heartrate2_int_control(heartrate2_t *ctx, heartrate2_int_t *int_ctrl)
Function for configurating interrupt registers.
float heartrate2_read_temp(heartrate2_t *ctx)
Function for reading temperature of device.
void heartrate2_cfg_setup(heartrate2_cfg_t *cfg)
Config Object Initialization function.
void heartrate2_soft_reset(heartrate2_t *ctx)
Function for restarting device.
void heartrate2_read_fifo(heartrate2_t *ctx, heartrate2_fifo_data_t *fifo)
Generic function for reading data from fifo registar.
void heartrate2_default_cfg(heartrate2_t *ctx, uint8_t cfg_led)
Click Default Configuration function.
uint8_t heartrate2_generic_read(heartrate2_t *ctx, uint8_t reg_adr)
Generic read function.
void heartrate2_set_en(heartrate2_t *ctx, uint8_t state)
Function for setting en pin status.
uint8_t heartrate2_led_range_curr_config(heartrate2_t *ctx, heartrate2_led_range_curr_t *led_range)
Function for configurating led current range registers.
uint8_t heartrate2_ppg_config(heartrate2_t *ctx, heartrate2_ppg_cfg_t *ppg_cfg)
Function for configurating ppg registers.
HEARTRATE2_RETVAL heartrate2_init(heartrate2_t *ctx, heartrate2_cfg_t *cfg)
Initialization function.
Click configuration structure definition.
Definition heartrate2.h:626
uint32_t i2c_speed
Definition heartrate2.h:640
pin_name_t scl
Definition heartrate2.h:629
pin_name_t int_pin
Definition heartrate2.h:636
pin_name_t sda
Definition heartrate2.h:630
pin_name_t an
Definition heartrate2.h:634
pin_name_t cs
Definition heartrate2.h:635
uint8_t i2c_address
Definition heartrate2.h:641
Structure for reading fifo data.
Definition heartrate2.h:532
uint8_t tag
Definition heartrate2.h:534
uint32_t data_val
Definition heartrate2.h:533
Structure for interrupt status.
Definition heartrate2.h:587
uint8_t proxy
Definition heartrate2.h:591
uint8_t alc_ovf
Definition heartrate2.h:590
uint8_t die_temp
Definition heartrate2.h:593
uint8_t data_rdy
Definition heartrate2.h:589
uint8_t sha
Definition heartrate2.h:595
uint8_t pwr_rdy
Definition heartrate2.h:594
uint8_t led_compliant
Definition heartrate2.h:592
uint8_t full_fifo
Definition heartrate2.h:588
Structure setting led current range.
Definition heartrate2.h:564
uint8_t green
Definition heartrate2.h:565
uint8_t ir
Definition heartrate2.h:566
uint8_t red
Definition heartrate2.h:567
Structure led brightness.
Definition heartrate2.h:554
uint8_t green
Definition heartrate2.h:555
uint8_t ir
Definition heartrate2.h:556
uint8_t red
Definition heartrate2.h:557
Structure configurating led sequence.
Definition heartrate2.h:541
uint8_t ledsq4
Definition heartrate2.h:545
uint8_t ledsq3
Definition heartrate2.h:544
uint8_t ledsq1
Definition heartrate2.h:542
uint8_t ledsq6
Definition heartrate2.h:547
uint8_t ledsq2
Definition heartrate2.h:543
uint8_t ledsq5
Definition heartrate2.h:546
Structure configurating ppg.
Definition heartrate2.h:574
uint8_t smp_rate
Definition heartrate2.h:579
uint8_t led_range
Definition heartrate2.h:578
uint8_t alc
Definition heartrate2.h:575
uint8_t smp_freq
Definition heartrate2.h:580
uint8_t ppg_tint
Definition heartrate2.h:577
uint8_t offset
Definition heartrate2.h:576
Click ctx object definition.
Definition heartrate2.h:602
digital_out_t cs
Definition heartrate2.h:605
digital_in_t int_pin
Definition heartrate2.h:610
i2c_master_t i2c
Definition heartrate2.h:614
digital_in_t an
Definition heartrate2.h:609
uint8_t slave_address
Definition heartrate2.h:618