hallswitch 2.0.0.0
hallswitch.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 HALLSWITCH_H
36#define HALLSWITCH_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_out.h"
53
54// -------------------------------------------------------------- PUBLIC MACROS
64#define HALLSWITCH_MAP_MIKROBUS( cfg, mikrobus ) \
65 cfg.np= MIKROBUS( mikrobus, MIKROBUS_CS ); \
66 cfg.sp= MIKROBUS( mikrobus, MIKROBUS_INT );
73#define HALLSWITCH_RETVAL uint8_t
74
75#define HALLSWITCH_OK 0x00
76#define HALLSWITCH_INIT_ERROR 0xFF
83#define HALLSWITCH_POLE_ACTIVE 0x00
84#define HALLSWITCH_POLE_NO_ACTIVE 0x01
87 // End group macro
88// --------------------------------------------------------------- PUBLIC TYPES
97typedef struct
98{
99 // Output pins
100
101 digital_out_t np;
102 digital_out_t sp;
103
105
109typedef struct
110{
111 // Additional gpio pins
112
113 pin_name_t np;
114 pin_name_t sp;
115
117
118 // End types group
119// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
120
126#ifdef __cplusplus
127extern "C"{
128#endif
129
139
150
158void hallswitch_set_npole ( hallswitch_t *ctx, uint8_t state );
159
167void hallswitch_set_spole ( hallswitch_t *ctx, uint8_t state );
168
169#ifdef __cplusplus
170}
171#endif
172#endif // _HALLSWITCH_H_
173
174 // End public_function group
176
177// ------------------------------------------------------------------------- END
#define HALLSWITCH_RETVAL
Definition hallswitch.h:73
void hallswitch_set_spole(hallswitch_t *ctx, uint8_t state)
Function for turn on and turn off S Pole.
void hallswitch_set_npole(hallswitch_t *ctx, uint8_t state)
Function for turn on and turn off N Pole.
HALLSWITCH_RETVAL hallswitch_init(hallswitch_t *ctx, hallswitch_cfg_t *cfg)
Initialization function.
void hallswitch_cfg_setup(hallswitch_cfg_t *cfg)
Config Object Initialization function.
Click configuration structure definition.
Definition hallswitch.h:110
pin_name_t sp
Definition hallswitch.h:114
pin_name_t np
Definition hallswitch.h:113
Click ctx object definition.
Definition hallswitch.h:98
digital_out_t np
Definition hallswitch.h:101
digital_out_t sp
Definition hallswitch.h:102