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
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 DCMOTOR8_MAP_MIKROBUS( cfg, mikrobus ) \
67 cfg.pwm = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
68 cfg.en = MIKROBUS( mikrobus, MIKROBUS_CS )
75#define DCMOTOR8_RETVAL uint8_t
76
77#define DCMOTOR8_OK 0x00
78#define DCMOTOR8_INIT_ERROR 0xFF
85#define DCMOTOR8_ENABLE 1
86#define DCMOTOR8_DISABLE 0
93#define DCMOTOR8_DEF_FREQ 20000
96 // End group macro
97// --------------------------------------------------------------- PUBLIC TYPES
106typedef struct
107{
108
109 // Output pins
110
111 digital_out_t en;
112
113 // Modules
114
115 pwm_t pwm;
116
117 // ctx variable
118
119 uint32_t pwm_freq;
120
121} dcmotor8_t;
122
126typedef struct
127{
128 // Communication gpio pins
129
130 pin_name_t pwm;
131
132 // Additional gpio pins
133
134 pin_name_t en;
135
136 // static variable
137
138 uint32_t dev_pwm_freq;
139
141
142 // End types group
143// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
144
150#ifdef __cplusplus
151extern "C"{
152#endif
153
163
173
182void dcmotor8_set_duty_cycle ( dcmotor8_t *ctx, float duty_cycle );
183
192
201
210void dcmotor8_enable ( dcmotor8_t *ctx, uint8_t state );
211
212#ifdef __cplusplus
213}
214#endif
215#endif // _DCMOTOR8_H_
216
217 // End public_function group
219
220// ------------------------------------------------------------------------- END
#define DCMOTOR8_RETVAL
Definition dcmotor8.h:75
void dcmotor8_pwm_stop(dcmotor8_t *ctx)
Stop PWM module.
void dcmotor8_pwm_start(dcmotor8_t *ctx)
Start PWM module.
void dcmotor8_enable(dcmotor8_t *ctx, uint8_t state)
Enable function.
void dcmotor8_cfg_setup(dcmotor8_cfg_t *cfg)
Config Object Initialization function.
void dcmotor8_set_duty_cycle(dcmotor8_t *ctx, float duty_cycle)
Generic sets PWM duty cycle.
DCMOTOR8_RETVAL dcmotor8_init(dcmotor8_t *ctx, dcmotor8_cfg_t *cfg)
Initialization function.
Click configuration structure definition.
Definition dcmotor8.h:127
uint32_t dev_pwm_freq
Definition dcmotor8.h:138
pin_name_t en
Definition dcmotor8.h:134
pin_name_t pwm
Definition dcmotor8.h:130
Click ctx object definition.
Definition dcmotor8.h:107
uint32_t pwm_freq
Definition dcmotor8.h:119
digital_out_t en
Definition dcmotor8.h:111
pwm_t pwm
Definition dcmotor8.h:115