hbridge4 2.0.0.0
hbridge4.h
Go to the documentation of this file.
1/*
2 * MikroSDK - MikroE Software Development Kit
3 * Copyright© 2020 MikroElektronika d.o.o.
4 *
5 * Permission is hereby granted, free of charge, to any person
6 * obtaining a copy of this software and associated documentation
7 * files (the "Software"), to deal in the Software without restriction,
8 * including without limitation the rights to use, copy, modify, merge,
9 * publish, distribute, sublicense, and/or sell copies of the Software,
10 * and to permit persons to whom the Software is furnished to do so,
11 * subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
22 * OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
33// ----------------------------------------------------------------------------
34
35#ifndef HBRIDGE4_H
36#define HBRIDGE4_H
37
42#ifdef PREINIT_SUPPORTED
43#include "preinit.h"
44#endif
45
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
48 #include "delays.h"
49 #endif
50#endif
51
52#include "drv_digital_out.h"
53#include "drv_digital_in.h"
54
55// -------------------------------------------------------------- PUBLIC MACROS
65#define HBRIDGE4_MAP_MIKROBUS( cfg, mikrobus ) \
66 cfg.in1 = MIKROBUS( mikrobus, MIKROBUS_AN ); \
67 cfg.in2 = MIKROBUS( mikrobus, MIKROBUS_RST ); \
68 cfg.en = MIKROBUS( mikrobus, MIKROBUS_CS ); \
69 cfg.in4 = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
70 cfg.in3 = MIKROBUS( mikrobus, MIKROBUS_INT );
77#define HBRIDGE4_RETVAL uint8_t
78
79#define HBRIDGE4_OK 0x00
80#define HBRIDGE4_INIT_ERROR 0xFF
83 // End group macro
84// --------------------------------------------------------------- PUBLIC TYPES
93typedef struct
94{
95 // Output pins
96
97 digital_out_t in1;
98 digital_out_t in2;
99 digital_out_t en;
100 digital_out_t in4;
101 digital_out_t in3;
102
103} hbridge4_t;
104
108typedef struct
109{
110 // Additional gpio pins
111
112 pin_name_t in1;
113 pin_name_t in2;
114 pin_name_t en;
115 pin_name_t in4;
116 pin_name_t in3;
117
119
120 // End types group
121// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
122
128#ifdef __cplusplus
129extern "C"{
130#endif
131
141
150
159void hbridge4_enable ( hbridge4_t *ctx, uint8_t state );
160
169void hbridge4_set_in1 ( hbridge4_t *ctx, uint8_t state );
170
179void hbridge4_set_in2 ( hbridge4_t *ctx, uint8_t state );
180
189void hbridge4_set_in3 ( hbridge4_t *ctx, uint8_t state );
190
199void hbridge4_set_in4 ( hbridge4_t *ctx, uint8_t state );
200
207
216
225
234
243
252
261
270
271#ifdef __cplusplus
272}
273#endif
274#endif // _HBRIDGE4_H_
275
276 // End public_function group
278
279// ------------------------------------------------------------------------- END
#define HBRIDGE4_RETVAL
Definition hbridge4.h:77
HBRIDGE4_RETVAL hbridge4_init(hbridge4_t *ctx, hbridge4_cfg_t *cfg)
Initialization function.
void hbridge4_set_in2(hbridge4_t *ctx, uint8_t state)
Set IN2 function.
void hbridge4_motor_b_standby(hbridge4_t *ctx)
Motor B standby function.
void hbridge4_motor_bcw(hbridge4_t *ctx)
Motor B clockwise motion function.
void hbridge4_motor_b_brake(hbridge4_t *ctx)
Motor B Brake function.
void hbridge4_cfg_setup(hbridge4_cfg_t *cfg)
Config Object Initialization function.
void hbridge4_set_in3(hbridge4_t *ctx, uint8_t state)
Set IN3 function.
void hbridge4_motor_bccw(hbridge4_t *ctx)
Motor B counter-clockwise motion function.
void hbridge4_set_in4(hbridge4_t *ctx, uint8_t state)
Set IN4 function.
void hbridge4_motor_a_standby(hbridge4_t *ctx)
Motor A standby function.
void hbridge4_enable(hbridge4_t *ctx, uint8_t state)
Enable the device function.
void hbridge4_motor_acw(hbridge4_t *ctx)
Motor A clockwise motion function.
void hbridge4_set_in1(hbridge4_t *ctx, uint8_t state)
Set IN1 function.
void hbridge4_motor_accw(hbridge4_t *ctx)
Motor A counter-clockwise motion function.
void hbridge4_motor_a_brake(hbridge4_t *ctx)
Motor A Brake function.
Click configuration structure definition.
Definition hbridge4.h:109
pin_name_t in2
Definition hbridge4.h:113
pin_name_t en
Definition hbridge4.h:114
pin_name_t in1
Definition hbridge4.h:112
pin_name_t in4
Definition hbridge4.h:115
pin_name_t in3
Definition hbridge4.h:116
Click ctx object definition.
Definition hbridge4.h:94
digital_out_t in2
Definition hbridge4.h:98
digital_out_t in3
Definition hbridge4.h:101
digital_out_t in4
Definition hbridge4.h:100
digital_out_t en
Definition hbridge4.h:99
digital_out_t in1
Definition hbridge4.h:97