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 
35 #include "mikrosdk_version.h"
36 
37 #ifdef __GNUC__
38 #if mikroSDK_GET_VERSION < 20800ul
39 #include "rcu_delays.h"
40 #else
41 #include "delays.h"
42 #endif
43 #endif
44 
45 #include "drv_digital_out.h"
46 #include "drv_digital_in.h"
47 
48 
69 #define MOTION4_MODULE_ENABLE 0x00
70 #define MOTION4_MODULE_DISABLE 0x01
71 #define MOTION4_NO_DETECT_OBJECT 0x00
72 #define MOTION4_DETECT_OBJECT 0x01
73  // motion4_set
75 
76 
91 #define MOTION4_MAP_MIKROBUS( cfg, mikrobus ) \
92  cfg.en = MIKROBUS( mikrobus, MIKROBUS_RST ); \
93  cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
94  // motion4_map // motion4
97 
102 typedef struct
103 {
104  // Output pins
105 
106  digital_out_t en;
107 
108  // Input pins
109 
110  digital_in_t int_pin;
111 
112 
113 } motion4_t;
114 
119 typedef struct
120 {
121  // Additional gpio pins
122 
123  pin_name_t en;
124  pin_name_t int_pin;
126 } motion4_cfg_t;
127 
132 typedef enum
133 {
135  MOTION4_ERROR = -1
136 
138 
145 typedef enum
146 {
149 
151 
152 typedef enum
153 {
156 
158 
159 
170 
185 err_t motion4_init ( motion4_t *ctx, motion4_cfg_t *cfg );
186 
196 void motion4_enable ( motion4_t *ctx, uint8_t state );
197 
208 
209 
210 
211 #ifdef __cplusplus
212 }
213 #endif
214 #endif // MOTION4_H
215  // motion4
217 
218 // ------------------------------------------------------------------------ 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:124
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:123
motion4_t::int_pin
digital_in_t int_pin
Definition: motion4.h:110
motion4_detect_state_t
motion4_detect_state_t
Definition: motion4.h:146
MOTION4_ERROR
@ MOTION4_ERROR
Definition: motion4.h:135
MOTION4_PIN_STATE_HIGH
@ MOTION4_PIN_STATE_HIGH
Definition: motion4.h:155
MOTION4_DETECTED
@ MOTION4_DETECTED
Definition: motion4.h:148
MOTION4_PIN_STATE_LOW
@ MOTION4_PIN_STATE_LOW
Definition: motion4.h:154
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:147
motion4_t::en
digital_out_t en
Definition: motion4.h:106
MOTION4_OK
@ MOTION4_OK
Definition: motion4.h:134
motion4_return_value_t
motion4_return_value_t
Motion 4 Click return value data.
Definition: motion4.h:133
motion4_t
Motion 4 Click context object.
Definition: motion4.h:103
motion4_pin_state_t
motion4_pin_state_t
Definition: motion4.h:153
motion4_cfg_t
Motion 4 Click configuration object.
Definition: motion4.h:120
motion4_enable
void motion4_enable(motion4_t *ctx, uint8_t state)
Enable motion sensor function.