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 
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  // heartrate10_reg
101 
116 #define HEARTRATE10_PART_ID 0x2B
117 
123 #define HEARTRATE10_SET_DEV_ADDR 0x57
124  // 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  // heartrate10_map // heartrate10
148 
153 typedef struct
154 {
155  // Input pins
156  digital_in_t int_pin;
158  // Modules
159  i2c_master_t i2c;
161  // I2C slave address
162  uint8_t slave_address;
164 } heartrate10_t;
165 
170 typedef 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 
186 typedef enum
187 {
189  HEARTRATE10_ERROR = -1
190 
192 
209 
224 
239 
252 err_t heartrate10_generic_write ( heartrate10_t *ctx, uint8_t reg, uint8_t tx_data );
253 
266 err_t heartrate10_generic_read ( heartrate10_t *ctx, uint8_t reg, uint8_t *rx_data );
267 
278 
287 
300 err_t heartrate10_fifo_read ( heartrate10_t *ctx, uint8_t *rx_buf, uint8_t rx_len );
301 
314 
332 err_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  // heartrate10
340 
341 // ------------------------------------------------------------------------ END
heartrate10_t::int_pin
digital_in_t int_pin
Definition: heartrate10.h:156
heartrate10_reset
void heartrate10_reset(heartrate10_t *ctx)
Reset device.
heartrate10_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: heartrate10.h:177
heartrate10_cfg_t::sda
pin_name_t sda
Definition: heartrate10.h:173
HEARTRATE10_OK
@ HEARTRATE10_OK
Definition: heartrate10.h:188
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:154
heartrate10_cfg_t
Heart Rate 10 Click configuration object.
Definition: heartrate10.h:171
heartrate10_cfg_t::int_pin
pin_name_t int_pin
Definition: heartrate10.h:175
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:178
heartrate10_t::slave_address
uint8_t slave_address
Definition: heartrate10.h:162
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:159
heartrate10_return_value_t
heartrate10_return_value_t
Heart Rate 10 Click return value data.
Definition: heartrate10.h:187
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:189
heartrate10_cfg_t::scl
pin_name_t scl
Definition: heartrate10.h:172
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.