driver 2.0.0.0
driver.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 DRIVER_H
36#define DRIVER_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 DRIVER_MAP_MIKROBUS( cfg, mikrobus ) \
66 cfg.in1= MIKROBUS( mikrobus, MIKROBUS_AN ); \
67 cfg.in2= MIKROBUS( mikrobus, MIKROBUS_RST ); \
68 cfg.in3= MIKROBUS( mikrobus, MIKROBUS_CS ); \
69 cfg.in4= MIKROBUS( mikrobus, MIKROBUS_PWM ); \
70 cfg.in5= MIKROBUS( mikrobus, MIKROBUS_INT ); \
71 cfg.in6= MIKROBUS( mikrobus, MIKROBUS_RX ); \
72 cfg.in7= MIKROBUS( mikrobus, MIKROBUS_TX )
73 //RX and TX are inverted because of mapping
74
81#define DRIVER_RETVAL uint8_t
82
83#define DRIVER_OK 0x00
84#define DRIVER_INIT_ERROR 0xFF
91#define PULSE_WIDTH 3000
92#define ENABLE_IN 0
93#define DISABLE_IN 1
96 // End group macro
97// --------------------------------------------------------------- PUBLIC TYPES
106typedef struct
107{
108 // Output pins
109
110 digital_out_t in1;
111 digital_out_t in2;
112 digital_out_t in3;
113 digital_out_t in4;
114 digital_out_t in5;
115 digital_out_t in6;
116 digital_out_t in7;
117
118} driver_t;
119
123typedef struct
124{
125 // Additional gpio pins
126
127 pin_name_t in1;
128 pin_name_t in2;
129 pin_name_t in3;
130 pin_name_t in4;
131 pin_name_t in5;
132 pin_name_t in6;
133 pin_name_t in7;
134
136
137 // End types group
138// ------------------------------------------------------------------ CONSTANTS
139
140// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
141
147#ifdef __cplusplus
148extern "C"{
149#endif
150
160
169
178void driver_set_in1 ( driver_t *ctx, uint8_t state );
179
188void driver_set_in2 ( driver_t *ctx, uint8_t state );
189
198void driver_set_in3 ( driver_t *ctx, uint8_t state );
199
207void driver_set_in4 ( driver_t *ctx, uint8_t state );
208
216void driver_set_in5 ( driver_t *ctx, uint8_t state );
217
225void driver_set_in6 ( driver_t *ctx, uint8_t state );
226
234void driver_set_in7 ( driver_t *ctx, uint8_t state );
235
236
237#ifdef __cplusplus
238}
239#endif
240#endif // _DRIVER_H_
241
242 // End public_function group
244
245// ------------------------------------------------------------------------- END
#define DRIVER_RETVAL
Definition driver.h:81
void driver_set_in4(driver_t *ctx, uint8_t state)
IN4 Set function.
void driver_set_in3(driver_t *ctx, uint8_t state)
IN3 Set function.
void driver_set_in7(driver_t *ctx, uint8_t state)
IN7 Set function.
void driver_set_in6(driver_t *ctx, uint8_t state)
IN6 Set function.
void driver_set_in2(driver_t *ctx, uint8_t state)
IN2 Set function.
void driver_cfg_setup(driver_cfg_t *cfg)
Config Object Initialization function.
void driver_set_in1(driver_t *ctx, uint8_t state)
IN1 Set function.
void driver_set_in5(driver_t *ctx, uint8_t state)
IN5 Set function.
DRIVER_RETVAL driver_init(driver_t *ctx, driver_cfg_t *cfg)
Initialization function.
Click configuration structure definition.
Definition driver.h:124
pin_name_t in5
Definition driver.h:131
pin_name_t in2
Definition driver.h:128
pin_name_t in1
Definition driver.h:127
pin_name_t in4
Definition driver.h:130
pin_name_t in6
Definition driver.h:132
pin_name_t in7
Definition driver.h:133
pin_name_t in3
Definition driver.h:129
Click ctx object definition.
Definition driver.h:107
digital_out_t in5
Definition driver.h:114
digital_out_t in2
Definition driver.h:111
digital_out_t in7
Definition driver.h:116
digital_out_t in3
Definition driver.h:112
digital_out_t in4
Definition driver.h:113
digital_out_t in1
Definition driver.h:110
digital_out_t in6
Definition driver.h:115