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