brushless6  2.0.0.0
brushless6.h
Go to the documentation of this file.
1 /*
2  * MikroSDK - MikroE Software Development Kit
3  * Copyright© 2020 MikroElektronika d.o.o.
4  *
5  * Permission is hereby granted, free of charge, to any person
6  * obtaining a copy of this software and associated documentation
7  * files (the "Software"), to deal in the Software without restriction,
8  * including without limitation the rights to use, copy, modify, merge,
9  * publish, distribute, sublicense, and/or sell copies of the Software,
10  * and to permit persons to whom the Software is furnished to do so,
11  * subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be
14  * included in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
22  * OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24 
33 // ----------------------------------------------------------------------------
34 
35 #ifndef BRUSHLESS6_H
36 #define BRUSHLESS6_H
37 
38 #include "drv_digital_out.h"
39 #include "drv_digital_in.h"
40 #include "drv_pwm.h"
41 
42 // -------------------------------------------------------------- PUBLIC MACROS
52 #define BRUSHLESS6_MAP_MIKROBUS( cfg, mikrobus ) \
53  cfg.pwm = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
54 
55 
56  //cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT );
63 #define BRUSHLESS6_RETVAL uint8_t
64 
65 #define BRUSHLESS6_OK 0x00
66 #define BRUSHLESS6_INIT_ERROR 0xFF
67 
73 #define BRUSHLESS6_DEF_FREQ 500
74 
80 #define BRUSHLESS6_COEF 1.0 / ( ( 1000000.0 / BRUSHLESS6_DEF_FREQ ) / 0.3048 )
81 #define BRUSHLESS6_MIN_PWM_DC BRUSHLESS6_COEF * 2000.0
82 #define BRUSHLESS6_INIT_DC BRUSHLESS6_COEF * 4855.0
83 #define BRUSHLESS6_1MS_DC BRUSHLESS6_MIN_PWM_DC / 0.608
84 #define BRUSHLESS6_2MS_DC BRUSHLESS6_1MS_DC * 2.0
85 #define BRUSHLESS6_PERIOD BRUSHLESS6_1MS_DC / 10.0
86  // End group macro
89 // --------------------------------------------------------------- PUBLIC TYPES
98 typedef struct
99 {
100 
101  // Modules
102 
103  pwm_t pwm;
104 
105  // ctx variable
106 
107  uint32_t pwm_freq;
108 
109 } brushless6_t;
110 
114 typedef struct
115 {
116  // Communication gpio pins
117 
118  pin_name_t pwm;
119 
120  // static variable
121 
122  uint32_t dev_pwm_freq;
123 
125  // End types group
127 
128 
129  // End constants group
131 
132 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
133 
139 #ifdef __cplusplus
140 extern "C"{
141 #endif
142 
152 
161 
162 
172 void brushless6_set_duty_cycle ( brushless6_t *ctx, float duty_cycle );
173 
181 void brushless6_pwm_stop ( brushless6_t *ctx );
182 
190 void brushless6_pwm_start ( brushless6_t *ctx );
191 
199 
200 #ifdef __cplusplus
201 }
202 #endif
203 #endif // _BRUSHLESS6_H_
204  // End public_function group
207 
208 // ------------------------------------------------------------------------- END
BRUSHLESS6_RETVAL
#define BRUSHLESS6_RETVAL
Definition: brushless6.h:63
brushless6_cfg_t::dev_pwm_freq
uint32_t dev_pwm_freq
Definition: brushless6.h:122
brushless6_gpio_driver_init
void brushless6_gpio_driver_init(brushless6_t *ctx)
GPIO Only Drivers - remove in other cases.
brushless6_t::pwm_freq
uint32_t pwm_freq
Definition: brushless6.h:107
brushless6_init
BRUSHLESS6_RETVAL brushless6_init(brushless6_t *ctx, brushless6_cfg_t *cfg)
Initialization function.
brushless6_cfg_t::pwm
pin_name_t pwm
Definition: brushless6.h:118
brushless6_t::pwm
pwm_t pwm
Definition: brushless6.h:103
brushless6_set_duty_cycle
void brushless6_set_duty_cycle(brushless6_t *ctx, float duty_cycle)
Generic sets PWM duty cycle.
brushless6_t
Click ctx object definition.
Definition: brushless6.h:98
brushless6_pwm_stop
void brushless6_pwm_stop(brushless6_t *ctx)
Stop PWM module.
brushless6_cfg_t
Click configuration structure definition.
Definition: brushless6.h:114
brushless6_pwm_start
void brushless6_pwm_start(brushless6_t *ctx)
Start PWM module.
brushless6_cfg_setup
void brushless6_cfg_setup(brushless6_cfg_t *cfg)
Config Object Initialization function.