linefollower 2.0.0.0
linefollower.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 LINEFOLLOWER_H
36#define LINEFOLLOWER_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_in.h"
53
54// -------------------------------------------------------------- PUBLIC MACROS
64#define LINEFOLLOWER_MAP_MIKROBUS( cfg, mikrobus ) \
65 cfg.u2= MIKROBUS( mikrobus, MIKROBUS_AN ); \
66 cfg.u1= MIKROBUS( mikrobus, MIKROBUS_RST ); \
67 cfg.u5= MIKROBUS( mikrobus, MIKROBUS_PWM ); \
68 cfg.u4= MIKROBUS( mikrobus, MIKROBUS_RX ); \
69 cfg.u3= MIKROBUS( mikrobus, MIKROBUS_TX );
76#define LINEFOLLOWER_RETVAL uint8_t
77
78#define LINEFOLLOWER_OK 0x00
79#define LINEFOLLOWER_INIT_ERROR 0xFF
86#define LINEFOLLOWER_DATA_DIR_START 0x00
87#define LINEFOLLOWER_DATA_DIR_1 0x01
88#define LINEFOLLOWER_DATA_DIR_2 0x02
89#define LINEFOLLOWER_DATA_DIR_3 0x03
90#define LINEFOLLOWER_DATA_DIR_4 0x04
91#define LINEFOLLOWER_DATA_DIR_6 0x06
92#define LINEFOLLOWER_DATA_DIR_7 0x07
93#define LINEFOLLOWER_DATA_DIR_8 0x08
94#define LINEFOLLOWER_DATA_DIR_12 0x0C
95#define LINEFOLLOWER_DATA_DIR_16 0x10
96#define LINEFOLLOWER_DATA_DIR_24 0x18
97#define LINEFOLLOWER_DATA_DIR_28 0x1C
98#define LINEFOLLOWER_DATA_DIR_31 0x1F
105#define LINEFOLLOWER_BIT_0 0x01
106#define LINEFOLLOWER_BIT_1 0x02
107#define LINEFOLLOWER_BIT_2 0x04
108#define LINEFOLLOWER_BIT_3 0x08
109#define LINEFOLLOWER_BIT_4 0x10
116#define LINEFOLLOWER_DIR_STRAIGHT 0x00
117#define LINEFOLLOWER_DIR_LEFT 0x01
118#define LINEFOLLOWER_DIR_RIGHT 0x02
119#define LINEFOLLOWER_DIR_SHARP_LEFT 0x03
120#define LINEFOLLOWER_DIR_SHARP_RIGHT 0x04
121#define LINEFOLLOWER_DIR_TRACKING_LOST 0x05
124 // End group macro
125// --------------------------------------------------------------- PUBLIC TYPES
134typedef struct
135{
136 // Input pins
137
138 digital_in_t u1;
139 digital_in_t u2;
140 digital_in_t u3;
141 digital_in_t u4;
142 digital_in_t u5;
143
145
149typedef struct
150{
151 // Additional gpio pins
152
153 pin_name_t u1;
154 pin_name_t u2;
155 pin_name_t u3;
156 pin_name_t u4;
157 pin_name_t u5;
158
160
161 // End types group
162// ------------------------------------------------------------------ CONSTANTS
170 // End constants group
171// ------------------------------------------------------------------ VARIABLES
176typedef struct
177{
178 uint8_t u1;
179 uint8_t u2;
180 uint8_t u3;
181 uint8_t u4;
182 uint8_t u5;
183
185
186 // End variable group
187// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
188
194#ifdef __cplusplus
195extern "C"{
196#endif
197
207
216
230
244
258
272
286
298
328
329
330#ifdef __cplusplus
331}
332#endif
333#endif // _LINEFOLLOWER_H_
334
335 // End public_function group
337
338// ------------------------------------------------------------------------- END
#define LINEFOLLOWER_RETVAL
Definition linefollower.h:76
void linefollower_cfg_setup(linefollower_cfg_t *cfg)
Config Object Initialization function.
uint8_t linefollower_get_direction(linefollower_t *ctx)
Get direction data function.
uint8_t linefollower_get_u3(linefollower_t *ctx)
Get status of U3 pin function.
uint8_t linefollower_get_u5(linefollower_t *ctx)
Get status of U5 pin function.
void linefollower_data_track(linefollower_t *ctx, linefollower_direction_t *data_track)
Get status of all pin function.
uint8_t linefollower_get_u1(linefollower_t *ctx)
Get status of U1 pin function.
uint8_t linefollower_get_u4(linefollower_t *ctx)
Get status of U4 pin function.
LINEFOLLOWER_RETVAL linefollower_init(linefollower_t *ctx, linefollower_cfg_t *cfg)
Initialization function.
uint8_t linefollower_get_u2(linefollower_t *ctx)
Get status of U2 pin function.
Click configuration structure definition.
Definition linefollower.h:150
pin_name_t u2
Definition linefollower.h:154
pin_name_t u1
Definition linefollower.h:153
pin_name_t u5
Definition linefollower.h:157
pin_name_t u3
Definition linefollower.h:155
pin_name_t u4
Definition linefollower.h:156
Definition linefollower.h:177
uint8_t u3
Definition linefollower.h:180
uint8_t u4
Definition linefollower.h:181
uint8_t u5
Definition linefollower.h:182
uint8_t u1
Definition linefollower.h:178
uint8_t u2
Definition linefollower.h:179
Click ctx object definition.
Definition linefollower.h:135
digital_in_t u5
Definition linefollower.h:142
digital_in_t u3
Definition linefollower.h:140
digital_in_t u1
Definition linefollower.h:138
digital_in_t u4
Definition linefollower.h:141
digital_in_t u2
Definition linefollower.h:139