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
32extern "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
110typedef 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
131typedef 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
150typedef enum
151{
153 HBRIDGE8_ERROR = -1
154
156
173
189
204
217err_t hbridge8_set_duty_cycle ( hbridge8_t *ctx, float duty_cycle );
218
231
244
260err_t hbridge8_set_mode ( hbridge8_t *ctx, uint8_t mode );
261
275
289
303
304#ifdef __cplusplus
305}
306#endif
307#endif // HBRIDGE8_H
308 // hbridge8
310
311// ------------------------------------------------------------------------ END
void hbridge8_cfg_setup(hbridge8_cfg_t *cfg)
H-Bridge 8 configuration object setup function.
err_t hbridge8_set_mode(hbridge8_t *ctx, uint8_t mode)
H-Bridge 8 set operating mode function.
err_t hbridge8_init(hbridge8_t *ctx, hbridge8_cfg_t *cfg)
H-Bridge 8 initialization function.
uint8_t hbridge8_get_fault_indication(hbridge8_t *ctx)
H-Bridge 8 get fault indication function.
err_t hbridge8_pwm_start(hbridge8_t *ctx)
H-Bridge 8 start PWM module.
err_t hbridge8_pwm_stop(hbridge8_t *ctx)
H-Bridge 8 stop PWM module.
err_t hbridge8_disable(hbridge8_t *ctx)
H-Bridge 8 set IC disable function.
err_t hbridge8_enable(hbridge8_t *ctx)
H-Bridge 8 set IC enable function.
err_t hbridge8_set_duty_cycle(hbridge8_t *ctx, float duty_cycle)
H-Bridge 8 sets PWM duty cycle.
err_t hbridge8_default_cfg(hbridge8_t *ctx)
H-Bridge 8 default configuration function.
hbridge8_return_value_t
H-Bridge 8 Click return value data.
Definition: hbridge8.h:151
@ HBRIDGE8_OK
Definition: hbridge8.h:152
@ HBRIDGE8_ERROR
Definition: hbridge8.h:153
uint8_t mode
Definition: main.c:32
H-Bridge 8 Click configuration object.
Definition: hbridge8.h:132
pin_name_t mod
Definition: hbridge8.h:138
uint32_t dev_pwm_freq
Definition: hbridge8.h:142
pin_name_t flt
Definition: hbridge8.h:139
pin_name_t en
Definition: hbridge8.h:137
pin_name_t pwm
Definition: hbridge8.h:134
H-Bridge 8 Click driver selector.
Definition: hbridge8.h:111
digital_out_t mod
Definition: hbridge8.h:114
digital_in_t flt
Definition: hbridge8.h:117
uint32_t pwm_freq
Definition: hbridge8.h:123
digital_out_t en
Definition: hbridge8.h:113
pwm_t pwm
Definition: hbridge8.h:120