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
32 extern "C"{
33 #endif
34 
35 #include "mikrosdk_version.h"
36 
37 #ifdef __GNUC__
38 #if mikroSDK_GET_VERSION < 20800ul
39 #include "rcu_delays.h"
40 #else
41 #include "delays.h"
42 #endif
43 #endif
44 
45 #include "drv_digital_out.h"
46 #include "drv_digital_in.h"
47 #include "drv_pwm.h"
48 
69 #define DCMOTOR5_DEF_FREQ 20000
70  // dcmotor5_cfg
72 
87 #define DCMOTOR5_MAP_MIKROBUS( cfg, mikrobus ) \
88  cfg.pwm = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
89  cfg.snso = MIKROBUS( mikrobus, MIKROBUS_AN ); \
90  cfg.sleep = MIKROBUS( mikrobus, MIKROBUS_RST ); \
91  cfg.fault = MIKROBUS( mikrobus, MIKROBUS_CS ); \
92  cfg.in2 = MIKROBUS( mikrobus, MIKROBUS_INT );
93  // dcmotor5_map // dcmotor5
96 
101 typedef struct
102 {
103  // Output pins
104  digital_out_t sleep;
105  digital_out_t in2;
107  // Input pins
108  digital_in_t snso;
109  digital_in_t fault;
111  // Modules
112  pwm_t pwm;
114  // ctx variable
115  uint32_t pwm_freq;
117 } dcmotor5_t;
118 
123 typedef struct
124 {
125  // Communication gpio pins
126  pin_name_t pwm;
128  // Additional gpio pins
129  pin_name_t snso;
130  pin_name_t sleep;
131  pin_name_t fault;
132  pin_name_t in2;
134  // Static variable
135  uint32_t dev_pwm_freq;
138 
143 typedef enum
144 {
146  DCMOTOR5_ERROR = -1
147 
149 
166 
178 
192 
201 void dcmotor5_set_duty_cycle ( dcmotor5_t *ctx, float duty_cycle );
202 
211 
220 
229 
239 
249 
259 
268 
276 void dcmotor5_stop ( dcmotor5_t *ctx );
277 
286 
296 
297 
298 #ifdef __cplusplus
299 }
300 #endif
301 #endif // DCMOTOR5_H
302  // dcmotor5
304 
305 // ------------------------------------------------------------------------ END
dcmotor5_t::fault
digital_in_t fault
Definition: dcmotor5.h:109
dcmotor5_cfg_t::snso
pin_name_t snso
Definition: dcmotor5.h:129
DCMOTOR5_OK
@ DCMOTOR5_OK
Definition: dcmotor5.h:145
dcmotor5_standby
void dcmotor5_standby(dcmotor5_t *ctx)
DC Motor 5 Disable the engine function.
dcmotor5_cfg_t::sleep
pin_name_t sleep
Definition: dcmotor5.h:130
dcmotor5_t::pwm_freq
uint32_t pwm_freq
Definition: dcmotor5.h:115
dcmotor5_pwm_start
void dcmotor5_pwm_start(dcmotor5_t *ctx)
DC Motor 5 start PWM module.
dcmotor5_get_fault_conditions
uint8_t dcmotor5_get_fault_conditions(dcmotor5_t *ctx)
DC Motor 5 get fault conditions state function.
dcmotor5_cfg_t::dev_pwm_freq
uint32_t dev_pwm_freq
Definition: dcmotor5.h:135
dcmotor5_cfg_t::fault
pin_name_t fault
Definition: dcmotor5.h:131
dcmotor5_init
err_t dcmotor5_init(dcmotor5_t *ctx, dcmotor5_cfg_t *cfg)
DC Motor 5 initialization function.
dcmotor5_default_cfg
void dcmotor5_default_cfg(dcmotor5_t *ctx)
DC Motor 5 default configuration function.
dcmotor5_clockwise
void dcmotor5_clockwise(dcmotor5_t *ctx)
DC Motor 5 Set the direction of rotation in the clockwise direction function.
dcmotor5_set_duty_cycle
void dcmotor5_set_duty_cycle(dcmotor5_t *ctx, float duty_cycle)
DC Motor 5 sets PWM duty cycle.
dcmotor5_t::snso
digital_in_t snso
Definition: dcmotor5.h:108
dcmotor5_return_value_t
dcmotor5_return_value_t
DC Motor 5 Click return value data.
Definition: dcmotor5.h:144
dcmotor5_short_brake
void dcmotor5_short_brake(dcmotor5_t *ctx)
DC Motor 5 brake the engine function.
dcmotor5_t
DC Motor 5 Click context object.
Definition: dcmotor5.h:102
dcmotor5_t::sleep
digital_out_t sleep
Definition: dcmotor5.h:104
dcmotor5_stop
void dcmotor5_stop(dcmotor5_t *ctx)
DC Motor 5 stop the engine function.
dcmotor5_cfg_setup
void dcmotor5_cfg_setup(dcmotor5_cfg_t *cfg)
DC Motor 5 configuration object setup function.
dcmotor5_counter_clockwise
void dcmotor5_counter_clockwise(dcmotor5_t *ctx)
DC Motor 5 Set the direction of rotation in the counter clockwise direction function.
dcmotor5_cfg_t
DC Motor 5 Click configuration object.
Definition: dcmotor5.h:124
dcmotor5_pwm_stop
void dcmotor5_pwm_stop(dcmotor5_t *ctx)
DC Motor 5 stop PWM module.
dcmotor5_t::pwm
pwm_t pwm
Definition: dcmotor5.h:112
dcmotor5_enable
void dcmotor5_enable(dcmotor5_t *ctx)
DC Motor 5 start PWM module.
dcmotor5_t::in2
digital_out_t in2
Definition: dcmotor5.h:105
dcmotor5_get_sense_comparator
uint8_t dcmotor5_get_sense_comparator(dcmotor5_t *ctx)
DC Motor 5 get sense comparator.
dcmotor5_cfg_t::pwm
pin_name_t pwm
Definition: dcmotor5.h:126
dcmotor5_cfg_t::in2
pin_name_t in2
Definition: dcmotor5.h:132
DCMOTOR5_ERROR
@ DCMOTOR5_ERROR
Definition: dcmotor5.h:146