hbridge2  2.0.0.0
hbridge2.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 HBRIDGE2_H
36 #define HBRIDGE2_H
37 
38 #include "drv_digital_out.h"
39 #include "drv_digital_in.h"
40 
41 // -------------------------------------------------------------- PUBLIC MACROS
51 #define HBRIDGE2_MAP_MIKROBUS( cfg, mikrobus ) \
52  cfg.gin= MIKROBUS( mikrobus, MIKROBUS_AN ); \
53  cfg.dir= MIKROBUS( mikrobus, MIKROBUS_RST ); \
54  cfg.end= MIKROBUS( mikrobus, MIKROBUS_CS ); \
55  cfg.pwm= MIKROBUS( mikrobus, MIKROBUS_PWM )
56 
62 #define HBRIDGE2_RETVAL uint8_t
63 
64 #define HBRIDGE2_OK 0x00
65 #define HBRIDGE2_INIT_ERROR 0xFF
66 
72 #define HBRIDGE2_OUT1_H_OUT2_H 0x00
73 #define HBRIDGE2_OUT1_H_OUT2_L 0x01
74 #define HBRIDGE2_OUT1_L_OUT2_H 0x02
75 #define HBRIDGE2_OUT1_Z_OUT2_Z 0x03
76 
77 #define HBRIDGE2_DISABLE 0x00
78 #define HBRIDGE2_ENABLE 0x01
79 
80 #define HBRIDGE2_GOUT_HIGH 0x00
81 #define HBRIDGE2_GOUT_LOW 0x01
82  // End group macro
85 // --------------------------------------------------------------- PUBLIC TYPES
94 typedef struct
95 {
96  // Output pins
97 
98  digital_out_t gin;
99  digital_out_t dir;
100  digital_out_t end;
101  digital_out_t pwm;
102 
103  // Input pins
104 
105 } hbridge2_t;
106 
110 typedef struct
111 {
112  // Additional gpio pins
113 
114  pin_name_t gin;
115  pin_name_t dir;
116  pin_name_t end;
117  pin_name_t pwm;
118 
120  // End types group
122 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
123 
129 #ifdef __cplusplus
130 extern "C"{
131 #endif
132 
141 void hbridge2_cfg_setup ( hbridge2_cfg_t *cfg );
142 
151 
164 uint8_t hbridge2_set_output ( hbridge2_t *ctx, uint8_t out_state );
165 
176 void hbridge2_enable ( hbridge2_t *ctx, uint8_t state );
177 
186 void hbridge2_set_gout ( hbridge2_t *ctx, uint8_t state );
187 
188 #ifdef __cplusplus
189 }
190 #endif
191 #endif // _HBRIDGE2_H_
192  // End public_function group
195 
196 // ------------------------------------------------------------------------- END
HBRIDGE2_RETVAL
#define HBRIDGE2_RETVAL
Definition: hbridge2.h:62
hbridge2_cfg_t::gin
pin_name_t gin
Definition: hbridge2.h:114
hbridge2_cfg_t::dir
pin_name_t dir
Definition: hbridge2.h:115
hbridge2_t::gin
digital_out_t gin
Definition: hbridge2.h:98
hbridge2_enable
void hbridge2_enable(hbridge2_t *ctx, uint8_t state)
Enable function.
hbridge2_cfg_t::pwm
pin_name_t pwm
Definition: hbridge2.h:117
hbridge2_init
HBRIDGE2_RETVAL hbridge2_init(hbridge2_t *ctx, hbridge2_cfg_t *cfg)
Initialization function.
hbridge2_t::end
digital_out_t end
Definition: hbridge2.h:100
hbridge2_set_output
uint8_t hbridge2_set_output(hbridge2_t *ctx, uint8_t out_state)
Output Set function.
hbridge2_cfg_setup
void hbridge2_cfg_setup(hbridge2_cfg_t *cfg)
Config Object Initialization function.
hbridge2_cfg_t::end
pin_name_t end
Definition: hbridge2.h:116
hbridge2_t
Click ctx object definition.
Definition: hbridge2.h:94
hbridge2_cfg_t
Click configuration structure definition.
Definition: hbridge2.h:110
hbridge2_set_gout
void hbridge2_set_gout(hbridge2_t *ctx, uint8_t state)
GOUT Set function.
hbridge2_t::pwm
digital_out_t pwm
Definition: hbridge2.h:101
hbridge2_t::dir
digital_out_t dir
Definition: hbridge2.h:99