brushless17 2.0.0.0
brushless17.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 BRUSHLESS17_H
29#define BRUSHLESS17_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 BRUSHLESS17_DIR_CCW 0
74#define BRUSHLESS17_DIR_CW 1
75
80#define BRUSHLESS17_DEF_FREQ 5000
81
82 // brushless17_cfg
83
98#define BRUSHLESS17_MAP_MIKROBUS( cfg, mikrobus ) \
99 cfg.pwm = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
100 cfg.brk = MIKROBUS( mikrobus, MIKROBUS_AN ); \
101 cfg.dir = MIKROBUS( mikrobus, MIKROBUS_RST ); \
102 cfg.en = MIKROBUS( mikrobus, MIKROBUS_CS ); \
103 cfg.diag = MIKROBUS( mikrobus, MIKROBUS_INT );
104
105 // brushless17_map
106 // brushless17
107
117typedef struct
118{
119 // Output pins
120 digital_out_t brk;
121 digital_out_t dir;
122 digital_out_t en;
124 // Input pins
125 digital_in_t diag;
127 // Modules
128 pwm_t pwm;
130 // ctx variable
131 uint32_t pwm_freq;
134
139typedef struct
140{
141 // Communication gpio pins
142 pin_name_t pwm;
144 // Additional gpio pins
145 pin_name_t brk;
146 pin_name_t dir;
147 pin_name_t en;
148 pin_name_t diag;
150 // Static variable
151 uint32_t dev_pwm_freq;
154
165
182
198
213
226err_t brushless17_set_duty_cycle ( brushless17_t *ctx, float duty_cycle );
227
240
253
263
273
284void brushless17_set_direction ( brushless17_t *ctx, uint8_t dir );
285
295
305
315
326
327#ifdef __cplusplus
328}
329#endif
330#endif // BRUSHLESS17_H
331
332 // brushless17
333
334// ------------------------------------------------------------------------ END
brushless17_return_value_t
Brushless 17 Click return value data.
Definition brushless17.h:160
@ BRUSHLESS17_ERROR
Definition brushless17.h:162
@ BRUSHLESS17_OK
Definition brushless17.h:161
void brushless17_pull_brake(brushless17_t *ctx)
Brushless 17 pull brake function.
err_t brushless17_pwm_stop(brushless17_t *ctx)
Brushless 17 stop PWM module.
err_t brushless17_default_cfg(brushless17_t *ctx)
Brushless 17 default configuration function.
err_t brushless17_pwm_start(brushless17_t *ctx)
Brushless 17 start PWM module.
err_t brushless17_init(brushless17_t *ctx, brushless17_cfg_t *cfg)
Brushless 17 initialization function.
void brushless17_switch_direction(brushless17_t *ctx)
Brushless 17 switch direction function.
void brushless17_disable_chip(brushless17_t *ctx)
Brushless 17 disable chip function.
void brushless17_enable_chip(brushless17_t *ctx)
Brushless 17 enable chip function.
void brushless17_set_direction(brushless17_t *ctx, uint8_t dir)
Brushless 17 set direction function.
void brushless17_cfg_setup(brushless17_cfg_t *cfg)
Brushless 17 configuration object setup function.
void brushless17_release_brake(brushless17_t *ctx)
Brushless 17 release brake function.
uint8_t brushless17_get_diagnostic_pin(brushless17_t *ctx)
Brushless 17 get diagnostic pin function.
err_t brushless17_set_duty_cycle(brushless17_t *ctx, float duty_cycle)
Brushless 17 sets PWM duty cycle.
Brushless 17 Click configuration object.
Definition brushless17.h:140
pin_name_t diag
Definition brushless17.h:148
uint32_t dev_pwm_freq
Definition brushless17.h:151
pin_name_t dir
Definition brushless17.h:146
pin_name_t en
Definition brushless17.h:147
pin_name_t pwm
Definition brushless17.h:142
pin_name_t brk
Definition brushless17.h:145
Brushless 17 Click driver selector.
Definition brushless17.h:118
digital_out_t brk
Definition brushless17.h:120
uint32_t pwm_freq
Definition brushless17.h:131
digital_out_t en
Definition brushless17.h:122
digital_in_t diag
Definition brushless17.h:125
pwm_t pwm
Definition brushless17.h:128
digital_out_t dir
Definition brushless17.h:121