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 "drv_digital_out.h"
39 #include "drv_digital_in.h"
40 
41 // -------------------------------------------------------------- PUBLIC MACROS
51 #define HBRIDGE4_MAP_MIKROBUS( cfg, mikrobus ) \
52  cfg.in1 = MIKROBUS( mikrobus, MIKROBUS_AN ); \
53  cfg.in2 = MIKROBUS( mikrobus, MIKROBUS_RST ); \
54  cfg.en = MIKROBUS( mikrobus, MIKROBUS_CS ); \
55  cfg.in4 = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
56  cfg.in3 = MIKROBUS( mikrobus, MIKROBUS_INT );
57 
63 #define HBRIDGE4_RETVAL uint8_t
64 
65 #define HBRIDGE4_OK 0x00
66 #define HBRIDGE4_INIT_ERROR 0xFF
67  // End group macro
70 // --------------------------------------------------------------- PUBLIC TYPES
79 typedef struct
80 {
81  // Output pins
82 
83  digital_out_t in1;
84  digital_out_t in2;
85  digital_out_t en;
86  digital_out_t in4;
87  digital_out_t in3;
88 
89 } hbridge4_t;
90 
94 typedef struct
95 {
96  // Additional gpio pins
97 
98  pin_name_t in1;
99  pin_name_t in2;
100  pin_name_t en;
101  pin_name_t in4;
102  pin_name_t in3;
103 
105  // End types group
107 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
108 
114 #ifdef __cplusplus
115 extern "C"{
116 #endif
117 
126 void hbridge4_cfg_setup ( hbridge4_cfg_t *cfg );
127 
136 
145 void hbridge4_enable ( hbridge4_t *ctx, uint8_t state );
146 
155 void hbridge4_set_in1 ( hbridge4_t *ctx, uint8_t state );
156 
165 void hbridge4_set_in2 ( hbridge4_t *ctx, uint8_t state );
166 
175 void hbridge4_set_in3 ( hbridge4_t *ctx, uint8_t state );
176 
185 void hbridge4_set_in4 ( hbridge4_t *ctx, uint8_t state );
186 
193 
201 void hbridge4_motor_acw ( hbridge4_t *ctx );
202 
210 void hbridge4_motor_accw ( hbridge4_t *ctx );
211 
219 void hbridge4_motor_a_brake ( hbridge4_t *ctx );
220 
229 
237 void hbridge4_motor_bcw ( hbridge4_t *ctx );
238 
246 void hbridge4_motor_bccw ( hbridge4_t *ctx );
247 
255 void hbridge4_motor_b_brake ( hbridge4_t *ctx );
256 
257 #ifdef __cplusplus
258 }
259 #endif
260 #endif // _HBRIDGE4_H_
261  // End public_function group
264 
265 // ------------------------------------------------------------------------- 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:100
hbridge4_cfg_t::in3
pin_name_t in3
Definition: hbridge4.h:102
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:84
hbridge4_t::in1
digital_out_t in1
Definition: hbridge4.h:83
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:98
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:79
hbridge4_t::in4
digital_out_t in4
Definition: hbridge4.h:86
hbridge4_t::in3
digital_out_t in3
Definition: hbridge4.h:87
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:101
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:94
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:85
HBRIDGE4_RETVAL
#define HBRIDGE4_RETVAL
Definition: hbridge4.h:63
hbridge4_cfg_t::in2
pin_name_t in2
Definition: hbridge4.h:99