indexcounter  2.0.0.0
indexcounter.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 INDEXCOUNTER_H
36 #define INDEXCOUNTER_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 
55 // -------------------------------------------------------------- PUBLIC MACROS
65 #define INDEXCOUNTER_MAP_MIKROBUS( cfg, mikrobus ) \
66  cfg.dir= MIKROBUS( mikrobus, MIKROBUS_AN ); \
67  cfg.spd= MIKROBUS( mikrobus, MIKROBUS_RST )
68 
74 #define INDEXCOUNTER_RETVAL uint8_t
75 
76 #define INDEXCOUNTER_OK 0x00
77 #define INDEXCOUNTER_INIT_ERROR 0xFF
78 
80 #define INDEXCOUNTER_ACTIVE 1
81 #define INDEXCOUNTER_INACTIVE 0
82 
83 #define INDEXCOUNTER_SPEED_ENABLE 1
84 #define INDEXCOUNTER_SPEED_DISABLE 0
85 
86 #define INDEXCOUNTER_ONE_MIN_CONV_MS 60000.0
87  // End group macro
89 // --------------------------------------------------------------- PUBLIC TYPES
98 typedef struct
99 {
100 
101  // Input pins
102 
103  digital_in_t dir;
104  digital_in_t spd;
105 
107 
111 typedef struct
112 {
113  // Additional gpio pins
114 
115  pin_name_t dir;
116  pin_name_t spd;
117 
119  // End types group
121 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
122 
128 #ifdef __cplusplus
129 extern "C"{
130 #endif
131 
141 
150 
159 
170 
181 
182 #ifdef __cplusplus
183 }
184 #endif
185 #endif // _INDEXCOUNTER_H_
186  // End public_function group
189 
190 // ------------------------------------------------------------------------- END
INDEXCOUNTER_RETVAL
#define INDEXCOUNTER_RETVAL
Definition: indexcounter.h:74
indexcounter_t
Click ctx object definition.
Definition: indexcounter.h:99
indexcounter_get_dir
uint8_t indexcounter_get_dir(indexcounter_t *ctx)
Get state of the direction pin function.
indexcounter_cfg_t::spd
pin_name_t spd
Definition: indexcounter.h:116
indexcounter_cfg_t::dir
pin_name_t dir
Definition: indexcounter.h:115
indexcounter_init
INDEXCOUNTER_RETVAL indexcounter_init(indexcounter_t *ctx, indexcounter_cfg_t *cfg)
Initialization function.
indexcounter_t::spd
digital_in_t spd
Definition: indexcounter.h:104
indexcounter_cfg_setup
void indexcounter_cfg_setup(indexcounter_cfg_t *cfg)
Config Object Initialization function.
indexcounter_default_cfg
void indexcounter_default_cfg(indexcounter_t *ctx)
Click Default Configuration function.
indexcounter_get_speed
uint8_t indexcounter_get_speed(indexcounter_t *ctx)
Get state of the speed pin function.
indexcounter_t::dir
digital_in_t dir
Definition: indexcounter.h:103
indexcounter_cfg_t
Click configuration structure definition.
Definition: indexcounter.h:112