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 "mikrosdk_version.h"
39 
40 #ifdef __GNUC__
41 #if mikroSDK_GET_VERSION < 20800ul
42 #include "rcu_delays.h"
43 #else
44 #include "delays.h"
45 #endif
46 #endif
47 
48 #include "drv_digital_out.h"
49 #include "drv_digital_in.h"
50 #include "drv_pwm.h"
51 
52 // -------------------------------------------------------------- PUBLIC MACROS
62 #define BRUSHLESS5_MAP_MIKROBUS( cfg, mikrobus ) \
63  cfg.pwm = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
64  cfg.fg = MIKROBUS( mikrobus, MIKROBUS_INT )
65 
71 #define BRUSHLESS5_RETVAL uint8_t
72 
73 #define BRUSHLESS5_OK 0x00
74 #define BRUSHLESS5_INIT_ERROR 0xFF
75 
81 #define BRUSHLESS5_DEF_FREQ 5000
82  // End group macro
85 // --------------------------------------------------------------- PUBLIC TYPES
94 typedef struct
95 {
96 
97  // Input pins
98 
99  digital_in_t fg;
100 
101  // Modules
102 
103  pwm_t pwm;
104 
105  // ctx variable
106 
107  uint32_t pwm_freq;
108 
109 } brushless5_t;
110 
114 typedef struct
115 {
116  // Communication gpio pins
117 
118  pin_name_t pwm;
119 
120  // Additional gpio pins
121 
122  pin_name_t fg;
123 
124  // static variable
125 
126  uint32_t dev_pwm_freq;
127 
129  // End types group
131 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
132 
138 #ifdef __cplusplus
139 extern "C"{
140 #endif
141 
151 
160 
170 void brushless5_set_duty_cycle ( brushless5_t *ctx, float duty_cycle );
171 
180 
189 
198 
199 #ifdef __cplusplus
200 }
201 #endif
202 #endif // _BRUSHLESS5_H_
203  // End public_function group
206 
207 // ------------------------------------------------------------------------- END
brushless5_t::pwm_freq
uint32_t pwm_freq
Definition: brushless5.h:107
brushless5_t::fg
digital_in_t fg
Definition: brushless5.h:99
brushless5_t::pwm
pwm_t pwm
Definition: brushless5.h:103
brushless5_pwm_start
void brushless5_pwm_start(brushless5_t *ctx)
Start PWM module.
brushless5_cfg_t::pwm
pin_name_t pwm
Definition: brushless5.h:118
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:126
brushless5_cfg_t::fg
pin_name_t fg
Definition: brushless5.h:122
BRUSHLESS5_RETVAL
#define BRUSHLESS5_RETVAL
Definition: brushless5.h:71
brushless5_pwm_stop
void brushless5_pwm_stop(brushless5_t *ctx)
Stop PWM module.
brushless5_cfg_t
Click configuration structure definition.
Definition: brushless5.h:115
brushless5_t
Click ctx object definition.
Definition: brushless5.h:95
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.