hbridge2 2.0.0.0
hbridge2.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 HBRIDGE2_H
36#define HBRIDGE2_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 HBRIDGE2_MAP_MIKROBUS( cfg, mikrobus ) \
66 cfg.gin= MIKROBUS( mikrobus, MIKROBUS_AN ); \
67 cfg.dir= MIKROBUS( mikrobus, MIKROBUS_RST ); \
68 cfg.end= MIKROBUS( mikrobus, MIKROBUS_CS ); \
69 cfg.pwm= MIKROBUS( mikrobus, MIKROBUS_PWM )
76#define HBRIDGE2_RETVAL uint8_t
77
78#define HBRIDGE2_OK 0x00
79#define HBRIDGE2_INIT_ERROR 0xFF
86#define HBRIDGE2_OUT1_H_OUT2_H 0x00
87#define HBRIDGE2_OUT1_H_OUT2_L 0x01
88#define HBRIDGE2_OUT1_L_OUT2_H 0x02
89#define HBRIDGE2_OUT1_Z_OUT2_Z 0x03
90
91#define HBRIDGE2_DISABLE 0x00
92#define HBRIDGE2_ENABLE 0x01
93
94#define HBRIDGE2_GOUT_HIGH 0x00
95#define HBRIDGE2_GOUT_LOW 0x01
98 // End group macro
99// --------------------------------------------------------------- PUBLIC TYPES
108typedef struct
109{
110 // Output pins
111
112 digital_out_t gin;
113 digital_out_t dir;
114 digital_out_t end;
115 digital_out_t pwm;
116
117 // Input pins
118
119} hbridge2_t;
120
124typedef struct
125{
126 // Additional gpio pins
127
128 pin_name_t gin;
129 pin_name_t dir;
130 pin_name_t end;
131 pin_name_t pwm;
132
134
135 // End types group
136// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
137
143#ifdef __cplusplus
144extern "C"{
145#endif
146
156
165
178uint8_t hbridge2_set_output ( hbridge2_t *ctx, uint8_t out_state );
179
190void hbridge2_enable ( hbridge2_t *ctx, uint8_t state );
191
200void hbridge2_set_gout ( hbridge2_t *ctx, uint8_t state );
201
202#ifdef __cplusplus
203}
204#endif
205#endif // _HBRIDGE2_H_
206
207 // End public_function group
209
210// ------------------------------------------------------------------------- END
#define HBRIDGE2_RETVAL
Definition hbridge2.h:76
void hbridge2_enable(hbridge2_t *ctx, uint8_t state)
Enable function.
HBRIDGE2_RETVAL hbridge2_init(hbridge2_t *ctx, hbridge2_cfg_t *cfg)
Initialization function.
void hbridge2_set_gout(hbridge2_t *ctx, uint8_t state)
GOUT Set function.
void hbridge2_cfg_setup(hbridge2_cfg_t *cfg)
Config Object Initialization function.
uint8_t hbridge2_set_output(hbridge2_t *ctx, uint8_t out_state)
Output Set function.
Click configuration structure definition.
Definition hbridge2.h:125
pin_name_t dir
Definition hbridge2.h:129
pin_name_t end
Definition hbridge2.h:130
pin_name_t pwm
Definition hbridge2.h:131
pin_name_t gin
Definition hbridge2.h:128
Click ctx object definition.
Definition hbridge2.h:109
digital_out_t pwm
Definition hbridge2.h:115
digital_out_t end
Definition hbridge2.h:114
digital_out_t dir
Definition hbridge2.h:113
digital_out_t gin
Definition hbridge2.h:112