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 "drv_digital_out.h"
39 #include "drv_digital_in.h"
40 
41 // -------------------------------------------------------------- PUBLIC MACROS
51 #define HBRIDGE7_MAP_MIKROBUS( cfg, mikrobus ) \
52  cfg.en= MIKROBUS( mikrobus, MIKROBUS_RST ); \
53  cfg.nsl= MIKROBUS( mikrobus, MIKROBUS_CS ); \
54  cfg.ph= MIKROBUS( mikrobus, MIKROBUS_PWM ); \
55  cfg.nft= MIKROBUS( mikrobus, MIKROBUS_INT )
56 
62 #define HBRIDGE7_RETVAL uint8_t
63 
64 #define HBRIDGE7_OK 0x00
65 #define HBRIDGE7_INIT_ERROR 0xFF
66 
72 #define HBRIDGE7_MOTOR_SLEEP 0
73 #define HBRIDGE7_MOTOR_BRAKE 1
74 #define HBRIDGE7_MOTOR_REVERSE 2
75 #define HBRIDGE7_MOTOR_FORWARD 3
76  // End group macro
78 // --------------------------------------------------------------- PUBLIC TYPES
87 typedef struct
88 {
89  // Output pins
90 
91  digital_out_t en;
92  digital_out_t nsl;
93  digital_out_t ph;
94 
95  // Input pins
96 
97  digital_in_t nft;
98 
99 } hbridge7_t;
100 
104 typedef struct
105 {
106  // Additional gpio pins
107 
108  pin_name_t en;
109  pin_name_t nsl;
110  pin_name_t ph;
111  pin_name_t nft;
112 
114  // End types group
116 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
117 
123 #ifdef __cplusplus
124 extern "C"{
125 #endif
126 
136 
146 
155 void hbridge7_motor_control ( hbridge7_t *ctx, uint8_t ctrl );
156 
167 
168 #ifdef __cplusplus
169 }
170 #endif
171 #endif // _HBRIDGE7_H_
172  // End public_function group
175 
176 // ------------------------------------------------------------------------- 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:108
hbridge7_cfg_t::nft
pin_name_t nft
Definition: hbridge7.h:111
hbridge7_t::en
digital_out_t en
Definition: hbridge7.h:91
hbridge7_motor_control
void hbridge7_motor_control(hbridge7_t *ctx, uint8_t ctrl)
Set motor control.
HBRIDGE7_RETVAL
#define HBRIDGE7_RETVAL
Definition: hbridge7.h:62
hbridge7_cfg_t::ph
pin_name_t ph
Definition: hbridge7.h:110
hbridge7_cfg_setup
void hbridge7_cfg_setup(hbridge7_cfg_t *cfg)
Config Object Initialization function.
hbridge7_t
Click ctx object definition.
Definition: hbridge7.h:88
hbridge7_t::ph
digital_out_t ph
Definition: hbridge7.h:93
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:92
hbridge7_cfg_t::nsl
pin_name_t nsl
Definition: hbridge7.h:109
hbridge7_cfg_t
Click configuration structure definition.
Definition: hbridge7.h:105
hbridge7_t::nft
digital_in_t nft
Definition: hbridge7.h:97