hbridge7  2.0.0.0
hbridge7.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 HBRIDGE7_H
36 #define HBRIDGE7_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 HBRIDGE7_MAP_MIKROBUS( cfg, mikrobus ) \
66  cfg.en= MIKROBUS( mikrobus, MIKROBUS_RST ); \
67  cfg.nsl= MIKROBUS( mikrobus, MIKROBUS_CS ); \
68  cfg.ph= MIKROBUS( mikrobus, MIKROBUS_PWM ); \
69  cfg.nft= MIKROBUS( mikrobus, MIKROBUS_INT )
70 
76 #define HBRIDGE7_RETVAL uint8_t
77 
78 #define HBRIDGE7_OK 0x00
79 #define HBRIDGE7_INIT_ERROR 0xFF
80 
86 #define HBRIDGE7_MOTOR_SLEEP 0
87 #define HBRIDGE7_MOTOR_BRAKE 1
88 #define HBRIDGE7_MOTOR_REVERSE 2
89 #define HBRIDGE7_MOTOR_FORWARD 3
90  // End group macro
92 // --------------------------------------------------------------- PUBLIC TYPES
101 typedef struct
102 {
103  // Output pins
104 
105  digital_out_t en;
106  digital_out_t nsl;
107  digital_out_t ph;
108 
109  // Input pins
110 
111  digital_in_t nft;
112 
113 } hbridge7_t;
114 
118 typedef struct
119 {
120  // Additional gpio pins
121 
122  pin_name_t en;
123  pin_name_t nsl;
124  pin_name_t ph;
125  pin_name_t nft;
126 
128  // End types group
130 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
131 
137 #ifdef __cplusplus
138 extern "C"{
139 #endif
140 
150 
160 
169 void hbridge7_motor_control ( hbridge7_t *ctx, uint8_t ctrl );
170 
181 
182 #ifdef __cplusplus
183 }
184 #endif
185 #endif // _HBRIDGE7_H_
186  // End public_function group
189 
190 // ------------------------------------------------------------------------- END
hbridge7_get_fault_state
uint8_t hbridge7_get_fault_state(hbridge7_t *ctx)
Get Fault pin state.
hbridge7_cfg_t::en
pin_name_t en
Definition: hbridge7.h:122
hbridge7_cfg_t::nft
pin_name_t nft
Definition: hbridge7.h:125
hbridge7_t::en
digital_out_t en
Definition: hbridge7.h:105
hbridge7_motor_control
void hbridge7_motor_control(hbridge7_t *ctx, uint8_t ctrl)
Set motor control.
HBRIDGE7_RETVAL
#define HBRIDGE7_RETVAL
Definition: hbridge7.h:76
hbridge7_cfg_t::ph
pin_name_t ph
Definition: hbridge7.h:124
hbridge7_cfg_setup
void hbridge7_cfg_setup(hbridge7_cfg_t *cfg)
Config Object Initialization function.
hbridge7_t
Click ctx object definition.
Definition: hbridge7.h:102
hbridge7_t::ph
digital_out_t ph
Definition: hbridge7.h:107
hbridge7_init
HBRIDGE7_RETVAL hbridge7_init(hbridge7_t *ctx, hbridge7_cfg_t *cfg)
Initialization function.
hbridge7_t::nsl
digital_out_t nsl
Definition: hbridge7.h:106
hbridge7_cfg_t::nsl
pin_name_t nsl
Definition: hbridge7.h:123
hbridge7_cfg_t
Click configuration structure definition.
Definition: hbridge7.h:119
hbridge7_t::nft
digital_in_t nft
Definition: hbridge7.h:111