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 "drv_digital_out.h"
36 #include "drv_digital_in.h"
37 #include "drv_pwm.h"
38 
59 #define DCMOTOR5_DEF_FREQ 20000
60  // dcmotor5_cfg
62 
77 #define DCMOTOR5_MAP_MIKROBUS( cfg, mikrobus ) \
78  cfg.pwm = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
79  cfg.snso = MIKROBUS( mikrobus, MIKROBUS_AN ); \
80  cfg.sleep = MIKROBUS( mikrobus, MIKROBUS_RST ); \
81  cfg.fault = MIKROBUS( mikrobus, MIKROBUS_CS ); \
82  cfg.in2 = MIKROBUS( mikrobus, MIKROBUS_INT );
83  // dcmotor5_map // dcmotor5
86 
91 typedef struct
92 {
93  // Output pins
94  digital_out_t sleep;
95  digital_out_t in2;
97  // Input pins
98  digital_in_t snso;
99  digital_in_t fault;
101  // Modules
102  pwm_t pwm;
104  // ctx variable
105  uint32_t pwm_freq;
107 } dcmotor5_t;
108 
113 typedef struct
114 {
115  // Communication gpio pins
116  pin_name_t pwm;
118  // Additional gpio pins
119  pin_name_t snso;
120  pin_name_t sleep;
121  pin_name_t fault;
122  pin_name_t in2;
124  // Static variable
125  uint32_t dev_pwm_freq;
128 
133 typedef enum
134 {
136  DCMOTOR5_ERROR = -1
137 
139 
156 
168 
182 
191 void dcmotor5_set_duty_cycle ( dcmotor5_t *ctx, float duty_cycle );
192 
201 
210 
219 
229 
239 
249 
258 
266 void dcmotor5_stop ( dcmotor5_t *ctx );
267 
276 
286 
287 
288 #ifdef __cplusplus
289 }
290 #endif
291 #endif // DCMOTOR5_H
292  // dcmotor5
294 
295 // ------------------------------------------------------------------------ END
dcmotor5_t::fault
digital_in_t fault
Definition: dcmotor5.h:99
dcmotor5_cfg_t::snso
pin_name_t snso
Definition: dcmotor5.h:119
DCMOTOR5_OK
@ DCMOTOR5_OK
Definition: dcmotor5.h:135
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:120
dcmotor5_t::pwm_freq
uint32_t pwm_freq
Definition: dcmotor5.h:105
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:125
dcmotor5_cfg_t::fault
pin_name_t fault
Definition: dcmotor5.h:121
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:98
dcmotor5_return_value_t
dcmotor5_return_value_t
DC Motor 5 Click return value data.
Definition: dcmotor5.h:134
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:92
dcmotor5_t::sleep
digital_out_t sleep
Definition: dcmotor5.h:94
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:114
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:102
dcmotor5_enable
void dcmotor5_enable(dcmotor5_t *ctx)
DC Motor 5 start PWM module.
dcmotor5_t::in2
digital_out_t in2
Definition: dcmotor5.h:95
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:116
dcmotor5_cfg_t::in2
pin_name_t in2
Definition: dcmotor5.h:122
DCMOTOR5_ERROR
@ DCMOTOR5_ERROR
Definition: dcmotor5.h:136