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 )
61#define DCMOTOR8_RETVAL uint8_t
62
63#define DCMOTOR8_OK 0x00
64#define DCMOTOR8_INIT_ERROR 0xFF
71#define DCMOTOR8_ENABLE 1
72#define DCMOTOR8_DISABLE 0
79#define DCMOTOR8_DEF_FREQ 20000 // End group macro
83// --------------------------------------------------------------- PUBLIC TYPES
92typedef 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
112typedef 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
137extern "C"{
138#endif
139
149
159
168void dcmotor8_set_duty_cycle ( dcmotor8_t *ctx, float duty_cycle );
169
178
187
196void 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
#define DCMOTOR8_RETVAL
Definition: dcmotor8.h:61
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:113
uint32_t dev_pwm_freq
Definition: dcmotor8.h:124
pin_name_t en
Definition: dcmotor8.h:120
pin_name_t pwm
Definition: dcmotor8.h:116
Click ctx object definition.
Definition: dcmotor8.h:93
uint32_t pwm_freq
Definition: dcmotor8.h:105
digital_out_t en
Definition: dcmotor8.h:97
pwm_t pwm
Definition: dcmotor8.h:101