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 )
76#define HBRIDGE7_RETVAL uint8_t
77
78#define HBRIDGE7_OK 0x00
79#define HBRIDGE7_INIT_ERROR 0xFF
86#define HBRIDGE7_MOTOR_SLEEP 0
87#define HBRIDGE7_MOTOR_BRAKE 1
88#define HBRIDGE7_MOTOR_REVERSE 2
89#define HBRIDGE7_MOTOR_FORWARD 3
91 // End group macro
92// --------------------------------------------------------------- PUBLIC TYPES
101typedef 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
118typedef 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
129 // End types group
130// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
131
137#ifdef __cplusplus
138extern "C"{
139#endif
140
150
160
169void hbridge7_motor_control ( hbridge7_t *ctx, uint8_t ctrl );
170
181
182#ifdef __cplusplus
183}
184#endif
185#endif // _HBRIDGE7_H_
186
187 // End public_function group
189
190// ------------------------------------------------------------------------- END
#define HBRIDGE7_RETVAL
Definition hbridge7.h:76
void hbridge7_cfg_setup(hbridge7_cfg_t *cfg)
Config Object Initialization function.
uint8_t hbridge7_get_fault_state(hbridge7_t *ctx)
Get Fault pin state.
HBRIDGE7_RETVAL hbridge7_init(hbridge7_t *ctx, hbridge7_cfg_t *cfg)
Initialization function.
void hbridge7_motor_control(hbridge7_t *ctx, uint8_t ctrl)
Set motor control.
Click configuration structure definition.
Definition hbridge7.h:119
pin_name_t nft
Definition hbridge7.h:125
pin_name_t ph
Definition hbridge7.h:124
pin_name_t nsl
Definition hbridge7.h:123
pin_name_t en
Definition hbridge7.h:122
Click ctx object definition.
Definition hbridge7.h:102
digital_out_t nsl
Definition hbridge7.h:106
digital_out_t en
Definition hbridge7.h:105
digital_out_t ph
Definition hbridge7.h:107
digital_in_t nft
Definition hbridge7.h:111