relay  2.0.0.0
relay.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 RELAY_H
36 #define RELAY_H
37 
38 #include "drv_digital_out.h"
39 
40 // -------------------------------------------------------------- PUBLIC MACROS
50 #define RELAY_MAP_MIKROBUS( cfg, mikrobus ) \
51  cfg.rel2= MIKROBUS( mikrobus, MIKROBUS_CS ); \
52  cfg.rel1= MIKROBUS( mikrobus, MIKROBUS_PWM );
53 
59 #define RELAY_RETVAL uint8_t
60 
61 #define RELAY_OK 0x00
62 #define RELAY_INIT_ERROR 0xFF
63 
69 #define RELAY_STATE_ON 1
70 #define RELAY_STATE_OFF 0
71 
77 #define RELAY_NUM_1 1
78 #define RELAY_NUM_2 2
79  // End group macro
82 // --------------------------------------------------------------- PUBLIC TYPES
91 typedef struct
92 {
93  // Output pins
94 
95  digital_out_t rel2;
96  digital_out_t rel1;
97 
98 } relay_t;
99 
103 typedef struct
104 {
105  // Additional gpio pins
106 
107  pin_name_t rel2;
108  pin_name_t rel1;
109 
110 } relay_cfg_t;
111  // End types group
113 
114 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
115 
121 #ifdef __cplusplus
122 extern "C"{
123 #endif
124 
133 void relay_cfg_setup ( relay_cfg_t *cfg );
134 
143 
153 void relay_default_cfg ( relay_t *ctx );
154 
164 void relay_set_state ( relay_t *ctx, uint8_t relay, uint8_t state );
165 
166 #ifdef __cplusplus
167 }
168 #endif
169 #endif // _RELAY_H_
170  // End public_function group
173 
174 // ------------------------------------------------------------------------- END
void relay_cfg_setup(relay_cfg_t *cfg)
Config Object Initialization function.
void relay_set_state(relay_t *ctx, uint8_t relay, uint8_t state)
Relay set state.
#define RELAY_RETVAL
Definition: relay.h:59
RELAY_RETVAL relay_init(relay_t *ctx, relay_cfg_t *cfg)
Initialization function.
void relay_default_cfg(relay_t *ctx)
Click Default Configuration function.
Click configuration structure definition.
Definition: relay.h:103
Click ctx object definition.
Definition: relay.h:91
digital_out_t rel2
Definition: relay.h:95
digital_out_t rel1
Definition: relay.h:96
pin_name_t rel2
Definition: relay.h:107
pin_name_t rel1
Definition: relay.h:108