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 
38 #include "mikrosdk_version.h"
39 
40 #ifdef __GNUC__
41 #if mikroSDK_GET_VERSION < 20800ul
42 #include "rcu_delays.h"
43 #else
44 #include "delays.h"
45 #endif
46 #endif
47 
48 #include "drv_digital_out.h"
49 #include "drv_digital_in.h"
50 
51 // -------------------------------------------------------------- PUBLIC MACROS
61 #define HBRIDGE4_MAP_MIKROBUS( cfg, mikrobus ) \
62  cfg.in1 = MIKROBUS( mikrobus, MIKROBUS_AN ); \
63  cfg.in2 = MIKROBUS( mikrobus, MIKROBUS_RST ); \
64  cfg.en = MIKROBUS( mikrobus, MIKROBUS_CS ); \
65  cfg.in4 = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
66  cfg.in3 = MIKROBUS( mikrobus, MIKROBUS_INT );
67 
73 #define HBRIDGE4_RETVAL uint8_t
74 
75 #define HBRIDGE4_OK 0x00
76 #define HBRIDGE4_INIT_ERROR 0xFF
77  // End group macro
80 // --------------------------------------------------------------- PUBLIC TYPES
89 typedef struct
90 {
91  // Output pins
92 
93  digital_out_t in1;
94  digital_out_t in2;
95  digital_out_t en;
96  digital_out_t in4;
97  digital_out_t in3;
98 
99 } hbridge4_t;
100 
104 typedef struct
105 {
106  // Additional gpio pins
107 
108  pin_name_t in1;
109  pin_name_t in2;
110  pin_name_t en;
111  pin_name_t in4;
112  pin_name_t in3;
113 
115  // End types group
117 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
118 
124 #ifdef __cplusplus
125 extern "C"{
126 #endif
127 
137 
146 
155 void hbridge4_enable ( hbridge4_t *ctx, uint8_t state );
156 
165 void hbridge4_set_in1 ( hbridge4_t *ctx, uint8_t state );
166 
175 void hbridge4_set_in2 ( hbridge4_t *ctx, uint8_t state );
176 
185 void hbridge4_set_in3 ( hbridge4_t *ctx, uint8_t state );
186 
195 void hbridge4_set_in4 ( hbridge4_t *ctx, uint8_t state );
196 
203 
212 
221 
230 
239 
248 
257 
266 
267 #ifdef __cplusplus
268 }
269 #endif
270 #endif // _HBRIDGE4_H_
271  // End public_function group
274 
275 // ------------------------------------------------------------------------- END
hbridge4_set_in1
void hbridge4_set_in1(hbridge4_t *ctx, uint8_t state)
Set IN1 function.
hbridge4_cfg_t::en
pin_name_t en
Definition: hbridge4.h:110
hbridge4_cfg_t::in3
pin_name_t in3
Definition: hbridge4.h:112
hbridge4_motor_b_brake
void hbridge4_motor_b_brake(hbridge4_t *ctx)
Motor B Brake function.
hbridge4_motor_a_brake
void hbridge4_motor_a_brake(hbridge4_t *ctx)
Motor A Brake function.
hbridge4_t::in2
digital_out_t in2
Definition: hbridge4.h:94
hbridge4_t::in1
digital_out_t in1
Definition: hbridge4.h:93
hbridge4_motor_a_standby
void hbridge4_motor_a_standby(hbridge4_t *ctx)
Motor A standby function.
hbridge4_motor_acw
void hbridge4_motor_acw(hbridge4_t *ctx)
Motor A clockwise motion function.
hbridge4_cfg_setup
void hbridge4_cfg_setup(hbridge4_cfg_t *cfg)
Config Object Initialization function.
hbridge4_motor_bcw
void hbridge4_motor_bcw(hbridge4_t *ctx)
Motor B clockwise motion function.
hbridge4_set_in4
void hbridge4_set_in4(hbridge4_t *ctx, uint8_t state)
Set IN4 function.
hbridge4_set_in3
void hbridge4_set_in3(hbridge4_t *ctx, uint8_t state)
Set IN3 function.
hbridge4_cfg_t::in1
pin_name_t in1
Definition: hbridge4.h:108
hbridge4_motor_accw
void hbridge4_motor_accw(hbridge4_t *ctx)
Motor A counter-clockwise motion function.
hbridge4_t
Click ctx object definition.
Definition: hbridge4.h:90
hbridge4_t::in4
digital_out_t in4
Definition: hbridge4.h:96
hbridge4_t::in3
digital_out_t in3
Definition: hbridge4.h:97
hbridge4_motor_b_standby
void hbridge4_motor_b_standby(hbridge4_t *ctx)
Motor B standby function.
hbridge4_cfg_t::in4
pin_name_t in4
Definition: hbridge4.h:111
hbridge4_set_in2
void hbridge4_set_in2(hbridge4_t *ctx, uint8_t state)
Set IN2 function.
hbridge4_cfg_t
Click configuration structure definition.
Definition: hbridge4.h:105
hbridge4_enable
void hbridge4_enable(hbridge4_t *ctx, uint8_t state)
Enable the device function.
hbridge4_motor_bccw
void hbridge4_motor_bccw(hbridge4_t *ctx)
Motor B counter-clockwise motion function.
hbridge4_init
HBRIDGE4_RETVAL hbridge4_init(hbridge4_t *ctx, hbridge4_cfg_t *cfg)
Initialization function.
hbridge4_t::en
digital_out_t en
Definition: hbridge4.h:95
HBRIDGE4_RETVAL
#define HBRIDGE4_RETVAL
Definition: hbridge4.h:73
hbridge4_cfg_t::in2
pin_name_t in2
Definition: hbridge4.h:109