brushless12  2.0.0.0
brushless12.h
Go to the documentation of this file.
1 /****************************************************************************
2 ** Copyright (C) 2020 MikroElektronika d.o.o.
3 ** Contact: https://www.mikroe.com/contact
4 **
5 ** Permission is hereby granted, free of charge, to any person obtaining a copy
6 ** of this software and associated documentation files (the "Software"), to deal
7 ** in the Software without restriction, including without limitation the rights
8 ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 ** copies of the Software, and to permit persons to whom the Software is
10 ** furnished to do so, subject to the following conditions:
11 ** The above copyright notice and this permission notice shall be
12 ** included in all copies or substantial portions of the Software.
13 **
14 ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16 ** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18 ** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19 ** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 ** USE OR OTHER DEALINGS IN THE SOFTWARE.
21 ****************************************************************************/
22 
28 #ifndef BRUSHLESS12_H
29 #define BRUSHLESS12_H
30 
31 #ifdef __cplusplus
32 extern "C"{
33 #endif
34 
35 #include "mikrosdk_version.h"
36 
37 #ifdef __GNUC__
38 #if mikroSDK_GET_VERSION < 20800ul
39 #include "rcu_delays.h"
40 #else
41 #include "delays.h"
42 #endif
43 #endif
44 
45 #include "drv_digital_out.h"
46 #include "drv_digital_in.h"
47 
58 #define BRUSHLESS12_ENABLE 1
59 #define BRUSHLESS12_DISABLE 0
60 #define BRUSHLESS12_START 1
61 #define BRUSHLESS12_BRAKE 0
62 #define BRUSHLESS12_DIR_FORWARD 1
63 #define BRUSHLESS12_DIR_REVERSE 0
64  // brushless12_set
71 
86 #define BRUSHLESS12_MAP_MIKROBUS( cfg, mikrobus ) \
87  cfg.brk = MIKROBUS( mikrobus, MIKROBUS_RST ); \
88  cfg.en = MIKROBUS( mikrobus, MIKROBUS_CS ); \
89  cfg.dir = MIKROBUS( mikrobus, MIKROBUS_PWM );
90  // brushless12_map // brushless12
93 
98 typedef struct
99 {
100  digital_out_t brk;
101  digital_out_t en;
102  digital_out_t dir;
104 } brushless12_t;
105 
110 typedef struct
111 {
112  pin_name_t brk;
113  pin_name_t en;
114  pin_name_t dir;
117 
122 typedef enum
123 {
125  BRUSHLESS12_ERROR = -1
126 
128 
145 
161 
176 
185 void brushless12_set_brake ( brushless12_t *ctx, uint8_t state );
186 
195 void brushless12_set_direction ( brushless12_t *ctx, uint8_t state );
196 
205 void brushless12_set_enable ( brushless12_t *ctx, uint8_t state );
206 
207 #ifdef __cplusplus
208 }
209 #endif
210 #endif // BRUSHLESS12_H
211  // brushless12
213 
214 // ------------------------------------------------------------------------ END
brushless12_cfg_t
Brushless 12 Click configuration object.
Definition: brushless12.h:111
brushless12_init
err_t brushless12_init(brushless12_t *ctx, brushless12_cfg_t *cfg)
Brushless 12 initialization function.
BRUSHLESS12_ERROR
@ BRUSHLESS12_ERROR
Definition: brushless12.h:125
brushless12_return_value_t
brushless12_return_value_t
Brushless 12 Click return value data.
Definition: brushless12.h:123
brushless12_default_cfg
err_t brushless12_default_cfg(brushless12_t *ctx)
Brushless 12 default configuration function.
brushless12_t::en
digital_out_t en
Definition: brushless12.h:101
brushless12_t::dir
digital_out_t dir
Definition: brushless12.h:102
BRUSHLESS12_OK
@ BRUSHLESS12_OK
Definition: brushless12.h:124
brushless12_cfg_setup
void brushless12_cfg_setup(brushless12_cfg_t *cfg)
Brushless 12 configuration object setup function.
brushless12_cfg_t::en
pin_name_t en
Definition: brushless12.h:113
brushless12_t::brk
digital_out_t brk
Definition: brushless12.h:100
brushless12_set_brake
void brushless12_set_brake(brushless12_t *ctx, uint8_t state)
Brushless 12 set BRK pin state function.
brushless12_set_direction
void brushless12_set_direction(brushless12_t *ctx, uint8_t state)
Brushless 12 set F/R pin state function.
brushless12_cfg_t::brk
pin_name_t brk
Definition: brushless12.h:112
brushless12_cfg_t::dir
pin_name_t dir
Definition: brushless12.h:114
brushless12_t
Brushless 12 Click context object.
Definition: brushless12.h:99
brushless12_set_enable
void brushless12_set_enable(brushless12_t *ctx, uint8_t state)
Brushless 12 set EN pin state function.