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 )
61#define BRUSHLESS5_RETVAL uint8_t
62
63#define BRUSHLESS5_OK 0x00
64#define BRUSHLESS5_INIT_ERROR 0xFF
71#define BRUSHLESS5_DEF_FREQ 5000 // End group macro
75// --------------------------------------------------------------- PUBLIC TYPES
84typedef 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
100
104typedef 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
129extern "C"{
130#endif
131
141
150
160void 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
#define BRUSHLESS5_RETVAL
Definition: brushless5.h:61
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:105
pin_name_t fg
Definition: brushless5.h:112
uint32_t dev_pwm_freq
Definition: brushless5.h:116
pin_name_t pwm
Definition: brushless5.h:108
Click ctx object definition.
Definition: brushless5.h:85
uint32_t pwm_freq
Definition: brushless5.h:97
digital_in_t fg
Definition: brushless5.h:89
pwm_t pwm
Definition: brushless5.h:93