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 );
71 
77 #define HBRIDGE4_RETVAL uint8_t
78 
79 #define HBRIDGE4_OK 0x00
80 #define HBRIDGE4_INIT_ERROR 0xFF
81  // End group macro
84 // --------------------------------------------------------------- PUBLIC TYPES
93 typedef 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 
108 typedef 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  // End types group
121 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
122 
128 #ifdef __cplusplus
129 extern "C"{
130 #endif
131 
141 
150 
159 void hbridge4_enable ( hbridge4_t *ctx, uint8_t state );
160 
169 void hbridge4_set_in1 ( hbridge4_t *ctx, uint8_t state );
170 
179 void hbridge4_set_in2 ( hbridge4_t *ctx, uint8_t state );
180 
189 void hbridge4_set_in3 ( hbridge4_t *ctx, uint8_t state );
190 
199 void 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  // End public_function group
278 
279 // ------------------------------------------------------------------------- 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:114
hbridge4_cfg_t::in3
pin_name_t in3
Definition: hbridge4.h:116
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:98
hbridge4_t::in1
digital_out_t in1
Definition: hbridge4.h:97
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:112
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:94
hbridge4_t::in4
digital_out_t in4
Definition: hbridge4.h:100
hbridge4_t::in3
digital_out_t in3
Definition: hbridge4.h:101
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:115
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:109
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:99
HBRIDGE4_RETVAL
#define HBRIDGE4_RETVAL
Definition: hbridge4.h:77
hbridge4_cfg_t::in2
pin_name_t in2
Definition: hbridge4.h:113