ecg5 2.0.0.0
ecg5.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 ECG5_H
29#define ECG5_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
73#define ECG5_NORMAL_MODE 0x01
74#define ECG5_SHUTDOWN_MODE 0x00
75
76 // ecg5_set
77
92#define ECG5_MAP_MIKROBUS( cfg, mikrobus ) \
93 cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN ); \
94 cfg.sdn = MIKROBUS( mikrobus, MIKROBUS_CS ); \
95 cfg.lon = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
96 cfg.lop = MIKROBUS( mikrobus, MIKROBUS_INT )
97
98 // ecg5_map
99 // ecg5
100
105typedef struct
106{
107 digital_out_t sdn;
109 digital_in_t lon;
110 digital_in_t lop;
112 analog_in_t adc;
114} ecg5_t;
115
120typedef struct
121{
122 pin_name_t an;
123 pin_name_t sdn;
124 pin_name_t lon;
125 pin_name_t lop;
127 analog_in_resolution_t resolution;
128 float vref;
130} ecg5_cfg_t;
131
136typedef enum
137{
139 ECG5_ERROR = -1
140
142
159
173err_t ecg5_init ( ecg5_t *ctx, ecg5_cfg_t *cfg );
174
186err_t ecg5_read_an_pin_value ( ecg5_t *ctx, uint16_t *data_out );
187
202err_t ecg5_read_an_pin_voltage ( ecg5_t *ctx, float *data_out );
203
212void ecg5_set_mode( ecg5_t *ctx, uint8_t state );
213
226
240
241#ifdef __cplusplus
242}
243#endif
244#endif // ECG5_H
245
246 // ecg5
247
248// ------------------------------------------------------------------------ END
ecg5_return_value_t
ECG 5 Click return value data.
Definition ecg5.h:137
@ ECG5_ERROR
Definition ecg5.h:139
@ ECG5_OK
Definition ecg5.h:138
err_t ecg5_check_lod_negative(ecg5_t *ctx)
LOD- Checking function.
err_t ecg5_init(ecg5_t *ctx, ecg5_cfg_t *cfg)
ECG 5 initialization function.
err_t ecg5_check_lod_positive(ecg5_t *ctx)
LOD+ Checking function.
void ecg5_set_mode(ecg5_t *ctx, uint8_t state)
Mode Setting function.
err_t ecg5_read_an_pin_value(ecg5_t *ctx, uint16_t *data_out)
ECG 5 read AN pin value function.
err_t ecg5_read_an_pin_voltage(ecg5_t *ctx, float *data_out)
ECG 5 read AN pin voltage level function.
void ecg5_cfg_setup(ecg5_cfg_t *cfg)
ECG 5 configuration object setup function.
ECG 5 Click configuration object.
Definition ecg5.h:121
analog_in_resolution_t resolution
Definition ecg5.h:127
float vref
Definition ecg5.h:128
pin_name_t lon
Definition ecg5.h:124
pin_name_t lop
Definition ecg5.h:125
pin_name_t sdn
Definition ecg5.h:123
pin_name_t an
Definition ecg5.h:122
ECG 5 Click context object.
Definition ecg5.h:106
digital_in_t lop
Definition ecg5.h:110
digital_in_t lon
Definition ecg5.h:109
digital_out_t sdn
Definition ecg5.h:107
analog_in_t adc
Definition ecg5.h:112