motion4  2.0.0.0
motion4.h
Go to the documentation of this file.
1 /****************************************************************************
2 ** Copyright (C) 2020 MikroElektronika d.o.o.
3 ** Contact: https://www.mikroe.com/contact
4 **
5 ** Permission is hereby granted, free of charge, to any person obtaining a copy
6 ** of this software and associated documentation files (the "Software"), to deal
7 ** in the Software without restriction, including without limitation the rights
8 ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 ** copies of the Software, and to permit persons to whom the Software is
10 ** furnished to do so, subject to the following conditions:
11 ** The above copyright notice and this permission notice shall be
12 ** included in all copies or substantial portions of the Software.
13 **
14 ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16 ** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18 ** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19 ** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 ** USE OR OTHER DEALINGS IN THE SOFTWARE.
21 ****************************************************************************/
22 
28 #ifndef MOTION4_H
29 #define MOTION4_H
30 
31 #ifdef __cplusplus
32 extern "C"{
33 #endif
34 
39 #ifdef PREINIT_SUPPORTED
40 #include "preinit.h"
41 #endif
42 
43 #ifdef MikroCCoreVersion
44  #if MikroCCoreVersion >= 1
45  #include "delays.h"
46  #endif
47 #endif
48 
49 #include "drv_digital_out.h"
50 #include "drv_digital_in.h"
51 
52 
73 #define MOTION4_MODULE_ENABLE 0x00
74 #define MOTION4_MODULE_DISABLE 0x01
75 #define MOTION4_NO_DETECT_OBJECT 0x00
76 #define MOTION4_DETECT_OBJECT 0x01
77  // motion4_set
79 
80 
95 #define MOTION4_MAP_MIKROBUS( cfg, mikrobus ) \
96  cfg.en = MIKROBUS( mikrobus, MIKROBUS_RST ); \
97  cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
98  // motion4_map // motion4
101 
106 typedef struct
107 {
108  // Output pins
109 
110  digital_out_t en;
111 
112  // Input pins
113 
114  digital_in_t int_pin;
115 
116 
117 } motion4_t;
118 
123 typedef struct
124 {
125  // Additional gpio pins
126 
127  pin_name_t en;
128  pin_name_t int_pin;
130 } motion4_cfg_t;
131 
136 typedef enum
137 {
139  MOTION4_ERROR = -1
140 
142 
149 typedef enum
150 {
153 
155 
156 typedef enum
157 {
160 
162 
163 
174 
189 err_t motion4_init ( motion4_t *ctx, motion4_cfg_t *cfg );
190 
200 void motion4_enable ( motion4_t *ctx, uint8_t state );
201 
212 
213 
214 
215 #ifdef __cplusplus
216 }
217 #endif
218 #endif // MOTION4_H
219  // motion4
221 
222 // ------------------------------------------------------------------------ END
motion4_cfg_setup
void motion4_cfg_setup(motion4_cfg_t *cfg)
Motion 4 configuration object setup function.
motion4_cfg_t::int_pin
pin_name_t int_pin
Definition: motion4.h:128
motion4_detect_state
uint8_t motion4_detect_state(motion4_t *ctx)
Get detection state function.
motion4_cfg_t::en
pin_name_t en
Definition: motion4.h:127
motion4_t::int_pin
digital_in_t int_pin
Definition: motion4.h:114
motion4_detect_state_t
motion4_detect_state_t
Definition: motion4.h:150
MOTION4_ERROR
@ MOTION4_ERROR
Definition: motion4.h:139
MOTION4_PIN_STATE_HIGH
@ MOTION4_PIN_STATE_HIGH
Definition: motion4.h:159
MOTION4_DETECTED
@ MOTION4_DETECTED
Definition: motion4.h:152
MOTION4_PIN_STATE_LOW
@ MOTION4_PIN_STATE_LOW
Definition: motion4.h:158
motion4_init
err_t motion4_init(motion4_t *ctx, motion4_cfg_t *cfg)
Motion 4 initialization function.
MOTION4_NO_DETECT
@ MOTION4_NO_DETECT
Definition: motion4.h:151
motion4_t::en
digital_out_t en
Definition: motion4.h:110
MOTION4_OK
@ MOTION4_OK
Definition: motion4.h:138
motion4_return_value_t
motion4_return_value_t
Motion 4 Click return value data.
Definition: motion4.h:137
motion4_t
Motion 4 Click context object.
Definition: motion4.h:107
motion4_pin_state_t
motion4_pin_state_t
Definition: motion4.h:157
motion4_cfg_t
Motion 4 Click configuration object.
Definition: motion4.h:124
motion4_enable
void motion4_enable(motion4_t *ctx, uint8_t state)
Enable motion sensor function.