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 "drv_digital_out.h"
36 #include "drv_digital_in.h"
37 #include "drv_pwm.h"
38 
59 #define BRUSHLESS15_DEF_FREQ 1000
60 
65 #define BRUSHLESS15_DIR_CW 0
66 #define BRUSHLESS15_DIR_CCW 1
67  // brushless15_cfg
69 
84 #define BRUSHLESS15_MAP_MIKROBUS( cfg, mikrobus ) \
85  cfg.pwm = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
86  cfg.dir = MIKROBUS( mikrobus, MIKROBUS_RST ); \
87  cfg.en = MIKROBUS( mikrobus, MIKROBUS_CS ); \
88  cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT );
89  // brushless15_map // brushless15
92 
102 typedef struct
103 {
104  // Output pins
105  digital_out_t dir;
106  digital_out_t en;
108  // Input pins
109  digital_in_t int_pin;
111  // Modules
112  pwm_t pwm;
114  // ctx variable
115  uint32_t pwm_freq;
117 } brushless15_t;
118 
123 typedef struct
124 {
125  // Communication gpio pins
126  pin_name_t pwm;
128  // Additional gpio pins
129  pin_name_t dir;
130  pin_name_t en;
131  pin_name_t int_pin;
133  // Static variable
134  uint32_t dev_pwm_freq;
137 
142 typedef enum
143 {
145  BRUSHLESS15_ERROR = -1
146 
148 
165 
181 
196 
209 err_t brushless15_set_duty_cycle ( brushless15_t *ctx, float duty_cycle );
210 
223 
236 
246 
256 
266 
277 void brushless15_set_direction ( brushless15_t *ctx, uint8_t direction );
278 
288 
289 #ifdef __cplusplus
290 }
291 #endif
292 #endif // BRUSHLESS15_H
293  // brushless15
295 
296 // ------------------------------------------------------------------------ END
brushless15_cfg_t
Brushless 15 Click configuration object.
Definition: brushless15.h:124
brushless15_cfg_t::en
pin_name_t en
Definition: brushless15.h:130
BRUSHLESS15_ERROR
@ BRUSHLESS15_ERROR
Definition: brushless15.h:145
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:143
brushless15_t::pwm_freq
uint32_t pwm_freq
Definition: brushless15.h:115
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:134
brushless15_t::pwm
pwm_t pwm
Definition: brushless15.h:112
brushless15_t
Brushless 15 Click driver selector.
Definition: brushless15.h:103
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:126
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:131
BRUSHLESS15_OK
@ BRUSHLESS15_OK
Definition: brushless15.h:144
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:129
brushless15_t::int_pin
digital_in_t int_pin
Definition: brushless15.h:109
brushless15_t::en
digital_out_t en
Definition: brushless15.h:106
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:105
brushless15_get_int_pin
uint8_t brushless15_get_int_pin(brushless15_t *ctx)
Brushless 15 get int pin function.