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 "drv_digital_in.h"
39 
40 // -------------------------------------------------------------- PUBLIC MACROS
50 #define REED_MAP_MIKROBUS( cfg, mikrobus ) \
51  cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS )
52 
58 #define REED_OK 0
59 #define REED_INIT_ERROR (-1)
60 
66 #define REED_NO_MAGNETIC_FIELD 0
67 #define REED_MAGNETIC_FIELD_DETECTED 1
68  // End group macro
71 // --------------------------------------------------------------- PUBLIC TYPES
80 typedef struct
81 {
82  // Input pins
83 
84  digital_in_t cs;
85 
86 } reed_t;
87 
91 typedef struct
92 {
93  // Additional gpio pins
94 
95  pin_name_t cs;
96 
97 } reed_cfg_t;
98  // End types group
100 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
106 #ifdef __cplusplus
107 extern "C"{
108 #endif
109 
119 
130 err_t reed_init ( reed_t *ctx, reed_cfg_t *cfg );
131 
144 uint8_t reed_get_status ( reed_t *ctx );
145 
146 #ifdef __cplusplus
147 }
148 #endif
149 #endif // REED_H
150  // End public_function group
153 
154 // ------------------------------------------------------------------------ END
reed_cfg_t
Click configuration structure definition.
Definition: reed.h:92
reed_cfg_t::cs
pin_name_t cs
Definition: reed.h:95
reed_t::cs
digital_in_t cs
Definition: reed.h:84
reed_t
Click ctx object definition.
Definition: reed.h:81
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.