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 
39 #ifdef PREINIT_SUPPORTED
40 #include "preinit.h"
41 #endif
42 
43 #ifdef MikroCCoreVersion
44  #if MikroCCoreVersion >= 1
45  #include "delays.h"
46  #endif
47 #endif
48 
49 #include "drv_digital_out.h"
50 #include "drv_digital_in.h"
51 
62 #define BRUSHLESS12_ENABLE 1
63 #define BRUSHLESS12_DISABLE 0
64 #define BRUSHLESS12_START 1
65 #define BRUSHLESS12_BRAKE 0
66 #define BRUSHLESS12_DIR_FORWARD 1
67 #define BRUSHLESS12_DIR_REVERSE 0
68  // brushless12_set
75 
90 #define BRUSHLESS12_MAP_MIKROBUS( cfg, mikrobus ) \
91  cfg.brk = MIKROBUS( mikrobus, MIKROBUS_RST ); \
92  cfg.en = MIKROBUS( mikrobus, MIKROBUS_CS ); \
93  cfg.dir = MIKROBUS( mikrobus, MIKROBUS_PWM );
94  // brushless12_map // brushless12
97 
102 typedef struct
103 {
104  digital_out_t brk;
105  digital_out_t en;
106  digital_out_t dir;
108 } brushless12_t;
109 
114 typedef struct
115 {
116  pin_name_t brk;
117  pin_name_t en;
118  pin_name_t dir;
121 
126 typedef enum
127 {
129  BRUSHLESS12_ERROR = -1
130 
132 
149 
165 
180 
189 void brushless12_set_brake ( brushless12_t *ctx, uint8_t state );
190 
199 void brushless12_set_direction ( brushless12_t *ctx, uint8_t state );
200 
209 void brushless12_set_enable ( brushless12_t *ctx, uint8_t state );
210 
211 #ifdef __cplusplus
212 }
213 #endif
214 #endif // BRUSHLESS12_H
215  // brushless12
217 
218 // ------------------------------------------------------------------------ END
brushless12_cfg_t
Brushless 12 Click configuration object.
Definition: brushless12.h:115
brushless12_init
err_t brushless12_init(brushless12_t *ctx, brushless12_cfg_t *cfg)
Brushless 12 initialization function.
BRUSHLESS12_ERROR
@ BRUSHLESS12_ERROR
Definition: brushless12.h:129
brushless12_return_value_t
brushless12_return_value_t
Brushless 12 Click return value data.
Definition: brushless12.h:127
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:105
brushless12_t::dir
digital_out_t dir
Definition: brushless12.h:106
BRUSHLESS12_OK
@ BRUSHLESS12_OK
Definition: brushless12.h:128
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:117
brushless12_t::brk
digital_out_t brk
Definition: brushless12.h:104
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:116
brushless12_cfg_t::dir
pin_name_t dir
Definition: brushless12.h:118
brushless12_t
Brushless 12 Click context object.
Definition: brushless12.h:103
brushless12_set_enable
void brushless12_set_enable(brushless12_t *ctx, uint8_t state)
Brushless 12 set EN pin state function.