hbridgedriver 2.0.0.0
hbridgedriver.h
Go to the documentation of this file.
1/****************************************************************************
2** Copyright (C) 2020 MikroElektronika d.o.o.
3** Contact: https://www.mikroe.com/contact
4**
5** Permission is hereby granted, free of charge, to any person obtaining a copy
6** of this software and associated documentation files (the "Software"), to deal
7** in the Software without restriction, including without limitation the rights
8** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9** copies of the Software, and to permit persons to whom the Software is
10** furnished to do so, subject to the following conditions:
11** The above copyright notice and this permission notice shall be
12** included in all copies or substantial portions of the Software.
13**
14** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20** USE OR OTHER DEALINGS IN THE SOFTWARE.
21****************************************************************************/
22
28#ifndef HBRIDGEDRIVER_H
29#define HBRIDGEDRIVER_H
30
31#ifdef __cplusplus
32extern "C"{
33#endif
34
39#ifdef PREINIT_SUPPORTED
40#include "preinit.h"
41#endif
42
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
45 #include "delays.h"
46 #endif
47#endif
48
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51
72#define HBRIDGEDRIVER_PROP_DIS 0x00
73#define HBRIDGEDRIVER_PROP_EN 0x01
74
75 // hbridgedriver_set
76
91#define HBRIDGEDRIVER_MAP_MIKROBUS( cfg, mikrobus ) \
92 cfg.il2 = MIKROBUS( mikrobus, MIKROBUS_AN ); \
93 cfg.ih2 = MIKROBUS( mikrobus, MIKROBUS_RST ); \
94 cfg.gen = MIKROBUS( mikrobus, MIKROBUS_CS ); \
95 cfg.il1 = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
96 cfg.ih1 = MIKROBUS( mikrobus, MIKROBUS_INT )
97
98 // hbridgedriver_map
99 // hbridgedriver
100
105typedef struct
106{
107 digital_out_t il2;
108 digital_out_t ih2;
109 digital_out_t gen;
110 digital_out_t il1;
111 digital_out_t ih1;
114
119typedef struct
120{
121 pin_name_t il2;
122 pin_name_t ih2;
123 pin_name_t gen;
124 pin_name_t il1;
125 pin_name_t ih1;
128
139
156
171
180void hbridgedriver_glo_enable ( hbridgedriver_t *ctx, uint8_t state );
181
190void hbridgedriver_in_ls_2 ( hbridgedriver_t *ctx, uint8_t state );
191
200void hbridgedriver_in_hs_2 ( hbridgedriver_t *ctx, uint8_t state );
201
210void hbridgedriver_in_ls_1 ( hbridgedriver_t *ctx, uint8_t state );
211
220void hbridgedriver_in_hs_1 ( hbridgedriver_t *ctx, uint8_t state );
221
231
241
251
261
271
281
291
301
311
321
331
341
342#ifdef __cplusplus
343}
344#endif
345#endif // HBRIDGEDRIVER_H
346
347 // hbridgedriver
348
349// ------------------------------------------------------------------------ END
void hbridgedriver_dc_brake_1(hbridgedriver_t *ctx)
Motor Connected to HS/LS 1 Braking function.
err_t hbridgedriver_init(hbridgedriver_t *ctx, hbridgedriver_cfg_t *cfg)
H-Bridge Driver initialization function.
void hbridgedriver_dc_bwd_2(hbridgedriver_t *ctx)
Motor Connected to HS/LS 2 Backward motion function.
void hbridgedriver_in_hs_2(hbridgedriver_t *ctx, uint8_t state)
Input High Side 2 function.
void hbridgedriver_in_ls_2(hbridgedriver_t *ctx, uint8_t state)
Input Low Side 2 function.
void hbridgedriver_coasting(hbridgedriver_t *ctx)
H-Bridge mode coasting function.
void hbridgedriver_in_hs_1(hbridgedriver_t *ctx, uint8_t state)
Input High Side 1 function.
void hbridgedriver_dc_coast_1(hbridgedriver_t *ctx)
Motor Connected to HS/LS 1 Coasting function.
void hbridgedriver_cfg_setup(hbridgedriver_cfg_t *cfg)
H-Bridge Driver configuration object setup function.
void hbridgedriver_braking(hbridgedriver_t *ctx)
H-Bridge mode braking function.
void hbridgedriver_dc_brake_2(hbridgedriver_t *ctx)
Motor Connected to HS/LS 2 Braking function.
void hbridgedriver_dc_fwd_1(hbridgedriver_t *ctx)
Motor Connected to HS/LS 1 Foreward motion function.
void hbridgedriver_reverse(hbridgedriver_t *ctx)
H-Bridge mode reverse function.
void hbridgedriver_dc_bwd_1(hbridgedriver_t *ctx)
Motor Connected to HS/LS 1 Backward motion function.
void hbridgedriver_forward(hbridgedriver_t *ctx)
H-Bridge mode forward function.
void hbridgedriver_dc_coast_2(hbridgedriver_t *ctx)
Motor Connected to HS/LS 2 Coasting function.
void hbridgedriver_glo_enable(hbridgedriver_t *ctx, uint8_t state)
Global enable function.
void hbridgedriver_in_ls_1(hbridgedriver_t *ctx, uint8_t state)
Input Low Side 1 function.
void hbridgedriver_dc_fwd_2(hbridgedriver_t *ctx)
Motor Connected to HS/LS 2 Foreward motion function.
hbridgedriver_return_value_t
H-Bridge Driver Click return value data.
Definition hbridgedriver.h:134
@ HBRIDGEDRIVER_OK
Definition hbridgedriver.h:135
@ HBRIDGEDRIVER_ERROR
Definition hbridgedriver.h:136
H-Bridge Driver Click configuration object.
Definition hbridgedriver.h:120
pin_name_t ih2
Definition hbridgedriver.h:122
pin_name_t ih1
Definition hbridgedriver.h:125
pin_name_t il2
Definition hbridgedriver.h:121
pin_name_t il1
Definition hbridgedriver.h:124
pin_name_t gen
Definition hbridgedriver.h:123
H-Bridge Driver Click context object.
Definition hbridgedriver.h:106
digital_out_t il1
Definition hbridgedriver.h:110
digital_out_t gen
Definition hbridgedriver.h:109
digital_out_t il2
Definition hbridgedriver.h:107
digital_out_t ih1
Definition hbridgedriver.h:111
digital_out_t ih2
Definition hbridgedriver.h:108