tilt 2.0.0.0
tilt.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 TILT_H
36#define TILT_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 TILT_MAP_MIKROBUS( cfg, mikrobus ) \
65 cfg.vo1= MIKROBUS( mikrobus, MIKROBUS_PWM ); \
66 cfg.vo2= MIKROBUS( mikrobus, MIKROBUS_INT )
73#define TILT_RETVAL uint8_t
74
75#define TILT_OK 0x00
76#define TILT_INIT_ERROR 0xFF
83#define TILT_NO_DETECTION 0
84#define TILT_DETECTION 1
85#define TILT_LEFT_DETECTION 2
86#define TILT_RIGHT_DETECTION 3
87#define TILT_UP_DETECTION 4
88#define TILT_DOWN_DETECTION 5
91 // End group macro
92// --------------------------------------------------------------- PUBLIC TYPES
101typedef struct
102{
103 // Input pins
104
105 digital_in_t vo1;
106 digital_in_t vo2;
107
108} tilt_t;
109
113typedef struct
114{
115 // Additional gpio pins
116
117 pin_name_t vo1;
118 pin_name_t vo2;
119
120} tilt_cfg_t;
121
122 // End types group
123// ------------------------------------------------------------------ CONSTANTS
131 // End constants group
132// ------------------------------------------------------------------ VARIABLES
139 // End variable group
140// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
141
147#ifdef __cplusplus
148extern "C"{
149#endif
150
160
169
182uint8_t tilt_left ( tilt_t *ctx );
183
196uint8_t tilt_right ( tilt_t *ctx );
197
210uint8_t tilt_up ( tilt_t *ctx );
211
224uint8_t tilt_down ( tilt_t *ctx );
225
241uint8_t tilt_direction ( tilt_t *ctx );
242
243#ifdef __cplusplus
244}
245#endif
246#endif // _TILT_H_
247
248 // End public_function group
250
251// ------------------------------------------------------------------------- END
#define TILT_RETVAL
Definition tilt.h:73
void tilt_cfg_setup(tilt_cfg_t *cfg)
Config Object Initialization function.
uint8_t tilt_direction(tilt_t *ctx)
Check the tilt movement's direction function.
uint8_t tilt_right(tilt_t *ctx)
Check the tilt right movement's direction function.
uint8_t tilt_up(tilt_t *ctx)
Check the tilt up movement's direction function.
uint8_t tilt_left(tilt_t *ctx)
Check the tilt left movement's direction function.
uint8_t tilt_down(tilt_t *ctx)
Check the tilt down movement's direction function.
TILT_RETVAL tilt_init(tilt_t *ctx, tilt_cfg_t *cfg)
Initialization function.
Click configuration structure definition.
Definition tilt.h:114
pin_name_t vo2
Definition tilt.h:118
pin_name_t vo1
Definition tilt.h:117
Click ctx object definition.
Definition tilt.h:102
digital_in_t vo2
Definition tilt.h:106
digital_in_t vo1
Definition tilt.h:105