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 )
70 
76 #define VTOHZ2_RETVAL uint8_t
77 
78 #define VTOHZ2_OK 0x00
79 #define VTOHZ2_INIT_ERROR 0xFF
80 
86 #define VTOHZ2_ENABLE 1
87 #define VTOHZ2_DISABLE 0
88 
94 #define VTOHZ2_DEF_FREQ 20000
95  // End group macro
98 // --------------------------------------------------------------- PUBLIC TYPES
107 typedef 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 
131 typedef 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 
146 } vtohz2_cfg_t;
147  // End types group
149 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
150 
156 #ifdef __cplusplus
157 extern "C"{
158 #endif
159 
169 
178 
187 
197 void vtohz2_set_duty_cycle ( vtohz2_t *ctx, float duty_cycle );
198 
206 void vtohz2_pwm_stop ( vtohz2_t *ctx );
207 
216 
229 void vtohz2_enable ( vtohz2_t *ctx, uint8_t state );
230 
240 uint8_t vtohz2_get_freq_out ( vtohz2_t *ctx );
241 
242 #ifdef __cplusplus
243 }
244 #endif
245 #endif // _VTOHZ2_H_
246  // End public_function group
249 
250 // ------------------------------------------------------------------------- END
vtohz2_pwm_start
void vtohz2_pwm_start(vtohz2_t *ctx)
Start PWM module.
vtohz2_cfg_t::fo
pin_name_t fo
Definition: vtohz2.h:140
vtohz2_set_duty_cycle
void vtohz2_set_duty_cycle(vtohz2_t *ctx, float duty_cycle)
Generic sets PWM duty cycle.
vtohz2_cfg_t::pwm
pin_name_t pwm
Definition: vtohz2.h:135
vtohz2_t::pwm
pwm_t pwm
Definition: vtohz2.h:120
vtohz2_pwm_stop
void vtohz2_pwm_stop(vtohz2_t *ctx)
Stop PWM module.
vtohz2_cfg_t::en
pin_name_t en
Definition: vtohz2.h:139
vtohz2_enable
void vtohz2_enable(vtohz2_t *ctx, uint8_t state)
Enable function.
vtohz2_cfg_setup
void vtohz2_cfg_setup(vtohz2_cfg_t *cfg)
Config Object Initialization function.
vtohz2_t
Click ctx object definition.
Definition: vtohz2.h:108
vtohz2_t::en
digital_out_t en
Definition: vtohz2.h:112
vtohz2_init
VTOHZ2_RETVAL vtohz2_init(vtohz2_t *ctx, vtohz2_cfg_t *cfg)
Initialization function.
vtohz2_cfg_t
Click configuration structure definition.
Definition: vtohz2.h:132
vtohz2_t::fo
digital_in_t fo
Definition: vtohz2.h:116
vtohz2_get_freq_out
uint8_t vtohz2_get_freq_out(vtohz2_t *ctx)
Frequency Out Get function.
vtohz2_cfg_t::dev_pwm_freq
uint32_t dev_pwm_freq
Definition: vtohz2.h:144
vtohz2_t::pwm_freq
uint32_t pwm_freq
Definition: vtohz2.h:124
vtohz2_default_cfg
void vtohz2_default_cfg(vtohz2_t *ctx)
Click Default Configuration function.
VTOHZ2_RETVAL
#define VTOHZ2_RETVAL
Definition: vtohz2.h:76