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
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 BRUSHLESS15_DEF_FREQ 1000
70 
75 #define BRUSHLESS15_DIR_CW 0
76 #define BRUSHLESS15_DIR_CCW 1
77  // brushless15_cfg
79 
94 #define BRUSHLESS15_MAP_MIKROBUS( cfg, mikrobus ) \
95  cfg.pwm = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
96  cfg.dir = MIKROBUS( mikrobus, MIKROBUS_RST ); \
97  cfg.en = MIKROBUS( mikrobus, MIKROBUS_CS ); \
98  cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT );
99  // brushless15_map // brushless15
102 
112 typedef struct
113 {
114  // Output pins
115  digital_out_t dir;
116  digital_out_t en;
118  // Input pins
119  digital_in_t int_pin;
121  // Modules
122  pwm_t pwm;
124  // ctx variable
125  uint32_t pwm_freq;
127 } brushless15_t;
128 
133 typedef struct
134 {
135  // Communication gpio pins
136  pin_name_t pwm;
138  // Additional gpio pins
139  pin_name_t dir;
140  pin_name_t en;
141  pin_name_t int_pin;
143  // Static variable
144  uint32_t dev_pwm_freq;
147 
152 typedef enum
153 {
155  BRUSHLESS15_ERROR = -1
156 
158 
175 
191 
206 
219 err_t brushless15_set_duty_cycle ( brushless15_t *ctx, float duty_cycle );
220 
233 
246 
256 
266 
276 
287 void brushless15_set_direction ( brushless15_t *ctx, uint8_t direction );
288 
298 
299 #ifdef __cplusplus
300 }
301 #endif
302 #endif // BRUSHLESS15_H
303  // brushless15
305 
306 // ------------------------------------------------------------------------ END
brushless15_cfg_t
Brushless 15 Click configuration object.
Definition: brushless15.h:134
brushless15_cfg_t::en
pin_name_t en
Definition: brushless15.h:140
BRUSHLESS15_ERROR
@ BRUSHLESS15_ERROR
Definition: brushless15.h:155
brushless15_pwm_stop
err_t brushless15_pwm_stop(brushless15_t *ctx)
Brushless 15 stop PWM module.
brushless15_enable_device
void brushless15_enable_device(brushless15_t *ctx)
Brushless 15 enable device function.
brushless15_return_value_t
brushless15_return_value_t
Brushless 15 Click return value data.
Definition: brushless15.h:153
brushless15_t::pwm_freq
uint32_t pwm_freq
Definition: brushless15.h:125
brushless15_set_duty_cycle
err_t brushless15_set_duty_cycle(brushless15_t *ctx, float duty_cycle)
Brushless 15 sets PWM duty cycle.
brushless15_pwm_start
err_t brushless15_pwm_start(brushless15_t *ctx)
Brushless 15 start PWM module.
brushless15_default_cfg
err_t brushless15_default_cfg(brushless15_t *ctx)
Brushless 15 default configuration function.
brushless15_cfg_t::dev_pwm_freq
uint32_t dev_pwm_freq
Definition: brushless15.h:144
brushless15_t::pwm
pwm_t pwm
Definition: brushless15.h:122
brushless15_t
Brushless 15 Click driver selector.
Definition: brushless15.h:113
brushless15_set_direction
void brushless15_set_direction(brushless15_t *ctx, uint8_t direction)
Brushless 15 set direction function.
brushless15_cfg_t::pwm
pin_name_t pwm
Definition: brushless15.h:136
brushless15_cfg_setup
void brushless15_cfg_setup(brushless15_cfg_t *cfg)
Brushless 15 configuration object setup function.
brushless15_cfg_t::int_pin
pin_name_t int_pin
Definition: brushless15.h:141
BRUSHLESS15_OK
@ BRUSHLESS15_OK
Definition: brushless15.h:154
brushless15_init
err_t brushless15_init(brushless15_t *ctx, brushless15_cfg_t *cfg)
Brushless 15 initialization function.
brushless15_cfg_t::dir
pin_name_t dir
Definition: brushless15.h:139
brushless15_t::int_pin
digital_in_t int_pin
Definition: brushless15.h:119
brushless15_t::en
digital_out_t en
Definition: brushless15.h:116
brushless15_switch_direction
void brushless15_switch_direction(brushless15_t *ctx)
Brushless 15 switch direction function.
brushless15_disable_device
void brushless15_disable_device(brushless15_t *ctx)
Brushless 15 disable device function.
brushless15_t::dir
digital_out_t dir
Definition: brushless15.h:115
brushless15_get_int_pin
uint8_t brushless15_get_int_pin(brushless15_t *ctx)
Brushless 15 get int pin function.