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
42#ifdef PREINIT_SUPPORTED
43#include "preinit.h"
44#endif
45
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
48 #include "delays.h"
49 #endif
50#endif
51
52#include "drv_digital_out.h"
53#include "drv_digital_in.h"
54#include "drv_pwm.h"
55
56// -------------------------------------------------------------- PUBLIC MACROS
66#define BRUSHLESS5_MAP_MIKROBUS( cfg, mikrobus ) \
67 cfg.pwm = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
68 cfg.fg = MIKROBUS( mikrobus, MIKROBUS_INT )
75#define BRUSHLESS5_RETVAL uint8_t
76
77#define BRUSHLESS5_OK 0x00
78#define BRUSHLESS5_INIT_ERROR 0xFF
85#define BRUSHLESS5_DEF_FREQ 5000
88 // End group macro
89// --------------------------------------------------------------- PUBLIC TYPES
98typedef struct
99{
100
101 // Input pins
102
103 digital_in_t fg;
104
105 // Modules
106
107 pwm_t pwm;
108
109 // ctx variable
110
111 uint32_t pwm_freq;
112
114
118typedef struct
119{
120 // Communication gpio pins
121
122 pin_name_t pwm;
123
124 // Additional gpio pins
125
126 pin_name_t fg;
127
128 // static variable
129
130 uint32_t dev_pwm_freq;
131
133
134 // End types group
135// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
136
142#ifdef __cplusplus
143extern "C"{
144#endif
145
155
164
174void brushless5_set_duty_cycle ( brushless5_t *ctx, float duty_cycle );
175
184
193
202
203#ifdef __cplusplus
204}
205#endif
206#endif // _BRUSHLESS5_H_
207
208 // End public_function group
210
211// ------------------------------------------------------------------------- END
#define BRUSHLESS5_RETVAL
Definition brushless5.h:75
uint8_t brushless5_get_fg(brushless5_t *ctx)
Get fg pin state.
void brushless5_set_duty_cycle(brushless5_t *ctx, float duty_cycle)
Generic sets PWM duty cycle.
BRUSHLESS5_RETVAL brushless5_init(brushless5_t *ctx, brushless5_cfg_t *cfg)
Initialization function.
void brushless5_pwm_stop(brushless5_t *ctx)
Stop PWM module.
void brushless5_cfg_setup(brushless5_cfg_t *cfg)
Config Object Initialization function.
void brushless5_pwm_start(brushless5_t *ctx)
Start PWM module.
Click configuration structure definition.
Definition brushless5.h:119
pin_name_t fg
Definition brushless5.h:126
uint32_t dev_pwm_freq
Definition brushless5.h:130
pin_name_t pwm
Definition brushless5.h:122
Click ctx object definition.
Definition brushless5.h:99
uint32_t pwm_freq
Definition brushless5.h:111
digital_in_t fg
Definition brushless5.h:103
pwm_t pwm
Definition brushless5.h:107