dcmotor17  2.0.0.0
dcmotor17.h
Go to the documentation of this file.
1 /****************************************************************************
2 ** Copyright (C) 2020 MikroElektronika d.o.o.
3 ** Contact: https://www.mikroe.com/contact
4 **
5 ** Permission is hereby granted, free of charge, to any person obtaining a copy
6 ** of this software and associated documentation files (the "Software"), to deal
7 ** in the Software without restriction, including without limitation the rights
8 ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 ** copies of the Software, and to permit persons to whom the Software is
10 ** furnished to do so, subject to the following conditions:
11 ** The above copyright notice and this permission notice shall be
12 ** included in all copies or substantial portions of the Software.
13 **
14 ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16 ** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18 ** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19 ** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 ** USE OR OTHER DEALINGS IN THE SOFTWARE.
21 ****************************************************************************/
22 
28 #ifndef DCMOTOR17_H
29 #define DCMOTOR17_H
30 
31 #ifdef __cplusplus
32 extern "C"{
33 #endif
34 
39 #ifdef PREINIT_SUPPORTED
40 #include "preinit.h"
41 #endif
42 
43 #ifdef MikroCCoreVersion
44  #if MikroCCoreVersion >= 1
45  #include "delays.h"
46  #endif
47 #endif
48 
49 #include "drv_digital_out.h"
50 
71 #define dcmotor17_retval_t uint8_t
72 
73 #define DCMOTOR17_OK 0x00
74 #define DCMOTOR17_ERROR 0xFF
75  // retval_flag
77 
87 #define DCMOTOR17_SEL_OUT_A 0
88 #define DCMOTOR17_SEL_OUT_B 1
89  // sel_out
91 
101 #define DCMOTOR17_SEL_MODE_STANDBY 0
102 #define DCMOTOR17_SEL_MODE_NORMAL 1
103  // mode
105 
120 #define DCMOTOR17_MAP_MIKROBUS( cfg, mikrobus ) \
121  cfg.i1a = MIKROBUS( mikrobus, MIKROBUS_AN ); \
122  cfg.i2a = MIKROBUS( mikrobus, MIKROBUS_RST ); \
123  cfg.stby = MIKROBUS( mikrobus, MIKROBUS_CS ); \
124  cfg.i1b = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
125  cfg.i2b = MIKROBUS( mikrobus, MIKROBUS_INT )
126  // dcmotor17_map // dcmotor17
129 
134 typedef struct
135 {
136  digital_out_t i1a;
137  digital_out_t i2a;
138  digital_out_t stby;
139  digital_out_t i1b;
140  digital_out_t i2b;
141 } dcmotor17_t;
142 
147 typedef struct
148 {
149  pin_name_t i1a;
150  pin_name_t i2a;
151  pin_name_t stby;
152  pin_name_t i1b;
153  pin_name_t i2b;
156 
173 
189 
202 
213 
224 
239 
254 
269 
281 
282 #ifdef __cplusplus
283 }
284 #endif
285 #endif // DCMOTOR17_H
286  // dcmotor17
288 
289 // ------------------------------------------------------------------------ END
dcmotor17_cfg_t::stby
pin_name_t stby
Definition: dcmotor17.h:151
dcmotor17_set_mode
dcmotor17_retval_t dcmotor17_set_mode(dcmotor17_t *ctx, uint8_t op_mode)
DC Motor 17 set operating mode function.
dcmotor17_cfg_t
DC Motor 17 Click configuration object.
Definition: dcmotor17.h:148
dcmotor17_standby_mode
void dcmotor17_standby_mode(dcmotor17_t *ctx)
DC Motor 17 set to standby operating mode function.
dcmotor17_normal_mode
void dcmotor17_normal_mode(dcmotor17_t *ctx)
DC Motor 17 set to normal operating mode function.
dcmotor17_stop
dcmotor17_retval_t dcmotor17_stop(dcmotor17_t *ctx, uint8_t sel_out)
DC Motor 17 stop motor function.
dcmotor17_forward
dcmotor17_retval_t dcmotor17_forward(dcmotor17_t *ctx, uint8_t sel_out)
DC Motor 17 forward function.
dcmotor17_cfg_t::i1b
pin_name_t i1b
Definition: dcmotor17.h:152
dcmotor17_t::i1a
digital_out_t i1a
Definition: dcmotor17.h:136
dcmotor17_reverse
dcmotor17_retval_t dcmotor17_reverse(dcmotor17_t *ctx, uint8_t sel_out)
DC Motor 17 reverse function.
dcmotor17_default_cfg
void dcmotor17_default_cfg(dcmotor17_t *ctx)
DC Motor 17 default configuration function.
dcmotor17_t::i1b
digital_out_t i1b
Definition: dcmotor17.h:139
dcmotor17_retval_t
#define dcmotor17_retval_t
DC Motor 17 error code settings.
Definition: dcmotor17.h:71
dcmotor17_cfg_t::i2a
pin_name_t i2a
Definition: dcmotor17.h:150
dcmotor17_t::i2b
digital_out_t i2b
Definition: dcmotor17.h:140
dcmotor17_t::stby
digital_out_t stby
Definition: dcmotor17.h:138
dcmotor17_cfg_setup
void dcmotor17_cfg_setup(dcmotor17_cfg_t *cfg)
DC Motor 17 configuration object setup function.
dcmotor17_cfg_t::i1a
pin_name_t i1a
Definition: dcmotor17.h:149
dcmotor17_init
err_t dcmotor17_init(dcmotor17_t *ctx, dcmotor17_cfg_t *cfg)
DC Motor 17 initialization function.
dcmotor17_t
DC Motor 17 Click context object.
Definition: dcmotor17.h:135
dcmotor17_cfg_t::i2b
pin_name_t i2b
Definition: dcmotor17.h:153
dcmotor17_t::i2a
digital_out_t i2a
Definition: dcmotor17.h:137