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
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 BRUSHLESS6_MAP_MIKROBUS( cfg, mikrobus ) \
67 cfg.pwm = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
68
69
70 //cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT );
77#define BRUSHLESS6_RETVAL uint8_t
78
79#define BRUSHLESS6_OK 0x00
80#define BRUSHLESS6_INIT_ERROR 0xFF
87#define BRUSHLESS6_DEF_FREQ 500
94#define BRUSHLESS6_COEF 1.0 / ( ( 1000000.0 / BRUSHLESS6_DEF_FREQ ) / 0.3048 )
95#define BRUSHLESS6_MIN_PWM_DC BRUSHLESS6_COEF * 2000.0
96#define BRUSHLESS6_INIT_DC BRUSHLESS6_COEF * 4855.0
97#define BRUSHLESS6_1MS_DC BRUSHLESS6_MIN_PWM_DC / 0.608
98#define BRUSHLESS6_2MS_DC BRUSHLESS6_1MS_DC * 2.0
99#define BRUSHLESS6_PERIOD BRUSHLESS6_1MS_DC / 10.0
102 // End group macro
103// --------------------------------------------------------------- PUBLIC TYPES
112typedef struct
113{
114
115 // Modules
116
117 pwm_t pwm;
118
119 // ctx variable
120
121 uint32_t pwm_freq;
122
124
128typedef struct
129{
130 // Communication gpio pins
131
132 pin_name_t pwm;
133
134 // static variable
135
136 uint32_t dev_pwm_freq;
137
139
140 // End types group
141
142
143
144 // End constants group
145
146// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
147
153#ifdef __cplusplus
154extern "C"{
155#endif
156
166
175
176
186void brushless6_set_duty_cycle ( brushless6_t *ctx, float duty_cycle );
187
196
205
206#ifdef __cplusplus
207}
208#endif
209#endif // _BRUSHLESS6_H_
210
211 // End public_function group
213
214// ------------------------------------------------------------------------- END
#define BRUSHLESS6_RETVAL
Definition brushless6.h:77
BRUSHLESS6_RETVAL brushless6_init(brushless6_t *ctx, brushless6_cfg_t *cfg)
Initialization function.
void brushless6_pwm_stop(brushless6_t *ctx)
Stop PWM module.
void brushless6_cfg_setup(brushless6_cfg_t *cfg)
Config Object Initialization function.
void brushless6_set_duty_cycle(brushless6_t *ctx, float duty_cycle)
Generic sets PWM duty cycle.
void brushless6_pwm_start(brushless6_t *ctx)
Start PWM module.
Click configuration structure definition.
Definition brushless6.h:129
uint32_t dev_pwm_freq
Definition brushless6.h:136
pin_name_t pwm
Definition brushless6.h:132
Click ctx object definition.
Definition brushless6.h:113
uint32_t pwm_freq
Definition brushless6.h:121
pwm_t pwm
Definition brushless6.h:117