hallswitch  2.0.0.0
hallswitch.h
Go to the documentation of this file.
1 /*
2  * MikroSDK - MikroE Software Development Kit
3  * Copyright (c) 2019, MikroElektronika - www.mikroe.com
4  * All rights reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * 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
void hallswitch_set_npole(hallswitch_t *ctx, uint8_t state)
Function for turn on and turn off N Pole.
Click ctx object definition.
Definition: hallswitch.h:83
digital_out_t sp
Definition: hallswitch.h:88
Click configuration structure definition.
Definition: hallswitch.h:95
void hallswitch_set_spole(hallswitch_t *ctx, uint8_t state)
Function for turn on and turn off S Pole.
#define HALLSWITCH_RETVAL
Definition: hallswitch.h:59
pin_name_t np
Definition: hallswitch.h:99
pin_name_t sp
Definition: hallswitch.h:100
HALLSWITCH_RETVAL hallswitch_init(hallswitch_t *ctx, hallswitch_cfg_t *cfg)
Initialization function.
digital_out_t np
Definition: hallswitch.h:87
void hallswitch_cfg_setup(hallswitch_cfg_t *cfg)
Config Object Initialization function.