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
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 )
72#define REED_OK 0
73#define REED_INIT_ERROR (-1)
80#define REED_NO_MAGNETIC_FIELD 0
81#define REED_MAGNETIC_FIELD_DETECTED 1
84 // End group macro
85// --------------------------------------------------------------- PUBLIC TYPES
94typedef struct
95{
96 // Input pins
97
98 digital_in_t cs;
99
100} reed_t;
101
105typedef struct
106{
107 // Additional gpio pins
108
109 pin_name_t cs;
110
111} reed_cfg_t;
112
113 // End types group
114// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
120#ifdef __cplusplus
121extern "C"{
122#endif
123
133
144err_t reed_init ( reed_t *ctx, reed_cfg_t *cfg );
145
158uint8_t reed_get_status ( reed_t *ctx );
159
160#ifdef __cplusplus
161}
162#endif
163#endif // REED_H
164
165 // End public_function group
167
168// ------------------------------------------------------------------------ END
void reed_cfg_setup(reed_cfg_t *cfg)
Config Object Initialization function.
err_t reed_init(reed_t *ctx, reed_cfg_t *cfg)
Initialization function.
uint8_t reed_get_status(reed_t *ctx)
Get sensor magnetic detected status function.
Click configuration structure definition.
Definition reed.h:106
pin_name_t cs
Definition reed.h:109
Click ctx object definition.
Definition reed.h:95
digital_in_t cs
Definition reed.h:98