signalrelay 2.0.0.0
signalrelay.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 SIGNALRELAY_H
36#define SIGNALRELAY_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 SIGNALRELAY_MAP_MIKROBUS( cfg, mikrobus ) \
65 cfg.re1= MIKROBUS( mikrobus, MIKROBUS_AN ); \
66 cfg.re2= MIKROBUS( mikrobus, MIKROBUS_RST ); \
67 cfg.re3= MIKROBUS( mikrobus, MIKROBUS_CS ); \
68 cfg.re4= MIKROBUS( mikrobus, MIKROBUS_PWM );
75#define SIGNALRELAY_RETVAL uint8_t
76
77#define SIGNALRELAY_OK 0x00
78#define SIGNALRELAY_INIT_ERROR 0xFF
85#define SIGNALRELAY_RELAY_1 1
86#define SIGNALRELAY_RELAY_2 2
87#define SIGNALRELAY_RELAY_3 3
88#define SIGNALRELAY_RELAY_4 4
95#define SIGNALRELAY_STATE_ON 0x01
96#define SIGNALRELAY_STATE_OFF 0x00
99 // End group macro
100// --------------------------------------------------------------- PUBLIC TYPES
109typedef struct
110{
111 // Output pins
112
113 digital_out_t re1;
114 digital_out_t re2;
115 digital_out_t re3;
116 digital_out_t re4;
117
119
123typedef struct
124{
125 // Additional gpio pins
126
127 pin_name_t re1;
128 pin_name_t re2;
129 pin_name_t re3;
130 pin_name_t re4;
131
133
134 // End types group
135// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
136
142#ifdef __cplusplus
143extern "C"{
144#endif
145
155
164
174
182void signalrelay_relay_state( signalrelay_t *ctx, uint8_t relay, uint8_t state );
183
184
185#ifdef __cplusplus
186}
187#endif
188#endif // _SIGNALRELAY_H_
189
190 // End public_function group
192
193// ------------------------------------------------------------------------- END
#define SIGNALRELAY_RETVAL
Definition signalrelay.h:75
SIGNALRELAY_RETVAL signalrelay_init(signalrelay_t *ctx, signalrelay_cfg_t *cfg)
Initialization function.
void signalrelay_default_cfg(signalrelay_t *ctx)
Click Default Configuration function.
void signalrelay_cfg_setup(signalrelay_cfg_t *cfg)
Config Object Initialization function.
void signalrelay_relay_state(signalrelay_t *ctx, uint8_t relay, uint8_t state)
Relays state.
Click configuration structure definition.
Definition signalrelay.h:124
pin_name_t re4
Definition signalrelay.h:130
pin_name_t re3
Definition signalrelay.h:129
pin_name_t re1
Definition signalrelay.h:127
pin_name_t re2
Definition signalrelay.h:128
Click ctx object definition.
Definition signalrelay.h:110
digital_out_t re1
Definition signalrelay.h:113
digital_out_t re2
Definition signalrelay.h:114
digital_out_t re4
Definition signalrelay.h:116
digital_out_t re3
Definition signalrelay.h:115