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 "drv_digital_out.h"
36 #include "drv_digital_in.h"
37 
58 #define HBRIDGEDRIVER_PROP_DIS 0x00
59 #define HBRIDGEDRIVER_PROP_EN 0x01
60  // hbridgedriver_set
62 
77 #define HBRIDGEDRIVER_MAP_MIKROBUS( cfg, mikrobus ) \
78  cfg.il2 = MIKROBUS( mikrobus, MIKROBUS_AN ); \
79  cfg.ih2 = MIKROBUS( mikrobus, MIKROBUS_RST ); \
80  cfg.gen = MIKROBUS( mikrobus, MIKROBUS_CS ); \
81  cfg.il1 = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
82  cfg.ih1 = MIKROBUS( mikrobus, MIKROBUS_INT )
83  // hbridgedriver_map // hbridgedriver
86 
91 typedef struct
92 {
93  digital_out_t il2;
94  digital_out_t ih2;
95  digital_out_t gen;
96  digital_out_t il1;
97  digital_out_t ih1;
100 
105 typedef struct
106 {
107  pin_name_t il2;
108  pin_name_t ih2;
109  pin_name_t gen;
110  pin_name_t il1;
111  pin_name_t ih1;
114 
119 typedef enum
120 {
123 
125 
142 
157 
166 void hbridgedriver_glo_enable ( hbridgedriver_t *ctx, uint8_t state );
167 
176 void hbridgedriver_in_ls_2 ( hbridgedriver_t *ctx, uint8_t state );
177 
186 void hbridgedriver_in_hs_2 ( hbridgedriver_t *ctx, uint8_t state );
187 
196 void hbridgedriver_in_ls_1 ( hbridgedriver_t *ctx, uint8_t state );
197 
206 void hbridgedriver_in_hs_1 ( hbridgedriver_t *ctx, uint8_t state );
207 
217 
227 
237 
247 
257 
267 
277 
287 
297 
307 
317 
327 
328 #ifdef __cplusplus
329 }
330 #endif
331 #endif // HBRIDGEDRIVER_H
332  // hbridgedriver
334 
335 // ------------------------------------------------------------------------ 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:94
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:108
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:93
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:97
hbridgedriver_forward
void hbridgedriver_forward(hbridgedriver_t *ctx)
H-Bridge mode forward function.
hbridgedriver_t::il1
digital_out_t il1
Definition: hbridgedriver.h:96
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:110
hbridgedriver_cfg_t::il2
pin_name_t il2
Definition: hbridgedriver.h:107
hbridgedriver_return_value_t
hbridgedriver_return_value_t
H-Bridge Driver Click return value data.
Definition: hbridgedriver.h:120
hbridgedriver_cfg_t::ih1
pin_name_t ih1
Definition: hbridgedriver.h:111
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:109
HBRIDGEDRIVER_ERROR
@ HBRIDGEDRIVER_ERROR
Definition: hbridgedriver.h:122
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:92
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:106
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:95
HBRIDGEDRIVER_OK
@ HBRIDGEDRIVER_OK
Definition: hbridgedriver.h:121
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.