dcmotor8  2.0.0.0
dcmotor8.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 DCMOTOR8_H
36 #define DCMOTOR8_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 DCMOTOR8_MAP_MIKROBUS( cfg, mikrobus ) \
53  cfg.pwm = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
54  cfg.en = MIKROBUS( mikrobus, MIKROBUS_CS )
55 
61 #define DCMOTOR8_RETVAL uint8_t
62 
63 #define DCMOTOR8_OK 0x00
64 #define DCMOTOR8_INIT_ERROR 0xFF
65 
71 #define DCMOTOR8_ENABLE 1
72 #define DCMOTOR8_DISABLE 0
73 
79 #define DCMOTOR8_DEF_FREQ 20000
80  // End group macro
83 // --------------------------------------------------------------- PUBLIC TYPES
92 typedef struct
93 {
94 
95  // Output pins
96 
97  digital_out_t en;
98 
99  // Modules
100 
101  pwm_t pwm;
102 
103  // ctx variable
104 
105  uint32_t pwm_freq;
106 
107 } dcmotor8_t;
108 
112 typedef struct
113 {
114  // Communication gpio pins
115 
116  pin_name_t pwm;
117 
118  // Additional gpio pins
119 
120  pin_name_t en;
121 
122  // static variable
123 
124  uint32_t dev_pwm_freq;
125 
127  // End types group
129 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
130 
136 #ifdef __cplusplus
137 extern "C"{
138 #endif
139 
149 
159 
168 void dcmotor8_set_duty_cycle ( dcmotor8_t *ctx, float duty_cycle );
169 
178 
187 
196 void dcmotor8_enable ( dcmotor8_t *ctx, uint8_t state );
197 
198 #ifdef __cplusplus
199 }
200 #endif
201 #endif // _DCMOTOR8_H_
202  // End public_function group
205 
206 // ------------------------------------------------------------------------- END
dcmotor8_enable
void dcmotor8_enable(dcmotor8_t *ctx, uint8_t state)
Enable function.
dcmotor8_cfg_t::pwm
pin_name_t pwm
Definition: dcmotor8.h:116
dcmotor8_pwm_start
void dcmotor8_pwm_start(dcmotor8_t *ctx)
Start PWM module.
dcmotor8_init
DCMOTOR8_RETVAL dcmotor8_init(dcmotor8_t *ctx, dcmotor8_cfg_t *cfg)
Initialization function.
dcmotor8_t::en
digital_out_t en
Definition: dcmotor8.h:97
dcmotor8_t
Click ctx object definition.
Definition: dcmotor8.h:93
dcmotor8_cfg_setup
void dcmotor8_cfg_setup(dcmotor8_cfg_t *cfg)
Config Object Initialization function.
dcmotor8_set_duty_cycle
void dcmotor8_set_duty_cycle(dcmotor8_t *ctx, float duty_cycle)
Generic sets PWM duty cycle.
dcmotor8_pwm_stop
void dcmotor8_pwm_stop(dcmotor8_t *ctx)
Stop PWM module.
dcmotor8_cfg_t::en
pin_name_t en
Definition: dcmotor8.h:120
DCMOTOR8_RETVAL
#define DCMOTOR8_RETVAL
Definition: dcmotor8.h:61
dcmotor8_t::pwm
pwm_t pwm
Definition: dcmotor8.h:101
dcmotor8_cfg_t
Click configuration structure definition.
Definition: dcmotor8.h:113
dcmotor8_cfg_t::dev_pwm_freq
uint32_t dev_pwm_freq
Definition: dcmotor8.h:124
dcmotor8_t::pwm_freq
uint32_t pwm_freq
Definition: dcmotor8.h:105