heartrate5 2.0.0.0
heartrate5.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 HEARTRATE5_H
29#define HEARTRATE5_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
77#define HEARTRATE5_REG0H 0x00
78#define HEARTRATE5_REG1H 0x01
79#define HEARTRATE5_REG2H 0x02
80#define HEARTRATE5_REG3H 0x03
81#define HEARTRATE5_REG4H 0x04
82#define HEARTRATE5_REG5H 0x05
83#define HEARTRATE5_REG6H 0x06
84#define HEARTRATE5_REG7H 0x07
85#define HEARTRATE5_REG8H 0x08
86#define HEARTRATE5_REG9H 0x09
87#define HEARTRATE5_REGAH 0x0A
88#define HEARTRATE5_REGBH 0x0B
89#define HEARTRATE5_REGCH 0x0C
90#define HEARTRATE5_REGDH 0x0D
91#define HEARTRATE5_REGEH 0x0E
92#define HEARTRATE5_REGFH 0x0F
93#define HEARTRATE5_REG10H 0x10
94#define HEARTRATE5_REG11H 0x11
95#define HEARTRATE5_REG12H 0x12
96#define HEARTRATE5_REG13H 0x13
97#define HEARTRATE5_REG14H 0x14
98#define HEARTRATE5_REG15H 0x15
99#define HEARTRATE5_REG16H 0x16
100#define HEARTRATE5_REG17H 0x17
101#define HEARTRATE5_REG18H 0x18
102#define HEARTRATE5_REG19H 0x19
103#define HEARTRATE5_REG1AH 0x1A
104#define HEARTRATE5_REG1BH 0x1B
105#define HEARTRATE5_REG1CH 0x1C
106
107#define HEARTRATE5_REG1DH 0x1D
108#define HEARTRATE5_REG1EH 0x1E
109#define HEARTRATE5_REG20H 0x20
110#define HEARTRATE5_REG21H 0x21
111#define HEARTRATE5_REG22H 0x22
112#define HEARTRATE5_REG23H 0x23
113#define HEARTRATE5_REG29H 0x29
114
115#define HEARTRATE5_REG2AH 0x2A
116#define HEARTRATE5_REG2BH 0x2B
117#define HEARTRATE5_REG2CH 0x2C
118#define HEARTRATE5_REG2DH 0x2D
119#define HEARTRATE5_REG2EH 0x2E
120#define HEARTRATE5_REG2FH 0x2F
121#define HEARTRATE5_REG31H 0x31
122
128#define HEARTRATE5_REG32H 0x32
129#define HEARTRATE5_REG33H 0x33
130
131#define HEARTRATE5_REG34H 0x34
132#define HEARTRATE5_REG35H 0x35
133
139#define HEARTRATE5_REG36H 0x36
140#define HEARTRATE5_REG37H 0x37
141
142#define HEARTRATE5_REG39H 0x39
143#define HEARTRATE5_REG3AH 0x3A
144#define HEARTRATE5_REG3DH 0x3D
145#define HEARTRATE5_REG3FH 0x3F
146#define HEARTRATE5_REG40H 0x40
147
148 // heartrate5_reg
149
170#define HEARTRATE5_SET_DEV_ADDR 0x58
171
172 // heartrate5_set
173
188#define HEARTRATE5_MAP_MIKROBUS( cfg, mikrobus ) \
189 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
190 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
191 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
192 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
193
194 // heartrate5_map
195 // heartrate5
196
201typedef struct
202{
203 // Output pins
204 digital_out_t rst;
206 // Input pins
207 digital_in_t int_pin;
209 // Modules
210 i2c_master_t i2c;
212 // I2C slave address
216
221typedef struct
222{
223 pin_name_t scl;
224 pin_name_t sda;
226 pin_name_t rst;
227 pin_name_t int_pin;
229 uint32_t i2c_speed;
230 uint8_t i2c_address;
233
244
261
276
291
306err_t heartrate5_generic_write ( heartrate5_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len );
307
322err_t heartrate5_generic_read ( heartrate5_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len );
323
334void heartrate5_write_reg( heartrate5_t *ctx, uint8_t reg_addr, uint32_t write_data );
335
345uint32_t heartrate5_read_reg( heartrate5_t *ctx, uint8_t reg_addr );
346
355
364
373
382
391
400
409
418
419#ifdef __cplusplus
420}
421#endif
422#endif // HEARTRATE5_H
423
424 // heartrate5
425
426// ------------------------------------------------------------------------ END
uint32_t heartrate5_read_reg(heartrate5_t *ctx, uint8_t reg_addr)
Heart Rate 5 register reading function.
uint32_t heartrate5_get_led2_aled2_val(heartrate5_t *ctx)
Heart Rate 5 get LED2_ALED2 data function.
void heartrate5_cfg_setup(heartrate5_cfg_t *cfg)
Heart Rate 5 configuration object setup function.
void heartrate5_write_reg(heartrate5_t *ctx, uint8_t reg_addr, uint32_t write_data)
Heart Rate 5 register write function.
uint32_t heartrate5_get_led1_aled1_val(heartrate5_t *ctx)
Heart Rate 5 get LED1_ALED1 data function.
err_t heartrate5_default_cfg(heartrate5_t *ctx)
Heart Rate 5 default configuration function.
uint32_t heartrate5_get_aled2_val_led3v_al(heartrate5_t *ctx)
Heart Rate 5 get ALED2 data function.
uint32_t heartrate5_get_led2_val(heartrate5_t *ctx)
Heart Rate 5 get LED2 data function.
err_t heartrate5_init(heartrate5_t *ctx, heartrate5_cfg_t *cfg)
Heart Rate 5 initialization function.
void heartrate5_sw_reset(heartrate5_t *ctx)
Heart Rate 5 software reset function.
err_t heartrate5_generic_read(heartrate5_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len)
Heart Rate 5 I2C reading function.
uint32_t heartrate5_get_aled1_val(heartrate5_t *ctx)
Heart Rate 5 get ALED1 data function.
void heartrate5_hw_reset(heartrate5_t *ctx)
Heart Rate 5 hardware reset function.
err_t heartrate5_generic_write(heartrate5_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len)
Heart Rate 5 I2C writing function.
uint32_t heartrate5_get_led1_val(heartrate5_t *ctx)
Heart Rate 5 get LED1 data function.
heartrate5_return_value_t
Heart Rate 5 Click return value data.
Definition heartrate5.h:239
@ HEARTRATE5_ERROR
Definition heartrate5.h:241
@ HEARTRATE5_OK
Definition heartrate5.h:240
Heart Rate 5 Click configuration object.
Definition heartrate5.h:222
uint32_t i2c_speed
Definition heartrate5.h:229
pin_name_t scl
Definition heartrate5.h:223
pin_name_t int_pin
Definition heartrate5.h:227
pin_name_t sda
Definition heartrate5.h:224
pin_name_t rst
Definition heartrate5.h:226
uint8_t i2c_address
Definition heartrate5.h:230
Heart Rate 5 Click context object.
Definition heartrate5.h:202
digital_in_t int_pin
Definition heartrate5.h:207
i2c_master_t i2c
Definition heartrate5.h:210
digital_out_t rst
Definition heartrate5.h:204
uint8_t slave_address
Definition heartrate5.h:213