dcmotor5 2.0.0.0
dcmotor5.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 DCMOTOR5_H
29#define DCMOTOR5_H
30
31#ifdef __cplusplus
32extern "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#include "drv_pwm.h"
52
73#define DCMOTOR5_DEF_FREQ 20000
74
75 // dcmotor5_cfg
76
91#define DCMOTOR5_MAP_MIKROBUS( cfg, mikrobus ) \
92 cfg.pwm = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
93 cfg.snso = MIKROBUS( mikrobus, MIKROBUS_AN ); \
94 cfg.sleep = MIKROBUS( mikrobus, MIKROBUS_RST ); \
95 cfg.fault = MIKROBUS( mikrobus, MIKROBUS_CS ); \
96 cfg.in2 = MIKROBUS( mikrobus, MIKROBUS_INT );
97
98 // dcmotor5_map
99 // dcmotor5
100
105typedef struct
106{
107 // Output pins
108 digital_out_t sleep;
109 digital_out_t in2;
111 // Input pins
112 digital_in_t snso;
113 digital_in_t fault;
115 // Modules
116 pwm_t pwm;
118 // ctx variable
119 uint32_t pwm_freq;
121} dcmotor5_t;
122
127typedef struct
128{
129 // Communication gpio pins
130 pin_name_t pwm;
132 // Additional gpio pins
133 pin_name_t snso;
134 pin_name_t sleep;
135 pin_name_t fault;
136 pin_name_t in2;
138 // Static variable
139 uint32_t dev_pwm_freq;
142
147typedef enum
148{
150 DCMOTOR5_ERROR = -1
151
153
170
182
196
205void dcmotor5_set_duty_cycle ( dcmotor5_t *ctx, float duty_cycle );
206
215
224
233
243
253
263
272
281
290
300
301
302#ifdef __cplusplus
303}
304#endif
305#endif // DCMOTOR5_H
306
307 // dcmotor5
308
309// ------------------------------------------------------------------------ END
dcmotor5_return_value_t
DC Motor 5 Click return value data.
Definition dcmotor5.h:148
@ DCMOTOR5_ERROR
Definition dcmotor5.h:150
@ DCMOTOR5_OK
Definition dcmotor5.h:149
void dcmotor5_short_brake(dcmotor5_t *ctx)
DC Motor 5 brake the engine function.
void dcmotor5_default_cfg(dcmotor5_t *ctx)
DC Motor 5 default configuration function.
void dcmotor5_pwm_stop(dcmotor5_t *ctx)
DC Motor 5 stop PWM module.
void dcmotor5_enable(dcmotor5_t *ctx)
DC Motor 5 start PWM module.
void dcmotor5_clockwise(dcmotor5_t *ctx)
DC Motor 5 Set the direction of rotation in the clockwise direction function.
void dcmotor5_stop(dcmotor5_t *ctx)
DC Motor 5 stop the engine function.
uint8_t dcmotor5_get_fault_conditions(dcmotor5_t *ctx)
DC Motor 5 get fault conditions state function.
uint8_t dcmotor5_get_sense_comparator(dcmotor5_t *ctx)
DC Motor 5 get sense comparator.
void dcmotor5_counter_clockwise(dcmotor5_t *ctx)
DC Motor 5 Set the direction of rotation in the counter clockwise direction function.
void dcmotor5_set_duty_cycle(dcmotor5_t *ctx, float duty_cycle)
DC Motor 5 sets PWM duty cycle.
void dcmotor5_pwm_start(dcmotor5_t *ctx)
DC Motor 5 start PWM module.
err_t dcmotor5_init(dcmotor5_t *ctx, dcmotor5_cfg_t *cfg)
DC Motor 5 initialization function.
void dcmotor5_cfg_setup(dcmotor5_cfg_t *cfg)
DC Motor 5 configuration object setup function.
void dcmotor5_standby(dcmotor5_t *ctx)
DC Motor 5 Disable the engine function.
DC Motor 5 Click configuration object.
Definition dcmotor5.h:128
pin_name_t sleep
Definition dcmotor5.h:134
pin_name_t in2
Definition dcmotor5.h:136
pin_name_t snso
Definition dcmotor5.h:133
uint32_t dev_pwm_freq
Definition dcmotor5.h:139
pin_name_t pwm
Definition dcmotor5.h:130
pin_name_t fault
Definition dcmotor5.h:135
DC Motor 5 Click context object.
Definition dcmotor5.h:106
digital_out_t sleep
Definition dcmotor5.h:108
digital_out_t in2
Definition dcmotor5.h:109
digital_in_t snso
Definition dcmotor5.h:112
uint32_t pwm_freq
Definition dcmotor5.h:119
digital_in_t fault
Definition dcmotor5.h:113
pwm_t pwm
Definition dcmotor5.h:116