dcmotor20  2.0.0.0
dcmotor20.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 DCMOTOR20_H
29 #define DCMOTOR20_H
30 
31 #ifdef __cplusplus
32 extern "C"{
33 #endif
34 
35 #include "drv_digital_out.h"
36 #include "drv_digital_in.h"
37 #include "drv_pwm.h"
38 
59 #define DCMOTOR20_CHANNEL_1 0x01
60 #define DCMOTOR20_CHANNEL_2 0x02
61 
66 #define DCMOTOR20_MODE_STOP 0x00
67 #define DCMOTOR20_MODE_FORWARD 0x01
68 #define DCMOTOR20_MODE_REVERSE 0x02
69 
74 #define DCMOTOR20_SPEED_MAX 100
75 #define DCMOTOR20_SPEED_DEFAULT 10
76 #define DCMOTOR20_SPEED_MIN 1
77 #define DCMOTOR20_MS_TIME_STEP 10
78  // dcmotor20_set
80 
95 #define DCMOTOR20_MAP_MIKROBUS( cfg, mikrobus ) \
96  cfg.in1 = MIKROBUS( mikrobus, MIKROBUS_AN ); \
97  cfg.in2 = MIKROBUS( mikrobus, MIKROBUS_RST ); \
98  cfg.in3 = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
99  cfg.in4 = MIKROBUS( mikrobus, MIKROBUS_INT )
100  // dcmotor20_map // dcmotor20
103 
108 typedef struct
109 {
110  digital_out_t in1;
111  digital_out_t in2;
112  digital_out_t in3;
113  digital_out_t in4;
115  uint8_t active_ch;
116  uint8_t mode;
118 } dcmotor20_t;
119 
124 typedef struct
125 {
126  pin_name_t in1;
127  pin_name_t in2;
128  pin_name_t in3;
129  pin_name_t in4;
132 
137 typedef enum
138 {
140  DCMOTOR20_ERROR = -1
141 
143 
160 
176 
192 err_t dcmotor20_drive_motor ( dcmotor20_t *ctx, uint8_t speed, uint32_t time_ms );
193 
208 err_t dcmotor20_set_channel_mode ( dcmotor20_t *ctx, uint8_t channel, uint8_t mode );
209 
219 
220 #ifdef __cplusplus
221 }
222 #endif
223 #endif // DCMOTOR20_H
224  // dcmotor20
226 
227 // ------------------------------------------------------------------------ END
dcmotor20_t::active_ch
uint8_t active_ch
Definition: dcmotor20.h:115
dcmotor20_cfg_t::in4
pin_name_t in4
Definition: dcmotor20.h:129
dcmotor20_return_value_t
dcmotor20_return_value_t
DC Motor 20 Click return value data.
Definition: dcmotor20.h:138
dcmotor20_t::in2
digital_out_t in2
Definition: dcmotor20.h:111
dcmotor20_drive_motor
err_t dcmotor20_drive_motor(dcmotor20_t *ctx, uint8_t speed, uint32_t time_ms)
DC Motor 20 drive motor function.
dcmotor20_t::in1
digital_out_t in1
Definition: dcmotor20.h:110
dcmotor20_cfg_t::in2
pin_name_t in2
Definition: dcmotor20.h:127
dcmotor20_t
DC Motor 20 Click context object.
Definition: dcmotor20.h:109
dcmotor20_init
err_t dcmotor20_init(dcmotor20_t *ctx, dcmotor20_cfg_t *cfg)
DC Motor 20 initialization function.
DCMOTOR20_ERROR
@ DCMOTOR20_ERROR
Definition: dcmotor20.h:140
dcmotor20_t::in4
digital_out_t in4
Definition: dcmotor20.h:113
DCMOTOR20_OK
@ DCMOTOR20_OK
Definition: dcmotor20.h:139
dcmotor20_set_channel_mode
err_t dcmotor20_set_channel_mode(dcmotor20_t *ctx, uint8_t channel, uint8_t mode)
DC Motor 20 set channel mode function.
dcmotor20_cfg_t::in1
pin_name_t in1
Definition: dcmotor20.h:126
dcmotor20_cfg_t::in3
pin_name_t in3
Definition: dcmotor20.h:128
dcmotor20_set_standby_mode
void dcmotor20_set_standby_mode(dcmotor20_t *ctx)
DC Motor 20 set standby mode function.
dcmotor20_t::mode
uint8_t mode
Definition: dcmotor20.h:116
dcmotor20_t::in3
digital_out_t in3
Definition: dcmotor20.h:112
dcmotor20_cfg_t
DC Motor 20 Click configuration object.
Definition: dcmotor20.h:125
dcmotor20_cfg_setup
void dcmotor20_cfg_setup(dcmotor20_cfg_t *cfg)
DC Motor 20 configuration object setup function.