tilt  2.0.0.0
tilt.h
Go to the documentation of this file.
1 /*
2  * MikroSDK - MikroE Software Development Kit
3  * Copyright (c) 2019, MikroElektronika - www.mikroe.com
4  * All rights reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * 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 )
53 
59 #define TILT_RETVAL uint8_t
60 
61 #define TILT_OK 0x00
62 #define TILT_INIT_ERROR 0xFF
63 
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
75  // End group macro
78 // --------------------------------------------------------------- PUBLIC TYPES
87 typedef struct
88 {
89  // Input pins
90 
91  digital_in_t vo1;
92  digital_in_t vo2;
93 
94 } tilt_t;
95 
99 typedef 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
134 extern "C"{
135 #endif
136 
145 void tilt_cfg_setup ( tilt_cfg_t *cfg );
146 
154 TILT_RETVAL tilt_init ( tilt_t *ctx, tilt_cfg_t *cfg );
155 
168 uint8_t tilt_left ( tilt_t *ctx );
169 
182 uint8_t tilt_right ( tilt_t *ctx );
183 
196 uint8_t tilt_up ( tilt_t *ctx );
197 
210 uint8_t tilt_down ( tilt_t *ctx );
211 
227 uint8_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
digital_in_t vo1
Definition: tilt.h:91
Click configuration structure definition.
Definition: tilt.h:99
digital_in_t vo2
Definition: tilt.h:92
#define TILT_RETVAL
Definition: tilt.h:59
uint8_t tilt_up(tilt_t *ctx)
Check the tilt up movement's direction function.
uint8_t tilt_direction(tilt_t *ctx)
Check the tilt movement's direction function.
pin_name_t vo2
Definition: tilt.h:104
uint8_t tilt_right(tilt_t *ctx)
Check the tilt right movement's direction function.
pin_name_t vo1
Definition: tilt.h:103
Click ctx object definition.
Definition: tilt.h:87
void tilt_cfg_setup(tilt_cfg_t *cfg)
Config Object Initialization function.
TILT_RETVAL tilt_init(tilt_t *ctx, tilt_cfg_t *cfg)
Initialization function.
uint8_t tilt_down(tilt_t *ctx)
Check the tilt down movement's direction function.
uint8_t tilt_left(tilt_t *ctx)
Check the tilt left movement's direction function.