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
38#include "drv_digital_out.h"
39#include "drv_digital_in.h"
40
41// -------------------------------------------------------------- PUBLIC MACROS
51#define DRIVER_MAP_MIKROBUS( cfg, mikrobus ) \
52 cfg.in1= MIKROBUS( mikrobus, MIKROBUS_AN ); \
53 cfg.in2= MIKROBUS( mikrobus, MIKROBUS_RST ); \
54 cfg.in3= MIKROBUS( mikrobus, MIKROBUS_CS ); \
55 cfg.in4= MIKROBUS( mikrobus, MIKROBUS_PWM ); \
56 cfg.in5= MIKROBUS( mikrobus, MIKROBUS_INT ); \
57 cfg.in6= MIKROBUS( mikrobus, MIKROBUS_RX ); \
58 cfg.in7= MIKROBUS( mikrobus, MIKROBUS_TX )
59 //RX and TX are inverted because of mapping
60
67#define DRIVER_RETVAL uint8_t
68
69#define DRIVER_OK 0x00
70#define DRIVER_INIT_ERROR 0xFF
77#define PULSE_WIDTH 3000
78#define ENABLE_IN 0
79#define DISABLE_IN 1 // End group macro
83// --------------------------------------------------------------- PUBLIC TYPES
92typedef struct
93{
94 // Output pins
95
96 digital_out_t in1;
97 digital_out_t in2;
98 digital_out_t in3;
99 digital_out_t in4;
100 digital_out_t in5;
101 digital_out_t in6;
102 digital_out_t in7;
103
104} driver_t;
105
109typedef struct
110{
111 // Additional gpio pins
112
113 pin_name_t in1;
114 pin_name_t in2;
115 pin_name_t in3;
116 pin_name_t in4;
117 pin_name_t in5;
118 pin_name_t in6;
119 pin_name_t in7;
120
122 // End types group
124// ------------------------------------------------------------------ CONSTANTS
125
126// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
127
133#ifdef __cplusplus
134extern "C"{
135#endif
136
146
155
164void driver_set_in1 ( driver_t *ctx, uint8_t state );
165
174void driver_set_in2 ( driver_t *ctx, uint8_t state );
175
184void driver_set_in3 ( driver_t *ctx, uint8_t state );
185
193void driver_set_in4 ( driver_t *ctx, uint8_t state );
194
202void driver_set_in5 ( driver_t *ctx, uint8_t state );
203
211void driver_set_in6 ( driver_t *ctx, uint8_t state );
212
220void driver_set_in7 ( driver_t *ctx, uint8_t state );
221
222
223#ifdef __cplusplus
224}
225#endif
226#endif // _DRIVER_H_
227 // End public_function group
230
231// ------------------------------------------------------------------------- END
#define DRIVER_RETVAL
Definition: driver.h:67
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:110
pin_name_t in5
Definition: driver.h:117
pin_name_t in2
Definition: driver.h:114
pin_name_t in1
Definition: driver.h:113
pin_name_t in4
Definition: driver.h:116
pin_name_t in6
Definition: driver.h:118
pin_name_t in7
Definition: driver.h:119
pin_name_t in3
Definition: driver.h:115
Click ctx object definition.
Definition: driver.h:93
digital_out_t in5
Definition: driver.h:100
digital_out_t in2
Definition: driver.h:97
digital_out_t in7
Definition: driver.h:102
digital_out_t in3
Definition: driver.h:98
digital_out_t in4
Definition: driver.h:99
digital_out_t in1
Definition: driver.h:96
digital_out_t in6
Definition: driver.h:101