brushless5  2.0.0.0
brushless5.h
Go to the documentation of this file.
1 /*
2  * MikroSDK - MikroE Software Development Kit
3  * Copyright (c) 2019, MikroElektronika - www.mikroe.com
4  * All rights reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * 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 20000
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  uint16_t pwm_period;
98  hal_tim_frequency_t pwm_freq;
99 
100 } brushless5_t;
101 
105 typedef struct
106 {
107  // Communication gpio pins
108 
109  pin_name_t pwm;
110 
111  // Additional gpio pins
112 
113  pin_name_t fg;
114 
115  // static variable
116 
117  hal_base_addr_t dev_pwm_base;
118  hal_tim_channel_t dev_pwm_channel;
119  hal_tim_output_polarity_t dev_pwm_polarity;
120  hal_tim_frequency_t dev_pwm_freq;
121 
123  // End types group
125 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
126 
132 #ifdef __cplusplus
133 extern "C"{
134 #endif
135 
145 
154 
164 void brushless5_set_duty_cycle ( brushless5_t *ctx, pwm_data_t duty_cycle );
165 
173 void brushless5_pwm_stop ( brushless5_t *ctx );
174 
182 void brushless5_pwm_start ( brushless5_t *ctx );
183 
184 #ifdef __cplusplus
185 }
186 #endif
187 #endif // _BRUSHLESS5_H_
188  // End public_function group
191 
192 // ------------------------------------------------------------------------- END
brushless5_t::fg
digital_in_t fg
Definition: brushless5.h:89
brushless5_cfg_t::dev_pwm_base
hal_base_addr_t dev_pwm_base
Definition: brushless5.h:117
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:109
brushless5_set_duty_cycle
void brushless5_set_duty_cycle(brushless5_t *ctx, pwm_data_t duty_cycle)
Generic sets PWM duty cycle.
brushless5_cfg_setup
void brushless5_cfg_setup(brushless5_cfg_t *cfg)
Config Object Initialization function.
brushless5_cfg_t::dev_pwm_polarity
hal_tim_output_polarity_t dev_pwm_polarity
Definition: brushless5.h:119
brushless5_cfg_t::fg
pin_name_t fg
Definition: brushless5.h:113
BRUSHLESS5_RETVAL
#define BRUSHLESS5_RETVAL
Definition: brushless5.h:61
brushless5_cfg_t::dev_pwm_freq
hal_tim_frequency_t dev_pwm_freq
Definition: brushless5.h:120
brushless5_t::pwm_period
uint16_t pwm_period
Definition: brushless5.h:97
brushless5_cfg_t::dev_pwm_channel
hal_tim_channel_t dev_pwm_channel
Definition: brushless5.h:118
brushless5_t::pwm_freq
hal_tim_frequency_t pwm_freq
Definition: brushless5.h:98
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:84
brushless5_init
BRUSHLESS5_RETVAL brushless5_init(brushless5_t *ctx, brushless5_cfg_t *cfg)
Initialization function.