brushless15 2.0.0.0
brushless15.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 BRUSHLESS15_H
29#define BRUSHLESS15_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 BRUSHLESS15_DEF_FREQ 1000
74
79#define BRUSHLESS15_DIR_CW 0
80#define BRUSHLESS15_DIR_CCW 1
81
82 // brushless15_cfg
83
98#define BRUSHLESS15_MAP_MIKROBUS( cfg, mikrobus ) \
99 cfg.pwm = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
100 cfg.dir = MIKROBUS( mikrobus, MIKROBUS_RST ); \
101 cfg.en = MIKROBUS( mikrobus, MIKROBUS_CS ); \
102 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT );
103
104 // brushless15_map
105 // brushless15
106
116typedef struct
117{
118 // Output pins
119 digital_out_t dir;
120 digital_out_t en;
122 // Input pins
123 digital_in_t int_pin;
125 // Modules
126 pwm_t pwm;
128 // ctx variable
129 uint32_t pwm_freq;
132
137typedef struct
138{
139 // Communication gpio pins
140 pin_name_t pwm;
142 // Additional gpio pins
143 pin_name_t dir;
144 pin_name_t en;
145 pin_name_t int_pin;
147 // Static variable
148 uint32_t dev_pwm_freq;
151
162
179
195
210
223err_t brushless15_set_duty_cycle ( brushless15_t *ctx, float duty_cycle );
224
237
250
260
270
280
291void brushless15_set_direction ( brushless15_t *ctx, uint8_t direction );
292
302
303#ifdef __cplusplus
304}
305#endif
306#endif // BRUSHLESS15_H
307
308 // brushless15
309
310// ------------------------------------------------------------------------ END
brushless15_return_value_t
Brushless 15 Click return value data.
Definition brushless15.h:157
@ BRUSHLESS15_OK
Definition brushless15.h:158
@ BRUSHLESS15_ERROR
Definition brushless15.h:159
void brushless15_set_direction(brushless15_t *ctx, uint8_t direction)
Brushless 15 set direction function.
void brushless15_disable_device(brushless15_t *ctx)
Brushless 15 disable device function.
void brushless15_cfg_setup(brushless15_cfg_t *cfg)
Brushless 15 configuration object setup function.
err_t brushless15_init(brushless15_t *ctx, brushless15_cfg_t *cfg)
Brushless 15 initialization function.
err_t brushless15_set_duty_cycle(brushless15_t *ctx, float duty_cycle)
Brushless 15 sets PWM duty cycle.
void brushless15_switch_direction(brushless15_t *ctx)
Brushless 15 switch direction function.
void brushless15_enable_device(brushless15_t *ctx)
Brushless 15 enable device function.
err_t brushless15_pwm_start(brushless15_t *ctx)
Brushless 15 start PWM module.
uint8_t brushless15_get_int_pin(brushless15_t *ctx)
Brushless 15 get int pin function.
err_t brushless15_default_cfg(brushless15_t *ctx)
Brushless 15 default configuration function.
err_t brushless15_pwm_stop(brushless15_t *ctx)
Brushless 15 stop PWM module.
Brushless 15 Click configuration object.
Definition brushless15.h:138
uint32_t dev_pwm_freq
Definition brushless15.h:148
pin_name_t dir
Definition brushless15.h:143
pin_name_t en
Definition brushless15.h:144
pin_name_t int_pin
Definition brushless15.h:145
pin_name_t pwm
Definition brushless15.h:140
Brushless 15 Click driver selector.
Definition brushless15.h:117
uint32_t pwm_freq
Definition brushless15.h:129
digital_in_t int_pin
Definition brushless15.h:123
digital_out_t en
Definition brushless15.h:120
pwm_t pwm
Definition brushless15.h:126
digital_out_t dir
Definition brushless15.h:119