relay3 2.0.0.0
relay3.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 RELAY3_H
36#define RELAY3_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#include "drv_digital_in.h"
54
55// -------------------------------------------------------------- PUBLIC MACROS
65#define RELAY3_MAP_MIKROBUS( cfg, mikrobus ) \
66 cfg.re1= MIKROBUS( mikrobus, MIKROBUS_RST ); \
67 cfg.re2= MIKROBUS( mikrobus, MIKROBUS_CS );
74#define RELAY3_RETVAL uint8_t
75
76#define RELAY3_OK 0x00
77#define RELAY3_INIT_ERROR 0xFF
84#define RELAY3_RELAY_1 0x01
85#define RELAY3_RELAY_2 0x02
86#define RELAY3_BOTH_RELAYS 0x03
93#define RELAY3_SECONDS 0x00
94#define RELAY3_MILISECONDS 0x01
97 // End group macro
98// --------------------------------------------------------------- PUBLIC TYPES
107typedef struct
108{
109 // Output pins
110
111 digital_out_t re1;
112 digital_out_t re2;
113
114} relay3_t;
115
119typedef struct
120{
121 // Additional gpio pins
122
123 pin_name_t re1;
124 pin_name_t re2;
125
127
128 // End types group
129// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
130
136#ifdef __cplusplus
137extern "C"{
138#endif
139
149
158
167void relay3_relay_on ( relay3_t *ctx, uint8_t relay );
168
177void relay3_relay_off ( relay3_t *ctx, uint8_t relay );
178
189void relay3_on_delay ( relay3_t *ctx, uint8_t relay, uint8_t units, uint16_t time );
190
201void relay3_on_delay ( relay3_t *ctx, uint8_t relay, uint8_t units, uint16_t time );
202
203#ifdef __cplusplus
204}
205#endif
206#endif // _RELAY3_H_
207
208 // End public_function group
210
211// ------------------------------------------------------------------------- END
#define RELAY3_RETVAL
Definition relay3.h:74
void relay3_relay_on(relay3_t *ctx, uint8_t relay)
Relay on function.
RELAY3_RETVAL relay3_init(relay3_t *ctx, relay3_cfg_t *cfg)
Initialization function.
void relay3_relay_off(relay3_t *ctx, uint8_t relay)
Relay off function.
void relay3_cfg_setup(relay3_cfg_t *cfg)
Config Object Initialization function.
void relay3_on_delay(relay3_t *ctx, uint8_t relay, uint8_t units, uint16_t time)
Relay on with delay function.
Click configuration structure definition.
Definition relay3.h:120
pin_name_t re1
Definition relay3.h:123
pin_name_t re2
Definition relay3.h:124
Click ctx object definition.
Definition relay3.h:108
digital_out_t re1
Definition relay3.h:111
digital_out_t re2
Definition relay3.h:112