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 
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 HBRIDGE7_MAP_MIKROBUS( cfg, mikrobus ) \
62  cfg.en= MIKROBUS( mikrobus, MIKROBUS_RST ); \
63  cfg.nsl= MIKROBUS( mikrobus, MIKROBUS_CS ); \
64  cfg.ph= MIKROBUS( mikrobus, MIKROBUS_PWM ); \
65  cfg.nft= MIKROBUS( mikrobus, MIKROBUS_INT )
66 
72 #define HBRIDGE7_RETVAL uint8_t
73 
74 #define HBRIDGE7_OK 0x00
75 #define HBRIDGE7_INIT_ERROR 0xFF
76 
82 #define HBRIDGE7_MOTOR_SLEEP 0
83 #define HBRIDGE7_MOTOR_BRAKE 1
84 #define HBRIDGE7_MOTOR_REVERSE 2
85 #define HBRIDGE7_MOTOR_FORWARD 3
86  // End group macro
88 // --------------------------------------------------------------- PUBLIC TYPES
97 typedef struct
98 {
99  // Output pins
100 
101  digital_out_t en;
102  digital_out_t nsl;
103  digital_out_t ph;
104 
105  // Input pins
106 
107  digital_in_t nft;
108 
109 } hbridge7_t;
110 
114 typedef struct
115 {
116  // Additional gpio pins
117 
118  pin_name_t en;
119  pin_name_t nsl;
120  pin_name_t ph;
121  pin_name_t nft;
122 
124  // End types group
126 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
127 
133 #ifdef __cplusplus
134 extern "C"{
135 #endif
136 
146 
156 
165 void hbridge7_motor_control ( hbridge7_t *ctx, uint8_t ctrl );
166 
177 
178 #ifdef __cplusplus
179 }
180 #endif
181 #endif // _HBRIDGE7_H_
182  // End public_function group
185 
186 // ------------------------------------------------------------------------- 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:118
hbridge7_cfg_t::nft
pin_name_t nft
Definition: hbridge7.h:121
hbridge7_t::en
digital_out_t en
Definition: hbridge7.h:101
hbridge7_motor_control
void hbridge7_motor_control(hbridge7_t *ctx, uint8_t ctrl)
Set motor control.
HBRIDGE7_RETVAL
#define HBRIDGE7_RETVAL
Definition: hbridge7.h:72
hbridge7_cfg_t::ph
pin_name_t ph
Definition: hbridge7.h:120
hbridge7_cfg_setup
void hbridge7_cfg_setup(hbridge7_cfg_t *cfg)
Config Object Initialization function.
hbridge7_t
Click ctx object definition.
Definition: hbridge7.h:98
hbridge7_t::ph
digital_out_t ph
Definition: hbridge7.h:103
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:102
hbridge7_cfg_t::nsl
pin_name_t nsl
Definition: hbridge7.h:119
hbridge7_cfg_t
Click configuration structure definition.
Definition: hbridge7.h:115
hbridge7_t::nft
digital_in_t nft
Definition: hbridge7.h:107