ecg  2.0.0.0
ecg.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 
35 #ifndef ECG_H
36 #define ECG_H
37 
38 #include "mikrosdk_version.h"
39 
40 #ifdef __GNUC__
41 #if mikroSDK_GET_VERSION < 20800ul
42 #include "rcu_delays.h"
43 #else
44 #include "delays.h"
45 #endif
46 #endif
47 
48 #include "drv_digital_out.h"
49 #include "drv_digital_in.h"
50 #include "drv_analog_in.h"
51 
52 // -------------------------------------------------------------- PUBLIC MACROS
53 
63 #define ECG_MAP_MIKROBUS( cfg, mikrobus ) \
64  cfg.an_pin = MIKROBUS( mikrobus, MIKROBUS_AN )
65 
71 #define ECG_RETVAL uint8_t
72 
73 #define ECG_OK 0x00
74 #define ECG_INIT_ERROR 0xFF
75  // End group macro
78 // --------------------------------------------------------------- PUBLIC TYPES
87 typedef uint16_t ecg_data_t;
88 
92 typedef struct
93 {
94  // Modules
95  analog_in_t adc;
96 
97 } ecg_t;
98 
102 typedef struct
103 {
104  // Communication gpio pins
105 
106  pin_name_t an_pin;
107 
108  // static variable
109 
110  analog_in_resolution_t resolution; // Resolution
111  float vref; // VRef
112 
113 } ecg_cfg_t;
114  // End types group
116 
117 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
118 
124 #ifdef __cplusplus
125 extern "C"{
126 #endif
127 
136 void ecg_cfg_setup ( ecg_cfg_t *cfg );
137 
147 
155 void ecg_default_cfg ( ecg_t *ctx );
156 
166 
167 
168 #ifdef __cplusplus
169 }
170 #endif
171 #endif // _ECG_H_
172  // End public_function group
175 
176 // ------------------------------------------------------------------------ END
ecg_generic_read
ecg_data_t ecg_generic_read(ecg_t *ctx)
Generic read function.
ecg_cfg_setup
void ecg_cfg_setup(ecg_cfg_t *cfg)
Config Object Initialization function.
ecg_t::adc
analog_in_t adc
Definition: ecg.h:95
ecg_cfg_t::resolution
analog_in_resolution_t resolution
Definition: ecg.h:110
ecg_cfg_t::an_pin
pin_name_t an_pin
Definition: ecg.h:106
ecg_cfg_t::vref
float vref
Definition: ecg.h:111
ECG_RETVAL
#define ECG_RETVAL
Definition: ecg.h:71
ecg_init
ECG_RETVAL ecg_init(ecg_t *ctx, ecg_cfg_t *cfg)
Initialization function.
ecg_cfg_t
Click configuration structure definition.
Definition: ecg.h:103
ecg_t
Click ctx object definition.
Definition: ecg.h:93
ecg_default_cfg
void ecg_default_cfg(ecg_t *ctx)
Click Default Configuration function.
ecg_data_t
uint16_t ecg_data_t
Analog data type.
Definition: ecg.h:87