reed  2.0.0.0
reed.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 REED_H
36 #define REED_H
37 
38 #include "mikrosdk_version.h"
39 
40 #ifdef __GNUC__
41 #if mikroSDK_GET_VERSION < 20800ul
42 #include "rcu_delays.h"
43 #else
44 #include "delays.h"
45 #endif
46 #endif
47 
48 #include "drv_digital_in.h"
49 
50 // -------------------------------------------------------------- PUBLIC MACROS
60 #define REED_MAP_MIKROBUS( cfg, mikrobus ) \
61  cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS )
62 
68 #define REED_OK 0
69 #define REED_INIT_ERROR (-1)
70 
76 #define REED_NO_MAGNETIC_FIELD 0
77 #define REED_MAGNETIC_FIELD_DETECTED 1
78  // End group macro
81 // --------------------------------------------------------------- PUBLIC TYPES
90 typedef struct
91 {
92  // Input pins
93 
94  digital_in_t cs;
95 
96 } reed_t;
97 
101 typedef struct
102 {
103  // Additional gpio pins
104 
105  pin_name_t cs;
106 
107 } reed_cfg_t;
108  // End types group
110 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
116 #ifdef __cplusplus
117 extern "C"{
118 #endif
119 
129 
140 err_t reed_init ( reed_t *ctx, reed_cfg_t *cfg );
141 
154 uint8_t reed_get_status ( reed_t *ctx );
155 
156 #ifdef __cplusplus
157 }
158 #endif
159 #endif // REED_H
160  // End public_function group
163 
164 // ------------------------------------------------------------------------ END
reed_cfg_t
Click configuration structure definition.
Definition: reed.h:102
reed_cfg_t::cs
pin_name_t cs
Definition: reed.h:105
reed_t::cs
digital_in_t cs
Definition: reed.h:94
reed_t
Click ctx object definition.
Definition: reed.h:91
reed_get_status
uint8_t reed_get_status(reed_t *ctx)
Get sensor magnetic detected status function.
reed_cfg_setup
void reed_cfg_setup(reed_cfg_t *cfg)
Config Object Initialization function.
reed_init
err_t reed_init(reed_t *ctx, reed_cfg_t *cfg)
Initialization function.