heartrate6 2.0.0.0
heartrate6.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 HEARTRATE6_H
36#define HEARTRATE6_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 HEARTRATE6_MAP_MIKROBUS( cfg, mikrobus ) \
67 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
68 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA )
75#define HEARTRATE6_RETVAL uint8_t
76
77#define HEARTRATE6_OK 0x00
78#define HEARTRATE6_INIT_ERROR 0xFF
85#define HEARTRATE6_SLAVE_ADDR 0x5B
92#define HEARTRATE6_MANUFACT_ID_REG1 0x0F
93#define HEARTRATE6_MANUFACT_ID_REG2 0x92
94#define HEARTRATE6_PART_ID_REG 0x10
95#define HEARTRATE6_RESET_REG 0x40
96#define HEARTRATE6_MEAS_CTRL1_REG 0x41
97#define HEARTRATE6_MEAS_CTRL2_REG 0x42
98#define HEARTRATE6_MEAS_START_REG 0x43
99#define HEARTRATE6_DATA_LEDOFF_LSB_REG 0x54
100#define HEARTRATE6_DATA_LEDOFF_MSB_REG 0x55
101#define HEARTRATE6_DATA_LEDON_LSB_REG 0x56
102#define HEARTRATE6_DATA_LEDON_MSB_REG 0x57
109#define HEARTRATE6_RESET_CMD 0x80
110#define HEARTRATE6_OSC_ACTIVE 0x80
111#define HEARTRATE6_LED_FREQ_128HZ 0x00
112#define HEARTRATE6_LED_FREQ_64HZ 0x04
113#define HEARTRATE6_DATAREAD_FREQ_64HZ 0x01
114#define HEARTRATE6_DATAREAD_FREQ_32HZ 0x02
115#define HEARTRATE6_LEDS_PULSED 0x00
116#define HEARTRATE6_LED1_CONST_LED2_PULSED 0x40
117#define HEARTRATE6_LED1_PULSED_LED2_CONST 0x80
118#define HEARTRATE6_LEDS_CONST 0xC0
119#define HEARTRATE6_LED_TIME_300MICROSEC 0x00
120#define HEARTRATE6_LED_TIME_600MICROSEC 0x20
121#define HEARTRATE6_LED_CURR_0MA 0x00
122#define HEARTRATE6_LED_CURR_1MA 0x08
123#define HEARTRATE6_LED_CURR_2MA 0x09
124#define HEARTRATE6_LED_CURR_3MA 0x0A
125#define HEARTRATE6_LED_CURR_6MA 0x0B
126#define HEARTRATE6_LED_CURR_10MA 0x0C
127#define HEARTRATE6_LED_CURR_20MA 0x0D
128#define HEARTRATE6_LED_CURR_30MA 0x0E
129#define HEARTRATE6_LED_CURR_60MA 0x0F
130#define HEARTRATE6_START_MEAS 0x01
137#define HEARTRATE6_OK 0x00
138#define HEARTRATE6_WRONG_ADDR 0x01
139#define HEARTRATE6_NBYTES_RANGE_ERROR 0x02
142 // End group macro
143// --------------------------------------------------------------- PUBLIC TYPES
152typedef struct
153{
154
155 // Modules
156
157 i2c_master_t i2c;
158
159 // ctx variable
160
162
163 float res;
164 uint8_t wait_time;
165
167
171typedef struct
172{
173 // Communication gpio pins
174
175 pin_name_t scl;
176 pin_name_t sda;
177
178 // static variable
179
180 uint32_t i2c_speed;
181 uint8_t i2c_address;
182
184
185 // End types group
186
187// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
188
194#ifdef __cplusplus
195extern "C"{
196#endif
197
207
217
226
238uint8_t heartrate6_write_single_byte ( heartrate6_t *ctx, uint8_t reg_addr, uint8_t data_in );
239
252uint8_t heartrate6_write_bytes ( heartrate6_t *ctx, uint8_t start_addr, uint8_t *data_in, uint8_t n_bytes );
253
266uint8_t heartrate6_read_bytes( heartrate6_t *ctx, uint8_t start_addr, uint8_t *data_out, uint8_t n_bytes );
267
275
284
294void heartrate6_set_freq ( heartrate6_t *ctx, uint8_t freq_data );
295
305void heartrate6_get_data ( heartrate6_t *ctx, uint16_t *led_off_data, uint16_t *led_on_data );
306
315
316#ifdef __cplusplus
317}
318#endif
319#endif // _HEARTRATE6_H_
320
321 // End public_function group
323
324// ------------------------------------------------------------------------- END
#define HEARTRATE6_RETVAL
Definition heartrate6.h:75
void heartrate6_start_measure(heartrate6_t *ctx)
Measurement Start function.
void heartrate6_get_data(heartrate6_t *ctx, uint16_t *led_off_data, uint16_t *led_on_data)
Data Get function.
HEARTRATE6_RETVAL heartrate6_init(heartrate6_t *ctx, heartrate6_cfg_t *cfg)
Initialization function.
void heartrate6_cfg_setup(heartrate6_cfg_t *cfg)
Config Object Initialization function.
void heartrate6_reset(heartrate6_t *ctx)
Reset function.
void heartrate6_set_freq(heartrate6_t *ctx, uint8_t freq_data)
Frequency Set function.
void heartrate6_default_cfg(heartrate6_t *ctx)
Click Default Configuration function.
uint8_t heartrate6_write_bytes(heartrate6_t *ctx, uint8_t start_addr, uint8_t *data_in, uint8_t n_bytes)
Bytes Write function.
uint8_t heartrate6_write_single_byte(heartrate6_t *ctx, uint8_t reg_addr, uint8_t data_in)
Single Byte Write function.
void heartrate6_wait_measure(heartrate6_t *ctx)
Wait measurement function.
uint8_t heartrate6_read_bytes(heartrate6_t *ctx, uint8_t start_addr, uint8_t *data_out, uint8_t n_bytes)
Generic Read function.
Click configuration structure definition.
Definition heartrate6.h:172
uint32_t i2c_speed
Definition heartrate6.h:180
pin_name_t scl
Definition heartrate6.h:175
pin_name_t sda
Definition heartrate6.h:176
uint8_t i2c_address
Definition heartrate6.h:181
Click ctx object definition.
Definition heartrate6.h:153
float res
Definition heartrate6.h:163
i2c_master_t i2c
Definition heartrate6.h:157
uint8_t slave_address
Definition heartrate6.h:161
uint8_t wait_time
Definition heartrate6.h:164