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 
38 #include "drv_digital_out.h"
39 
40 // -------------------------------------------------------------- PUBLIC MACROS
50 #define HALLSWITCH_MAP_MIKROBUS( cfg, mikrobus ) \
51  cfg.np= MIKROBUS( mikrobus, MIKROBUS_CS ); \
52  cfg.sp= MIKROBUS( mikrobus, MIKROBUS_INT );
53 
59 #define HALLSWITCH_RETVAL uint8_t
60 
61 #define HALLSWITCH_OK 0x00
62 #define HALLSWITCH_INIT_ERROR 0xFF
63 
69 #define HALLSWITCH_POLE_ACTIVE 0x00
70 #define HALLSWITCH_POLE_NO_ACTIVE 0x01
71  // End group macro
74 // --------------------------------------------------------------- PUBLIC TYPES
83 typedef struct
84 {
85  // Output pins
86 
87  digital_out_t np;
88  digital_out_t sp;
89 
90 } hallswitch_t;
91 
95 typedef struct
96 {
97  // Additional gpio pins
98 
99  pin_name_t np;
100  pin_name_t sp;
101 
103  // End types group
105 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
106 
112 #ifdef __cplusplus
113 extern "C"{
114 #endif
115 
125 
136 
144 void hallswitch_set_npole ( hallswitch_t *ctx, uint8_t state );
145 
153 void hallswitch_set_spole ( hallswitch_t *ctx, uint8_t state );
154 
155 #ifdef __cplusplus
156 }
157 #endif
158 #endif // _HALLSWITCH_H_
159  // End public_function group
162 
163 // ------------------------------------------------------------------------- END
hallswitch_t::sp
digital_out_t sp
Definition: hallswitch.h:88
hallswitch_cfg_t::sp
pin_name_t sp
Definition: hallswitch.h:100
hallswitch_t::np
digital_out_t np
Definition: hallswitch.h:87
hallswitch_cfg_t
Click configuration structure definition.
Definition: hallswitch.h:95
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:83
HALLSWITCH_RETVAL
#define HALLSWITCH_RETVAL
Definition: hallswitch.h:59
hallswitch_cfg_t::np
pin_name_t np
Definition: hallswitch.h:99