ecg7 2.0.0.0
ecg7.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 ECG7_H
29#define ECG7_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_analog_in.h"
52#include "drv_i2c_master.h"
53
74#define ECG7_ADC_RESOLUTION 0x0FFF
75#define ECG7_VREF_3V3 3.3
76#define ECG7_VREF_5V 5.0
77
83#define ECG7_SET_DEV_ADDR 0x4D
84
85 // ecg7_set
86
101#define ECG7_MAP_MIKROBUS( cfg, mikrobus ) \
102 cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN ); \
103 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
104 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA );
105
106 // ecg7_map
107 // ecg7
108
119
124typedef struct
125{
126 analog_in_t adc;
127 i2c_master_t i2c;
130 pin_name_t chip_select;
131 float vref;
134} ecg7_t;
135
140typedef struct
141{
142 pin_name_t an;
143 pin_name_t scl;
144 pin_name_t sda;
146 analog_in_resolution_t resolution;
147 float vref;
149 uint32_t i2c_speed;
150 uint8_t i2c_address;
154} ecg7_cfg_t;
155
160typedef enum
161{
163 ECG7_ERROR = -1
164
166
183
199
213err_t ecg7_init ( ecg7_t *ctx, ecg7_cfg_t *cfg );
214
226err_t ecg7_read_raw_adc ( ecg7_t *ctx, uint16_t *raw_adc );
227
239err_t ecg7_read_voltage ( ecg7_t *ctx, float *voltage );
240
252err_t ecg7_set_vref ( ecg7_t *ctx, float vref );
253
254#ifdef __cplusplus
255}
256#endif
257#endif // ECG7_H
258
259 // ecg7
260
261// ------------------------------------------------------------------------ END
ecg7_drv_t
ECG 7 Click driver selector.
Definition ecg7.h:114
@ ECG7_DRV_SEL_I2C
Definition ecg7.h:116
@ ECG7_DRV_SEL_ADC
Definition ecg7.h:115
ecg7_return_value_t
ECG 7 Click return value data.
Definition ecg7.h:161
@ ECG7_OK
Definition ecg7.h:162
@ ECG7_ERROR
Definition ecg7.h:163
void ecg7_drv_interface_selection(ecg7_cfg_t *cfg, ecg7_drv_t drv_sel)
ECG 7 driver interface setup function.
err_t ecg7_init(ecg7_t *ctx, ecg7_cfg_t *cfg)
ECG 7 initialization function.
err_t ecg7_read_voltage(ecg7_t *ctx, float *voltage)
ECG 7 read voltage level function.
void ecg7_cfg_setup(ecg7_cfg_t *cfg)
ECG 7 configuration object setup function.
err_t ecg7_read_raw_adc(ecg7_t *ctx, uint16_t *raw_adc)
ECG 7 read raw ADC value function.
err_t ecg7_set_vref(ecg7_t *ctx, float vref)
ECG 7 set vref function.
ECG 7 Click configuration object.
Definition ecg7.h:141
ecg7_drv_t drv_sel
Definition ecg7.h:152
analog_in_resolution_t resolution
Definition ecg7.h:146
float vref
Definition ecg7.h:147
uint32_t i2c_speed
Definition ecg7.h:149
pin_name_t scl
Definition ecg7.h:143
pin_name_t sda
Definition ecg7.h:144
pin_name_t an
Definition ecg7.h:142
uint8_t i2c_address
Definition ecg7.h:150
ECG 7 Click context object.
Definition ecg7.h:125
ecg7_drv_t drv_sel
Definition ecg7.h:132
float vref
Definition ecg7.h:131
i2c_master_t i2c
Definition ecg7.h:127
uint8_t slave_address
Definition ecg7.h:129
pin_name_t chip_select
Definition ecg7.h:130
analog_in_t adc
Definition ecg7.h:126