vtohz2 2.0.0.0
vtohz2.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 VTOHZ2_H
36#define VTOHZ2_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 VTOHZ2_MAP_MIKROBUS( cfg, mikrobus ) \
67 cfg.pwm = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
68 cfg.en = MIKROBUS( mikrobus, MIKROBUS_CS ); \
69 cfg.fo = MIKROBUS( mikrobus, MIKROBUS_INT )
76#define VTOHZ2_RETVAL uint8_t
77
78#define VTOHZ2_OK 0x00
79#define VTOHZ2_INIT_ERROR 0xFF
86#define VTOHZ2_ENABLE 1
87#define VTOHZ2_DISABLE 0
94#define VTOHZ2_DEF_FREQ 20000
97 // End group macro
98// --------------------------------------------------------------- PUBLIC TYPES
107typedef struct
108{
109
110 // Output pins
111
112 digital_out_t en;
113
114 // Input pins
115
116 digital_in_t fo;
117
118 // Modules
119
120 pwm_t pwm;
121
122 // ctx variable
123
124 uint32_t pwm_freq;
125
126} vtohz2_t;
127
131typedef struct
132{
133 // Communication gpio pins
134
135 pin_name_t pwm;
136
137 // Additional gpio pins
138
139 pin_name_t en;
140 pin_name_t fo;
141
142 // static variable
143
144 uint32_t dev_pwm_freq;
145
147
148 // End types group
149// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
150
156#ifdef __cplusplus
157extern "C"{
158#endif
159
169
178
187
197void vtohz2_set_duty_cycle ( vtohz2_t *ctx, float duty_cycle );
198
207
216
229void vtohz2_enable ( vtohz2_t *ctx, uint8_t state );
230
241
242#ifdef __cplusplus
243}
244#endif
245#endif // _VTOHZ2_H_
246
247 // End public_function group
249
250// ------------------------------------------------------------------------- END
#define VTOHZ2_RETVAL
Definition vtohz2.h:76
void vtohz2_enable(vtohz2_t *ctx, uint8_t state)
Enable function.
void vtohz2_set_duty_cycle(vtohz2_t *ctx, float duty_cycle)
Generic sets PWM duty cycle.
void vtohz2_pwm_start(vtohz2_t *ctx)
Start PWM module.
void vtohz2_cfg_setup(vtohz2_cfg_t *cfg)
Config Object Initialization function.
void vtohz2_default_cfg(vtohz2_t *ctx)
Click Default Configuration function.
uint8_t vtohz2_get_freq_out(vtohz2_t *ctx)
Frequency Out Get function.
void vtohz2_pwm_stop(vtohz2_t *ctx)
Stop PWM module.
VTOHZ2_RETVAL vtohz2_init(vtohz2_t *ctx, vtohz2_cfg_t *cfg)
Initialization function.
Click configuration structure definition.
Definition vtohz2.h:132
pin_name_t fo
Definition vtohz2.h:140
uint32_t dev_pwm_freq
Definition vtohz2.h:144
pin_name_t en
Definition vtohz2.h:139
pin_name_t pwm
Definition vtohz2.h:135
Click ctx object definition.
Definition vtohz2.h:108
digital_in_t fo
Definition vtohz2.h:116
uint32_t pwm_freq
Definition vtohz2.h:124
digital_out_t en
Definition vtohz2.h:112
pwm_t pwm
Definition vtohz2.h:120