brushless5  2.0.0.0
brushless5.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 BRUSHLESS5_H
36 #define BRUSHLESS5_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 BRUSHLESS5_MAP_MIKROBUS( cfg, mikrobus ) \
53  cfg.pwm = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
54  cfg.fg = MIKROBUS( mikrobus, MIKROBUS_INT )
55 
61 #define BRUSHLESS5_RETVAL uint8_t
62 
63 #define BRUSHLESS5_OK 0x00
64 #define BRUSHLESS5_INIT_ERROR 0xFF
65 
71 #define BRUSHLESS5_DEF_FREQ 5000
72  // End group macro
75 // --------------------------------------------------------------- PUBLIC TYPES
84 typedef struct
85 {
86 
87  // Input pins
88 
89  digital_in_t fg;
90 
91  // Modules
92 
93  pwm_t pwm;
94 
95  // ctx variable
96 
97  uint32_t pwm_freq;
98 
99 } brushless5_t;
100 
104 typedef struct
105 {
106  // Communication gpio pins
107 
108  pin_name_t pwm;
109 
110  // Additional gpio pins
111 
112  pin_name_t fg;
113 
114  // static variable
115 
116  uint32_t dev_pwm_freq;
117 
119  // End types group
121 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
122 
128 #ifdef __cplusplus
129 extern "C"{
130 #endif
131 
141 
150 
160 void brushless5_set_duty_cycle ( brushless5_t *ctx, float duty_cycle );
161 
170 
179 
188 
189 #ifdef __cplusplus
190 }
191 #endif
192 #endif // _BRUSHLESS5_H_
193  // End public_function group
196 
197 // ------------------------------------------------------------------------- END
brushless5_t::pwm_freq
uint32_t pwm_freq
Definition: brushless5.h:97
brushless5_t::fg
digital_in_t fg
Definition: brushless5.h:89
brushless5_t::pwm
pwm_t pwm
Definition: brushless5.h:93
brushless5_pwm_start
void brushless5_pwm_start(brushless5_t *ctx)
Start PWM module.
brushless5_cfg_t::pwm
pin_name_t pwm
Definition: brushless5.h:108
brushless5_get_fg
uint8_t brushless5_get_fg(brushless5_t *ctx)
Get fg pin state.
brushless5_cfg_setup
void brushless5_cfg_setup(brushless5_cfg_t *cfg)
Config Object Initialization function.
brushless5_cfg_t::dev_pwm_freq
uint32_t dev_pwm_freq
Definition: brushless5.h:116
brushless5_cfg_t::fg
pin_name_t fg
Definition: brushless5.h:112
BRUSHLESS5_RETVAL
#define BRUSHLESS5_RETVAL
Definition: brushless5.h:61
brushless5_pwm_stop
void brushless5_pwm_stop(brushless5_t *ctx)
Stop PWM module.
brushless5_cfg_t
Click configuration structure definition.
Definition: brushless5.h:105
brushless5_t
Click ctx object definition.
Definition: brushless5.h:85
brushless5_set_duty_cycle
void brushless5_set_duty_cycle(brushless5_t *ctx, float duty_cycle)
Generic sets PWM duty cycle.
brushless5_init
BRUSHLESS5_RETVAL brushless5_init(brushless5_t *ctx, brushless5_cfg_t *cfg)
Initialization function.