dcmotor14  2.0.0.0
dcmotor14.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 DCMOTOR14_H
36 #define DCMOTOR14_H
37 
38 #include "drv_digital_out.h"
39 #include "drv_digital_in.h"
40 
41 // -------------------------------------------------------------- PUBLIC MACROS
51 #define DCMOTOR14_MAP_MIKROBUS( cfg, mikrobus ) \
52  cfg.in1= MIKROBUS( mikrobus, MIKROBUS_AN ); \
53  cfg.in2= MIKROBUS( mikrobus, MIKROBUS_RST )
54 
61 #define DCMOTOR14_RETVAL uint8_t
62 
63 #define DCMOTOR14_OK 0x00
64 #define DCMOTOR14_INIT_ERROR 0xFF
65 
71 #define DCMOTOR14_HIGH 1
72 #define DCMOTOR14_LOW 0
73  // End group macro
76 // --------------------------------------------------------------- PUBLIC TYPES
85 typedef struct
86 {
87  // Output pins
88 
89  digital_out_t in1;
90  digital_out_t in2;
91 
92 } dcmotor14_t;
93 
97 typedef struct
98 {
99  // Additional gpio pins
100 
101  pin_name_t in1;
102  pin_name_t in2;
103 
105  // End types group
107 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
108 
114 #ifdef __cplusplus
115 extern "C"{
116 #endif
117 
127 
136 
145 void dcmotor14_set_an_state ( dcmotor14_t *ctx, uint8_t state );
146 
155 void dcmotor14_set_rst_state ( dcmotor14_t *ctx, uint8_t state );
156 
164 void dcmotor14_stop ( dcmotor14_t *ctx );
165 
173 void dcmotor14_forward ( dcmotor14_t *ctx );
174 
182 void dcmotor14_reverse ( dcmotor14_t *ctx );
183 
191 void dcmotor14_brake ( dcmotor14_t *ctx );
192 
193 #ifdef __cplusplus
194 }
195 #endif
196 #endif // _DCMOTOR14_H_
197  // End public_function group
200 
201 // ------------------------------------------------------------------------- END
dcmotor14_cfg_t::in1
pin_name_t in1
Definition: dcmotor14.h:101
dcmotor14_cfg_t
Click configuration structure definition.
Definition: dcmotor14.h:97
dcmotor14_t
Click ctx object definition.
Definition: dcmotor14.h:85
dcmotor14_forward
void dcmotor14_forward(dcmotor14_t *ctx)
Forward function.
dcmotor14_cfg_t::in2
pin_name_t in2
Definition: dcmotor14.h:102
dcmotor14_set_rst_state
void dcmotor14_set_rst_state(dcmotor14_t *ctx, uint8_t state)
Set rst pin state function.
dcmotor14_reverse
void dcmotor14_reverse(dcmotor14_t *ctx)
Reverse function.
dcmotor14_init
DCMOTOR14_RETVAL dcmotor14_init(dcmotor14_t *ctx, dcmotor14_cfg_t *cfg)
Initialization function.
dcmotor14_set_an_state
void dcmotor14_set_an_state(dcmotor14_t *ctx, uint8_t state)
Set an pin state function.
dcmotor14_brake
void dcmotor14_brake(dcmotor14_t *ctx)
Brake function.
dcmotor14_cfg_setup
void dcmotor14_cfg_setup(dcmotor14_cfg_t *cfg)
Config Object Initialization function.
dcmotor14_t::in1
digital_out_t in1
Definition: dcmotor14.h:89
dcmotor14_t::in2
digital_out_t in2
Definition: dcmotor14.h:90
dcmotor14_stop
void dcmotor14_stop(dcmotor14_t *ctx)
Stop function.
DCMOTOR14_RETVAL
#define DCMOTOR14_RETVAL
Definition: dcmotor14.h:61