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
38#include "drv_digital_in.h"
39
40// -------------------------------------------------------------- PUBLIC MACROS
50#define TILT_MAP_MIKROBUS( cfg, mikrobus ) \
51 cfg.vo1= MIKROBUS( mikrobus, MIKROBUS_PWM ); \
52 cfg.vo2= MIKROBUS( mikrobus, MIKROBUS_INT )
59#define TILT_RETVAL uint8_t
60
61#define TILT_OK 0x00
62#define TILT_INIT_ERROR 0xFF
69#define TILT_NO_DETECTION 0
70#define TILT_DETECTION 1
71#define TILT_LEFT_DETECTION 2
72#define TILT_RIGHT_DETECTION 3
73#define TILT_UP_DETECTION 4
74#define TILT_DOWN_DETECTION 5 // End group macro
78// --------------------------------------------------------------- PUBLIC TYPES
87typedef struct
88{
89 // Input pins
90
91 digital_in_t vo1;
92 digital_in_t vo2;
93
94} tilt_t;
95
99typedef struct
100{
101 // Additional gpio pins
102
103 pin_name_t vo1;
104 pin_name_t vo2;
105
106} tilt_cfg_t;
107 // End types group
109// ------------------------------------------------------------------ CONSTANTS // End constants group
118// ------------------------------------------------------------------ VARIABLES // End variable group
126// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
127
133#ifdef __cplusplus
134extern "C"{
135#endif
136
146
155
168uint8_t tilt_left ( tilt_t *ctx );
169
182uint8_t tilt_right ( tilt_t *ctx );
183
196uint8_t tilt_up ( tilt_t *ctx );
197
210uint8_t tilt_down ( tilt_t *ctx );
211
227uint8_t tilt_direction ( tilt_t *ctx );
228
229#ifdef __cplusplus
230}
231#endif
232#endif // _TILT_H_
233 // End public_function group
236
237// ------------------------------------------------------------------------- END
#define TILT_RETVAL
Definition: tilt.h:59
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:100
pin_name_t vo2
Definition: tilt.h:104
pin_name_t vo1
Definition: tilt.h:103
Click ctx object definition.
Definition: tilt.h:88
digital_in_t vo2
Definition: tilt.h:92
digital_in_t vo1
Definition: tilt.h:91