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
38#include "drv_digital_in.h"
39
40// -------------------------------------------------------------- PUBLIC MACROS
50#define LINEFOLLOWER_MAP_MIKROBUS( cfg, mikrobus ) \
51 cfg.u2= MIKROBUS( mikrobus, MIKROBUS_AN ); \
52 cfg.u1= MIKROBUS( mikrobus, MIKROBUS_RST ); \
53 cfg.u5= MIKROBUS( mikrobus, MIKROBUS_PWM ); \
54 cfg.u4= MIKROBUS( mikrobus, MIKROBUS_RX ); \
55 cfg.u3= MIKROBUS( mikrobus, MIKROBUS_TX );
62#define LINEFOLLOWER_RETVAL uint8_t
63
64#define LINEFOLLOWER_OK 0x00
65#define LINEFOLLOWER_INIT_ERROR 0xFF
72#define LINEFOLLOWER_DATA_DIR_START 0x00
73#define LINEFOLLOWER_DATA_DIR_1 0x01
74#define LINEFOLLOWER_DATA_DIR_2 0x02
75#define LINEFOLLOWER_DATA_DIR_3 0x03
76#define LINEFOLLOWER_DATA_DIR_4 0x04
77#define LINEFOLLOWER_DATA_DIR_6 0x06
78#define LINEFOLLOWER_DATA_DIR_7 0x07
79#define LINEFOLLOWER_DATA_DIR_8 0x08
80#define LINEFOLLOWER_DATA_DIR_12 0x0C
81#define LINEFOLLOWER_DATA_DIR_16 0x10
82#define LINEFOLLOWER_DATA_DIR_24 0x18
83#define LINEFOLLOWER_DATA_DIR_28 0x1C
84#define LINEFOLLOWER_DATA_DIR_31 0x1F
91#define LINEFOLLOWER_BIT_0 0x01
92#define LINEFOLLOWER_BIT_1 0x02
93#define LINEFOLLOWER_BIT_2 0x04
94#define LINEFOLLOWER_BIT_3 0x08
95#define LINEFOLLOWER_BIT_4 0x10
102#define LINEFOLLOWER_DIR_STRAIGHT 0x00
103#define LINEFOLLOWER_DIR_LEFT 0x01
104#define LINEFOLLOWER_DIR_RIGHT 0x02
105#define LINEFOLLOWER_DIR_SHARP_LEFT 0x03
106#define LINEFOLLOWER_DIR_SHARP_RIGHT 0x04
107#define LINEFOLLOWER_DIR_TRACKING_LOST 0x05 // End group macro
111// --------------------------------------------------------------- PUBLIC TYPES
120typedef struct
121{
122 // Input pins
123
124 digital_in_t u1;
125 digital_in_t u2;
126 digital_in_t u3;
127 digital_in_t u4;
128 digital_in_t u5;
129
131
135typedef struct
136{
137 // Additional gpio pins
138
139 pin_name_t u1;
140 pin_name_t u2;
141 pin_name_t u3;
142 pin_name_t u4;
143 pin_name_t u5;
144
146 // End types group
148// ------------------------------------------------------------------ CONSTANTS // End constants group
157// ------------------------------------------------------------------ VARIABLES
162typedef struct
163{
164 uint8_t u1;
165 uint8_t u2;
166 uint8_t u3;
167 uint8_t u4;
168 uint8_t u5;
169
171 // End variable group
173// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
174
180#ifdef __cplusplus
181extern "C"{
182#endif
183
193
202
216
230
244
258
272
284
314
315
316#ifdef __cplusplus
317}
318#endif
319#endif // _LINEFOLLOWER_H_
320 // End public_function group
323
324// ------------------------------------------------------------------------- END
#define LINEFOLLOWER_RETVAL
Definition: linefollower.h:62
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:136
pin_name_t u2
Definition: linefollower.h:140
pin_name_t u1
Definition: linefollower.h:139
pin_name_t u5
Definition: linefollower.h:143
pin_name_t u3
Definition: linefollower.h:141
pin_name_t u4
Definition: linefollower.h:142
Definition: linefollower.h:163
uint8_t u3
Definition: linefollower.h:166
uint8_t u4
Definition: linefollower.h:167
uint8_t u5
Definition: linefollower.h:168
uint8_t u1
Definition: linefollower.h:164
uint8_t u2
Definition: linefollower.h:165
Click ctx object definition.
Definition: linefollower.h:121
digital_in_t u5
Definition: linefollower.h:128
digital_in_t u3
Definition: linefollower.h:126
digital_in_t u1
Definition: linefollower.h:124
digital_in_t u4
Definition: linefollower.h:127
digital_in_t u2
Definition: linefollower.h:125