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 "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 
51 // -------------------------------------------------------------- PUBLIC MACROS
61 #define INDEXCOUNTER_MAP_MIKROBUS( cfg, mikrobus ) \
62  cfg.dir= MIKROBUS( mikrobus, MIKROBUS_AN ); \
63  cfg.spd= MIKROBUS( mikrobus, MIKROBUS_RST )
64 
70 #define INDEXCOUNTER_RETVAL uint8_t
71 
72 #define INDEXCOUNTER_OK 0x00
73 #define INDEXCOUNTER_INIT_ERROR 0xFF
74 
76 #define INDEXCOUNTER_ACTIVE 1
77 #define INDEXCOUNTER_INACTIVE 0
78 
79 #define INDEXCOUNTER_SPEED_ENABLE 1
80 #define INDEXCOUNTER_SPEED_DISABLE 0
81 
82 #define INDEXCOUNTER_ONE_MIN_CONV_MS 60000.0
83  // End group macro
85 // --------------------------------------------------------------- PUBLIC TYPES
94 typedef struct
95 {
96 
97  // Input pins
98 
99  digital_in_t dir;
100  digital_in_t spd;
101 
103 
107 typedef struct
108 {
109  // Additional gpio pins
110 
111  pin_name_t dir;
112  pin_name_t spd;
113 
115  // End types group
117 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
118 
124 #ifdef __cplusplus
125 extern "C"{
126 #endif
127 
137 
146 
155 
166 
177 
178 #ifdef __cplusplus
179 }
180 #endif
181 #endif // _INDEXCOUNTER_H_
182  // End public_function group
185 
186 // ------------------------------------------------------------------------- END
INDEXCOUNTER_RETVAL
#define INDEXCOUNTER_RETVAL
Definition: indexcounter.h:70
indexcounter_t
Click ctx object definition.
Definition: indexcounter.h:95
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:112
indexcounter_cfg_t::dir
pin_name_t dir
Definition: indexcounter.h:111
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:100
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:99
indexcounter_cfg_t
Click configuration structure definition.
Definition: indexcounter.h:108