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
32 extern "C"{
33 #endif
34 
35 #include "mikrosdk_version.h"
36 
37 #ifdef __GNUC__
38 #if mikroSDK_GET_VERSION < 20800ul
39 #include "rcu_delays.h"
40 #else
41 #include "delays.h"
42 #endif
43 #endif
44 
45 #include "drv_digital_out.h"
46 #include "drv_digital_in.h"
47 #include "drv_i2c_master.h"
48 
69 #define HEARTRATE10_REG_INT_STATUS 0x00
70 #define HEARTRATE10_REG_INT_ENABLE 0x02
71 #define HEARTRATE10_REG_FIFO_WR_PTR 0x04
72 #define HEARTRATE10_REG_FIFO_OVF_CNT 0x05
73 #define HEARTRATE10_REG_FIFO_RD_PTR 0x06
74 #define HEARTRATE10_REG_FIFO_DATA 0x07
75 #define HEARTRATE10_REG_FIFO_CFG 0x08
76 #define HEARTRATE10_REG_MODE_CFG1 0x09
77 #define HEARTRATE10_REG_MODE_CFG2 0x0A
78 #define HEARTRATE10_REG_LED1_PA 0x0C
79 #define HEARTRATE10_REG_LED2_PA 0x0D
80 #define HEARTRATE10_REG_LED3_PA 0x0E
81 #define HEARTRATE10_REG_LED4_PA 0x0F
82 #define HEARTRATE10_REG_LED_RANGE 0x11
83 #define HEARTRATE10_REG_PILOT_PA 0x12
84 #define HEARTRATE10_REG_LED_SEQ1 0x13
85 #define HEARTRATE10_REG_LED_SEQ2 0x14
86 #define HEARTRATE10_REG_DAC1_CROSSTALK_CODE 0x26
87 #define HEARTRATE10_REG_DAC2_CROSSTALK_CODE 0x27
88 #define HEARTRATE10_REG_DAC3_CROSSTALK_CODE 0x28
89 #define HEARTRATE10_REG_DAC4_CROSSTALK_CODE 0x29
90 #define HEARTRATE10_REG_PROX_INT_THRESHOLD 0x30
91 #define HEARTRATE10_REG_LED_COMPARATOR_EN 0x31
92 #define HEARTRATE10_REG_LED_COMPARATOR_STATUS 0x32
93 #define HEARTRATE10_REG_REV_ID 0xFE
94 #define HEARTRATE10_REG_PART_ID 0xFF
95  // heartrate10_reg
97 
112 #define HEARTRATE10_PART_ID 0x2B
113 
119 #define HEARTRATE10_SET_DEV_ADDR 0x57
120  // heartrate10_set
122 
137 #define HEARTRATE10_MAP_MIKROBUS( cfg, mikrobus ) \
138  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
139  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
140  cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
141  // heartrate10_map // heartrate10
144 
149 typedef struct
150 {
151  // Input pins
152  digital_in_t int_pin;
154  // Modules
155  i2c_master_t i2c;
157  // I2C slave address
158  uint8_t slave_address;
160 } heartrate10_t;
161 
166 typedef struct
167 {
168  pin_name_t scl;
169  pin_name_t sda;
171  pin_name_t int_pin;
173  uint32_t i2c_speed;
174  uint8_t i2c_address;
177 
182 typedef enum
183 {
185  HEARTRATE10_ERROR = -1
186 
188 
205 
220 
235 
248 err_t heartrate10_generic_write ( heartrate10_t *ctx, uint8_t reg, uint8_t tx_data );
249 
262 err_t heartrate10_generic_read ( heartrate10_t *ctx, uint8_t reg, uint8_t *rx_data );
263 
274 
283 
296 err_t heartrate10_fifo_read ( heartrate10_t *ctx, uint8_t *rx_buf, uint8_t rx_len );
297 
310 
328 err_t heartrate10_read_complete_fifo_data ( heartrate10_t *ctx, uint32_t *led1, uint32_t *led2, uint32_t *led3, uint32_t *led4 );
329 
330 #ifdef __cplusplus
331 }
332 #endif
333 #endif // HEARTRATE10_H
334  // heartrate10
336 
337 // ------------------------------------------------------------------------ END
heartrate10_t::int_pin
digital_in_t int_pin
Definition: heartrate10.h:152
heartrate10_reset
void heartrate10_reset(heartrate10_t *ctx)
Reset device.
heartrate10_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: heartrate10.h:173
heartrate10_cfg_t::sda
pin_name_t sda
Definition: heartrate10.h:169
HEARTRATE10_OK
@ HEARTRATE10_OK
Definition: heartrate10.h:184
heartrate10_read_complete_fifo_data
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.
heartrate10_t
Heart Rate 10 Click context object.
Definition: heartrate10.h:150
heartrate10_cfg_t
Heart Rate 10 Click configuration object.
Definition: heartrate10.h:167
heartrate10_cfg_t::int_pin
pin_name_t int_pin
Definition: heartrate10.h:171
heartrate10_default_cfg
err_t heartrate10_default_cfg(heartrate10_t *ctx)
Heart Rate 10 default configuration function.
heartrate10_cfg_t::i2c_address
uint8_t i2c_address
Definition: heartrate10.h:174
heartrate10_t::slave_address
uint8_t slave_address
Definition: heartrate10.h:158
heartrate10_generic_write
err_t heartrate10_generic_write(heartrate10_t *ctx, uint8_t reg, uint8_t tx_data)
Writing function.
heartrate10_generic_read
err_t heartrate10_generic_read(heartrate10_t *ctx, uint8_t reg, uint8_t *rx_data)
Reading function.
heartrate10_t::i2c
i2c_master_t i2c
Definition: heartrate10.h:155
heartrate10_return_value_t
heartrate10_return_value_t
Heart Rate 10 Click return value data.
Definition: heartrate10.h:183
heartrate10_read_fifo_sample
uint32_t heartrate10_read_fifo_sample(heartrate10_t *ctx)
Read single sample of FIFO data.
heartrate10_get_int_pin
uint8_t heartrate10_get_int_pin(heartrate10_t *ctx)
Get interrupt pin state.
HEARTRATE10_ERROR
@ HEARTRATE10_ERROR
Definition: heartrate10.h:185
heartrate10_cfg_t::scl
pin_name_t scl
Definition: heartrate10.h:168
heartrate10_cfg_setup
void heartrate10_cfg_setup(heartrate10_cfg_t *cfg)
Heart Rate 10 configuration object setup function.
heartrate10_fifo_read
err_t heartrate10_fifo_read(heartrate10_t *ctx, uint8_t *rx_buf, uint8_t rx_len)
Read fifo register data.
heartrate10_init
err_t heartrate10_init(heartrate10_t *ctx, heartrate10_cfg_t *cfg)
Heart Rate 10 initialization function.