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 "drv_digital_out.h"
36 #include "drv_digital_in.h"
37 
38 
59 #define MOTION4_MODULE_ENABLE 0x00
60 #define MOTION4_MODULE_DISABLE 0x01
61 #define MOTION4_NO_DETECT_OBJECT 0x00
62 #define MOTION4_DETECT_OBJECT 0x01
63  // motion4_set
65 
66 
81 #define MOTION4_MAP_MIKROBUS( cfg, mikrobus ) \
82  cfg.en = MIKROBUS( mikrobus, MIKROBUS_RST ); \
83  cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
84  // motion4_map // motion4
87 
92 typedef struct
93 {
94  // Output pins
95 
96  digital_out_t en;
97 
98  // Input pins
99 
100  digital_in_t int_pin;
101 
102 
103 } motion4_t;
104 
109 typedef struct
110 {
111  // Additional gpio pins
112 
113  pin_name_t en;
114  pin_name_t int_pin;
116 } motion4_cfg_t;
117 
122 typedef enum
123 {
125  MOTION4_ERROR = -1
126 
128 
135 typedef enum
136 {
139 
141 
142 typedef enum
143 {
146 
148 
149 
160 
175 err_t motion4_init ( motion4_t *ctx, motion4_cfg_t *cfg );
176 
186 void motion4_enable ( motion4_t *ctx, uint8_t state );
187 
198 
199 
200 
201 #ifdef __cplusplus
202 }
203 #endif
204 #endif // MOTION4_H
205  // motion4
207 
208 // ------------------------------------------------------------------------ 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:114
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:113
motion4_t::int_pin
digital_in_t int_pin
Definition: motion4.h:100
motion4_detect_state_t
motion4_detect_state_t
Definition: motion4.h:136
MOTION4_ERROR
@ MOTION4_ERROR
Definition: motion4.h:125
MOTION4_PIN_STATE_HIGH
@ MOTION4_PIN_STATE_HIGH
Definition: motion4.h:145
MOTION4_DETECTED
@ MOTION4_DETECTED
Definition: motion4.h:138
MOTION4_PIN_STATE_LOW
@ MOTION4_PIN_STATE_LOW
Definition: motion4.h:144
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:137
motion4_t::en
digital_out_t en
Definition: motion4.h:96
MOTION4_OK
@ MOTION4_OK
Definition: motion4.h:124
motion4_return_value_t
motion4_return_value_t
Motion 4 Click return value data.
Definition: motion4.h:123
motion4_t
Motion 4 Click context object.
Definition: motion4.h:93
motion4_pin_state_t
motion4_pin_state_t
Definition: motion4.h:143
motion4_cfg_t
Motion 4 Click configuration object.
Definition: motion4.h:110
motion4_enable
void motion4_enable(motion4_t *ctx, uint8_t state)
Enable motion sensor function.