reed
2.0.0.0
cmake
reed
lib_reed
include
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
42
#ifdef PREINIT_SUPPORTED
43
#include "preinit.h"
44
#endif
45
46
#ifdef MikroCCoreVersion
47
#if MikroCCoreVersion >= 1
48
#include "delays.h"
49
#endif
50
#endif
51
52
#include "drv_digital_in.h"
53
54
// -------------------------------------------------------------- PUBLIC MACROS
64
#define REED_MAP_MIKROBUS( cfg, mikrobus ) \
65
cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS )
66
72
#define REED_OK 0
73
#define REED_INIT_ERROR (-1)
74
80
#define REED_NO_MAGNETIC_FIELD 0
81
#define REED_MAGNETIC_FIELD_DETECTED 1
82
// End group macro
85
// --------------------------------------------------------------- PUBLIC TYPES
94
typedef
struct
95
{
96
// Input pins
97
98
digital_in_t
cs
;
99
100
}
reed_t
;
101
105
typedef
struct
106
{
107
// Additional gpio pins
108
109
pin_name_t
cs
;
110
111
}
reed_cfg_t
;
112
// End types group
114
// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
120
#ifdef __cplusplus
121
extern
"C"
{
122
#endif
123
132
void
reed_cfg_setup
(
reed_cfg_t
*cfg );
133
144
err_t
reed_init
(
reed_t
*ctx,
reed_cfg_t
*cfg );
145
158
uint8_t
reed_get_status
(
reed_t
*ctx );
159
160
#ifdef __cplusplus
161
}
162
#endif
163
#endif // REED_H
164
// End public_function group
167
168
// ------------------------------------------------------------------------ END
reed_cfg_t
Click configuration structure definition.
Definition:
reed.h:106
reed_cfg_t::cs
pin_name_t cs
Definition:
reed.h:109
reed_t::cs
digital_in_t cs
Definition:
reed.h:98
reed_t
Click ctx object definition.
Definition:
reed.h:95
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.
Generated by
1.8.20