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 
38 #include "drv_digital_out.h"
39 #include "drv_digital_in.h"
40 
41 // -------------------------------------------------------------- PUBLIC MACROS
51 #define INDEXCOUNTER_MAP_MIKROBUS( cfg, mikrobus ) \
52  cfg.dir= MIKROBUS( mikrobus, MIKROBUS_AN ); \
53  cfg.spd= MIKROBUS( mikrobus, MIKROBUS_RST )
54 
60 #define INDEXCOUNTER_RETVAL uint8_t
61 
62 #define INDEXCOUNTER_OK 0x00
63 #define INDEXCOUNTER_INIT_ERROR 0xFF
64 
66 #define INDEXCOUNTER_ACTIVE 1
67 #define INDEXCOUNTER_INACTIVE 0
68 
69 #define INDEXCOUNTER_SPEED_ENABLE 1
70 #define INDEXCOUNTER_SPEED_DISABLE 0
71 
72 #define INDEXCOUNTER_ONE_MIN_CONV_MS 60000.0
73  // End group macro
75 // --------------------------------------------------------------- PUBLIC TYPES
84 typedef struct
85 {
86 
87  // Input pins
88 
89  digital_in_t dir;
90  digital_in_t spd;
91 
93 
97 typedef struct
98 {
99  // Additional gpio pins
100 
101  pin_name_t dir;
102  pin_name_t spd;
103 
105  // End types group
107 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
108 
114 #ifdef __cplusplus
115 extern "C"{
116 #endif
117 
127 
136 
145 
156 
167 
168 #ifdef __cplusplus
169 }
170 #endif
171 #endif // _INDEXCOUNTER_H_
172  // End public_function group
175 
176 // ------------------------------------------------------------------------- END
INDEXCOUNTER_RETVAL
#define INDEXCOUNTER_RETVAL
Definition: indexcounter.h:60
indexcounter_t
Click ctx object definition.
Definition: indexcounter.h:85
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:102
indexcounter_cfg_t::dir
pin_name_t dir
Definition: indexcounter.h:101
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:90
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:89
indexcounter_cfg_t
Click configuration structure definition.
Definition: indexcounter.h:98