hbridge8  2.0.0.0
hbridge8.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 HBRIDGE8_H
29 #define HBRIDGE8_H
30 
31 #ifdef __cplusplus
32 extern "C"{
33 #endif
34 
35 #include "drv_digital_out.h"
36 #include "drv_digital_in.h"
37 #include "drv_pwm.h"
38 
55 #define HBRIDGE8_MODE_REVERSE 0
56 #define HBRIDGE8_MODE_FORWARD 1
57  // mode
59 
74 #define HBRIDGE8_DEF_FREQ 225000
75  // hbridge8_cfg
77 
92 #define HBRIDGE8_MAP_MIKROBUS( cfg, mikrobus ) \
93  cfg.pwm = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
94  cfg.en = MIKROBUS( mikrobus, MIKROBUS_RST ); \
95  cfg.mod = MIKROBUS( mikrobus, MIKROBUS_CS ); \
96  cfg.flt = MIKROBUS( mikrobus, MIKROBUS_INT )
97  // hbridge8_map // hbridge8
100 
110 typedef struct
111 {
112  // Output pins
113  digital_out_t en;
114  digital_out_t mod;
116  // Input pins
117  digital_in_t flt;
119  // Modules
120  pwm_t pwm;
122  // ctx variable
123  uint32_t pwm_freq;
125 } hbridge8_t;
126 
131 typedef struct
132 {
133  // Communication gpio pins
134  pin_name_t pwm;
136  // Additional gpio pins
137  pin_name_t en;
138  pin_name_t mod;
139  pin_name_t flt;
141  // Static variable
142  uint32_t dev_pwm_freq;
145 
150 typedef enum
151 {
153  HBRIDGE8_ERROR = -1
154 
156 
172 void hbridge8_cfg_setup ( hbridge8_cfg_t *cfg );
173 
188 err_t hbridge8_init ( hbridge8_t *ctx, hbridge8_cfg_t *cfg );
189 
203 err_t hbridge8_default_cfg ( hbridge8_t *ctx );
204 
217 err_t hbridge8_set_duty_cycle ( hbridge8_t *ctx, float duty_cycle );
218 
230 err_t hbridge8_pwm_stop ( hbridge8_t *ctx );
231 
243 err_t hbridge8_pwm_start ( hbridge8_t *ctx );
244 
260 err_t hbridge8_set_mode ( hbridge8_t *ctx, uint8_t mode );
261 
274 err_t hbridge8_enable ( hbridge8_t *ctx );
275 
288 err_t hbridge8_disable ( hbridge8_t *ctx );
289 
303 
304 #ifdef __cplusplus
305 }
306 #endif
307 #endif // HBRIDGE8_H
308  // hbridge8
310 
311 // ------------------------------------------------------------------------ END
hbridge8_set_mode
err_t hbridge8_set_mode(hbridge8_t *ctx, uint8_t mode)
H-Bridge 8 set operating mode function.
hbridge8_pwm_stop
err_t hbridge8_pwm_stop(hbridge8_t *ctx)
H-Bridge 8 stop PWM module.
mode
uint8_t mode
Definition: main.c:32
hbridge8_disable
err_t hbridge8_disable(hbridge8_t *ctx)
H-Bridge 8 set IC disable function.
hbridge8_t
H-Bridge 8 Click driver selector.
Definition: hbridge8.h:109
HBRIDGE8_OK
Definition: hbridge8.h:151
hbridge8_default_cfg
err_t hbridge8_default_cfg(hbridge8_t *ctx)
H-Bridge 8 default configuration function.
HBRIDGE8_ERROR
Definition: hbridge8.h:152
hbridge8_set_duty_cycle
err_t hbridge8_set_duty_cycle(hbridge8_t *ctx, float duty_cycle)
H-Bridge 8 sets PWM duty cycle.
hbridge8_cfg_t
H-Bridge 8 Click configuration object.
Definition: hbridge8.h:130
hbridge8_cfg_setup
void hbridge8_cfg_setup(hbridge8_cfg_t *cfg)
H-Bridge 8 configuration object setup function.
hbridge8_get_fault_indication
uint8_t hbridge8_get_fault_indication(hbridge8_t *ctx)
H-Bridge 8 get fault indication function.
hbridge8_enable
err_t hbridge8_enable(hbridge8_t *ctx)
H-Bridge 8 set IC enable function.
hbridge8_init
err_t hbridge8_init(hbridge8_t *ctx, hbridge8_cfg_t *cfg)
H-Bridge 8 initialization function.
hbridge8_return_value_t
hbridge8_return_value_t
H-Bridge 8 Click return value data.
Definition: hbridge8.h:149
hbridge8_pwm_start
err_t hbridge8_pwm_start(hbridge8_t *ctx)
H-Bridge 8 start PWM module.