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
32 extern "C"{
33 #endif
34 
35 #include "mikrosdk_version.h"
36 
37 #ifdef __GNUC__
38 #if mikroSDK_GET_VERSION < 20800ul
39 #include "rcu_delays.h"
40 #else
41 #include "delays.h"
42 #endif
43 #endif
44 
45 #include "drv_digital_out.h"
46 #include "drv_digital_in.h"
47 
68 #define HBRIDGEDRIVER_PROP_DIS 0x00
69 #define HBRIDGEDRIVER_PROP_EN 0x01
70  // hbridgedriver_set
72 
87 #define HBRIDGEDRIVER_MAP_MIKROBUS( cfg, mikrobus ) \
88  cfg.il2 = MIKROBUS( mikrobus, MIKROBUS_AN ); \
89  cfg.ih2 = MIKROBUS( mikrobus, MIKROBUS_RST ); \
90  cfg.gen = MIKROBUS( mikrobus, MIKROBUS_CS ); \
91  cfg.il1 = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
92  cfg.ih1 = MIKROBUS( mikrobus, MIKROBUS_INT )
93  // hbridgedriver_map // hbridgedriver
96 
101 typedef struct
102 {
103  digital_out_t il2;
104  digital_out_t ih2;
105  digital_out_t gen;
106  digital_out_t il1;
107  digital_out_t ih1;
110 
115 typedef struct
116 {
117  pin_name_t il2;
118  pin_name_t ih2;
119  pin_name_t gen;
120  pin_name_t il1;
121  pin_name_t ih1;
124 
129 typedef enum
130 {
133 
135 
152 
167 
176 void hbridgedriver_glo_enable ( hbridgedriver_t *ctx, uint8_t state );
177 
186 void hbridgedriver_in_ls_2 ( hbridgedriver_t *ctx, uint8_t state );
187 
196 void hbridgedriver_in_hs_2 ( hbridgedriver_t *ctx, uint8_t state );
197 
206 void hbridgedriver_in_ls_1 ( hbridgedriver_t *ctx, uint8_t state );
207 
216 void hbridgedriver_in_hs_1 ( hbridgedriver_t *ctx, uint8_t state );
217 
227 
237 
247 
257 
267 
277 
287 
297 
307 
317 
327 
337 
338 #ifdef __cplusplus
339 }
340 #endif
341 #endif // HBRIDGEDRIVER_H
342  // hbridgedriver
344 
345 // ------------------------------------------------------------------------ END
hbridgedriver_dc_bwd_1
void hbridgedriver_dc_bwd_1(hbridgedriver_t *ctx)
Motor Connected to HS/LS 1 Backward motion function.
hbridgedriver_t::ih2
digital_out_t ih2
Definition: hbridgedriver.h:104
hbridgedriver_dc_coast_2
void hbridgedriver_dc_coast_2(hbridgedriver_t *ctx)
Motor Connected to HS/LS 2 Coasting function.
hbridgedriver_glo_enable
void hbridgedriver_glo_enable(hbridgedriver_t *ctx, uint8_t state)
Global enable function.
hbridgedriver_cfg_t::ih2
pin_name_t ih2
Definition: hbridgedriver.h:118
hbridgedriver_in_ls_1
void hbridgedriver_in_ls_1(hbridgedriver_t *ctx, uint8_t state)
Input Low Side 1 function.
hbridgedriver_in_ls_2
void hbridgedriver_in_ls_2(hbridgedriver_t *ctx, uint8_t state)
Input Low Side 2 function.
hbridgedriver_in_hs_1
void hbridgedriver_in_hs_1(hbridgedriver_t *ctx, uint8_t state)
Input High Side 1 function.
hbridgedriver_t::il2
digital_out_t il2
Definition: hbridgedriver.h:103
hbridgedriver_dc_brake_2
void hbridgedriver_dc_brake_2(hbridgedriver_t *ctx)
Motor Connected to HS/LS 2 Braking function.
hbridgedriver_t::ih1
digital_out_t ih1
Definition: hbridgedriver.h:107
hbridgedriver_forward
void hbridgedriver_forward(hbridgedriver_t *ctx)
H-Bridge mode forward function.
hbridgedriver_t::il1
digital_out_t il1
Definition: hbridgedriver.h:106
hbridgedriver_coasting
void hbridgedriver_coasting(hbridgedriver_t *ctx)
H-Bridge mode coasting function.
hbridgedriver_dc_coast_1
void hbridgedriver_dc_coast_1(hbridgedriver_t *ctx)
Motor Connected to HS/LS 1 Coasting function.
hbridgedriver_cfg_t::il1
pin_name_t il1
Definition: hbridgedriver.h:120
hbridgedriver_cfg_t::il2
pin_name_t il2
Definition: hbridgedriver.h:117
hbridgedriver_return_value_t
hbridgedriver_return_value_t
H-Bridge Driver Click return value data.
Definition: hbridgedriver.h:130
hbridgedriver_cfg_t::ih1
pin_name_t ih1
Definition: hbridgedriver.h:121
hbridgedriver_dc_brake_1
void hbridgedriver_dc_brake_1(hbridgedriver_t *ctx)
Motor Connected to HS/LS 1 Braking function.
hbridgedriver_dc_fwd_1
void hbridgedriver_dc_fwd_1(hbridgedriver_t *ctx)
Motor Connected to HS/LS 1 Foreward motion function.
hbridgedriver_cfg_t::gen
pin_name_t gen
Definition: hbridgedriver.h:119
HBRIDGEDRIVER_ERROR
@ HBRIDGEDRIVER_ERROR
Definition: hbridgedriver.h:132
hbridgedriver_in_hs_2
void hbridgedriver_in_hs_2(hbridgedriver_t *ctx, uint8_t state)
Input High Side 2 function.
hbridgedriver_t
H-Bridge Driver Click context object.
Definition: hbridgedriver.h:102
hbridgedriver_reverse
void hbridgedriver_reverse(hbridgedriver_t *ctx)
H-Bridge mode reverse function.
hbridgedriver_cfg_t
H-Bridge Driver Click configuration object.
Definition: hbridgedriver.h:116
hbridgedriver_dc_bwd_2
void hbridgedriver_dc_bwd_2(hbridgedriver_t *ctx)
Motor Connected to HS/LS 2 Backward motion function.
hbridgedriver_braking
void hbridgedriver_braking(hbridgedriver_t *ctx)
H-Bridge mode braking function.
hbridgedriver_t::gen
digital_out_t gen
Definition: hbridgedriver.h:105
HBRIDGEDRIVER_OK
@ HBRIDGEDRIVER_OK
Definition: hbridgedriver.h:131
hbridgedriver_dc_fwd_2
void hbridgedriver_dc_fwd_2(hbridgedriver_t *ctx)
Motor Connected to HS/LS 2 Foreward motion function.
hbridgedriver_cfg_setup
void hbridgedriver_cfg_setup(hbridgedriver_cfg_t *cfg)
H-Bridge Driver configuration object setup function.
hbridgedriver_init
err_t hbridgedriver_init(hbridgedriver_t *ctx, hbridgedriver_cfg_t *cfg)
H-Bridge Driver initialization function.