dcmotor21  2.0.0.0
dcmotor21.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 DCMOTOR21_H
29 #define DCMOTOR21_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 #include "drv_digital_in.h"
51 
72 #define DCMOTOR21_OUT_LOW 0x00
73 #define DCMOTOR21_OUT_HIGH 0x01
74 #define DCMOTOR21_OUT_HIGH_Z 0x02
75  // dcmotor21_set
77 
92 #define DCMOTOR21_MAP_MIKROBUS( cfg, mikrobus ) \
93  cfg.hn1 = MIKROBUS( mikrobus, MIKROBUS_AN ); \
94  cfg.ln1 = MIKROBUS( mikrobus, MIKROBUS_CS ); \
95  cfg.hn2 = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
96  cfg.ln2 = MIKROBUS( mikrobus, MIKROBUS_INT )
97  // dcmotor21_map // dcmotor21
100 
105 typedef struct
106 {
107  digital_out_t hn1;
108  digital_out_t ln1;
109  digital_out_t hn2;
110  digital_out_t ln2;
112 } dcmotor21_t;
113 
118 typedef struct
119 {
120  pin_name_t hn1;
121  pin_name_t ln1;
122  pin_name_t hn2;
123  pin_name_t ln2;
126 
131 typedef enum
132 {
134  DCMOTOR21_ERROR = -1
135 
137 
154 
170 
182 
194 void dcmotor21_set_out_1 ( dcmotor21_t *ctx, uint8_t state );
195 
207 void dcmotor21_set_out_2 ( dcmotor21_t *ctx, uint8_t state );
208 
209 #ifdef __cplusplus
210 }
211 #endif
212 #endif // DCMOTOR21_H
213  // dcmotor21
215 
216 // ------------------------------------------------------------------------ END
dcmotor21_t::ln1
digital_out_t ln1
Definition: dcmotor21.h:108
dcmotor21_cfg_t::hn2
pin_name_t hn2
Definition: dcmotor21.h:122
dcmotor21_set_out_1
void dcmotor21_set_out_1(dcmotor21_t *ctx, uint8_t state)
DC Motor 21 set out 1 function.
dcmotor21_t::hn2
digital_out_t hn2
Definition: dcmotor21.h:109
dcmotor21_default_cfg
void dcmotor21_default_cfg(dcmotor21_t *ctx)
DC Motor 21 default configuration function.
dcmotor21_t
DC Motor 21 Click context object.
Definition: dcmotor21.h:106
dcmotor21_init
err_t dcmotor21_init(dcmotor21_t *ctx, dcmotor21_cfg_t *cfg)
DC Motor 21 initialization function.
DCMOTOR21_OK
@ DCMOTOR21_OK
Definition: dcmotor21.h:133
dcmotor21_cfg_t::ln2
pin_name_t ln2
Definition: dcmotor21.h:123
dcmotor21_return_value_t
dcmotor21_return_value_t
DC Motor 21 Click return value data.
Definition: dcmotor21.h:132
dcmotor21_cfg_t::ln1
pin_name_t ln1
Definition: dcmotor21.h:121
dcmotor21_set_out_2
void dcmotor21_set_out_2(dcmotor21_t *ctx, uint8_t state)
DC Motor 21 set out 2 function.
dcmotor21_cfg_t::hn1
pin_name_t hn1
Definition: dcmotor21.h:120
dcmotor21_t::ln2
digital_out_t ln2
Definition: dcmotor21.h:110
DCMOTOR21_ERROR
@ DCMOTOR21_ERROR
Definition: dcmotor21.h:134
dcmotor21_cfg_t
DC Motor 21 Click configuration object.
Definition: dcmotor21.h:119
dcmotor21_t::hn1
digital_out_t hn1
Definition: dcmotor21.h:107
dcmotor21_cfg_setup
void dcmotor21_cfg_setup(dcmotor21_cfg_t *cfg)
DC Motor 21 configuration object setup function.