heartrate10 2.0.0.0
heartrate10.h
Go to the documentation of this file.
1/****************************************************************************
2** Copyright (C) 2020 MikroElektronika d.o.o.
3** Contact: https://www.mikroe.com/contact
4**
5** Permission is hereby granted, free of charge, to any person obtaining a copy
6** of this software and associated documentation files (the "Software"), to deal
7** in the Software without restriction, including without limitation the rights
8** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9** copies of the Software, and to permit persons to whom the Software is
10** furnished to do so, subject to the following conditions:
11** The above copyright notice and this permission notice shall be
12** included in all copies or substantial portions of the Software.
13**
14** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20** USE OR OTHER DEALINGS IN THE SOFTWARE.
21****************************************************************************/
22
28#ifndef HEARTRATE10_H
29#define HEARTRATE10_H
30
31#ifdef __cplusplus
32extern "C"{
33#endif
34
39#ifdef PREINIT_SUPPORTED
40#include "preinit.h"
41#endif
42
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
45 #include "delays.h"
46 #endif
47#endif
48
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_i2c_master.h"
52
73#define HEARTRATE10_REG_INT_STATUS 0x00
74#define HEARTRATE10_REG_INT_ENABLE 0x02
75#define HEARTRATE10_REG_FIFO_WR_PTR 0x04
76#define HEARTRATE10_REG_FIFO_OVF_CNT 0x05
77#define HEARTRATE10_REG_FIFO_RD_PTR 0x06
78#define HEARTRATE10_REG_FIFO_DATA 0x07
79#define HEARTRATE10_REG_FIFO_CFG 0x08
80#define HEARTRATE10_REG_MODE_CFG1 0x09
81#define HEARTRATE10_REG_MODE_CFG2 0x0A
82#define HEARTRATE10_REG_LED1_PA 0x0C
83#define HEARTRATE10_REG_LED2_PA 0x0D
84#define HEARTRATE10_REG_LED3_PA 0x0E
85#define HEARTRATE10_REG_LED4_PA 0x0F
86#define HEARTRATE10_REG_LED_RANGE 0x11
87#define HEARTRATE10_REG_PILOT_PA 0x12
88#define HEARTRATE10_REG_LED_SEQ1 0x13
89#define HEARTRATE10_REG_LED_SEQ2 0x14
90#define HEARTRATE10_REG_DAC1_CROSSTALK_CODE 0x26
91#define HEARTRATE10_REG_DAC2_CROSSTALK_CODE 0x27
92#define HEARTRATE10_REG_DAC3_CROSSTALK_CODE 0x28
93#define HEARTRATE10_REG_DAC4_CROSSTALK_CODE 0x29
94#define HEARTRATE10_REG_PROX_INT_THRESHOLD 0x30
95#define HEARTRATE10_REG_LED_COMPARATOR_EN 0x31
96#define HEARTRATE10_REG_LED_COMPARATOR_STATUS 0x32
97#define HEARTRATE10_REG_REV_ID 0xFE
98#define HEARTRATE10_REG_PART_ID 0xFF
99
100 // heartrate10_reg
101
116#define HEARTRATE10_PART_ID 0x2B
117
123#define HEARTRATE10_SET_DEV_ADDR 0x57
124
125 // heartrate10_set
126
141#define HEARTRATE10_MAP_MIKROBUS( cfg, mikrobus ) \
142 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
143 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
144 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
145
146 // heartrate10_map
147 // heartrate10
148
153typedef struct
154{
155 // Input pins
156 digital_in_t int_pin;
158 // Modules
159 i2c_master_t i2c;
161 // I2C slave address
165
170typedef struct
171{
172 pin_name_t scl;
173 pin_name_t sda;
175 pin_name_t int_pin;
177 uint32_t i2c_speed;
178 uint8_t i2c_address;
181
192
209
224
239
252err_t heartrate10_generic_write ( heartrate10_t *ctx, uint8_t reg, uint8_t tx_data );
253
266err_t heartrate10_generic_read ( heartrate10_t *ctx, uint8_t reg, uint8_t *rx_data );
267
278
287
300err_t heartrate10_fifo_read ( heartrate10_t *ctx, uint8_t *rx_buf, uint8_t rx_len );
301
314
332err_t heartrate10_read_complete_fifo_data ( heartrate10_t *ctx, uint32_t *led1, uint32_t *led2, uint32_t *led3, uint32_t *led4 );
333
334#ifdef __cplusplus
335}
336#endif
337#endif // HEARTRATE10_H
338
339 // heartrate10
340
341// ------------------------------------------------------------------------ END
uint32_t heartrate10_read_fifo_sample(heartrate10_t *ctx)
Read single sample of FIFO data.
err_t heartrate10_fifo_read(heartrate10_t *ctx, uint8_t *rx_buf, uint8_t rx_len)
Read fifo register data.
err_t heartrate10_init(heartrate10_t *ctx, heartrate10_cfg_t *cfg)
Heart Rate 10 initialization function.
err_t heartrate10_generic_read(heartrate10_t *ctx, uint8_t reg, uint8_t *rx_data)
Reading function.
err_t heartrate10_read_complete_fifo_data(heartrate10_t *ctx, uint32_t *led1, uint32_t *led2, uint32_t *led3, uint32_t *led4)
Read all led samples.
err_t heartrate10_default_cfg(heartrate10_t *ctx)
Heart Rate 10 default configuration function.
void heartrate10_reset(heartrate10_t *ctx)
Reset device.
void heartrate10_cfg_setup(heartrate10_cfg_t *cfg)
Heart Rate 10 configuration object setup function.
uint8_t heartrate10_get_int_pin(heartrate10_t *ctx)
Get interrupt pin state.
err_t heartrate10_generic_write(heartrate10_t *ctx, uint8_t reg, uint8_t tx_data)
Writing function.
heartrate10_return_value_t
Heart Rate 10 Click return value data.
Definition heartrate10.h:187
@ HEARTRATE10_OK
Definition heartrate10.h:188
@ HEARTRATE10_ERROR
Definition heartrate10.h:189
Heart Rate 10 Click configuration object.
Definition heartrate10.h:171
uint32_t i2c_speed
Definition heartrate10.h:177
pin_name_t scl
Definition heartrate10.h:172
pin_name_t int_pin
Definition heartrate10.h:175
pin_name_t sda
Definition heartrate10.h:173
uint8_t i2c_address
Definition heartrate10.h:178
Heart Rate 10 Click context object.
Definition heartrate10.h:154
digital_in_t int_pin
Definition heartrate10.h:156
i2c_master_t i2c
Definition heartrate10.h:159
uint8_t slave_address
Definition heartrate10.h:162