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 )
60#define INDEXCOUNTER_RETVAL uint8_t
61
62#define INDEXCOUNTER_OK 0x00
63#define INDEXCOUNTER_INIT_ERROR 0xFF
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
84typedef struct
85{
86
87 // Input pins
88
89 digital_in_t dir;
90 digital_in_t spd;
91
93
97typedef 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
115extern "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
#define INDEXCOUNTER_RETVAL
Definition: indexcounter.h:60
void indexcounter_cfg_setup(indexcounter_cfg_t *cfg)
Config Object Initialization function.
uint8_t indexcounter_get_speed(indexcounter_t *ctx)
Get state of the speed pin function.
uint8_t indexcounter_get_dir(indexcounter_t *ctx)
Get state of the direction pin function.
void indexcounter_default_cfg(indexcounter_t *ctx)
Click Default Configuration function.
INDEXCOUNTER_RETVAL indexcounter_init(indexcounter_t *ctx, indexcounter_cfg_t *cfg)
Initialization function.
Click configuration structure definition.
Definition: indexcounter.h:98
pin_name_t spd
Definition: indexcounter.h:102
pin_name_t dir
Definition: indexcounter.h:101
Click ctx object definition.
Definition: indexcounter.h:85
digital_in_t spd
Definition: indexcounter.h:90
digital_in_t dir
Definition: indexcounter.h:89