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 
38 #include "mikrosdk_version.h"
39 
40 #ifdef __GNUC__
41 #if mikroSDK_GET_VERSION < 20800ul
42 #include "rcu_delays.h"
43 #else
44 #include "delays.h"
45 #endif
46 #endif
47 
48 #include "drv_digital_out.h"
49 #include "drv_digital_in.h"
50 #include "drv_pwm.h"
51 
52 // -------------------------------------------------------------- PUBLIC MACROS
62 #define VTOHZ2_MAP_MIKROBUS( cfg, mikrobus ) \
63  cfg.pwm = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
64  cfg.en = MIKROBUS( mikrobus, MIKROBUS_CS ); \
65  cfg.fo = MIKROBUS( mikrobus, MIKROBUS_INT )
66 
72 #define VTOHZ2_RETVAL uint8_t
73 
74 #define VTOHZ2_OK 0x00
75 #define VTOHZ2_INIT_ERROR 0xFF
76 
82 #define VTOHZ2_ENABLE 1
83 #define VTOHZ2_DISABLE 0
84 
90 #define VTOHZ2_DEF_FREQ 20000
91  // End group macro
94 // --------------------------------------------------------------- PUBLIC TYPES
103 typedef struct
104 {
105 
106  // Output pins
107 
108  digital_out_t en;
109 
110  // Input pins
111 
112  digital_in_t fo;
113 
114  // Modules
115 
116  pwm_t pwm;
117 
118  // ctx variable
119 
120  uint32_t pwm_freq;
121 
122 } vtohz2_t;
123 
127 typedef struct
128 {
129  // Communication gpio pins
130 
131  pin_name_t pwm;
132 
133  // Additional gpio pins
134 
135  pin_name_t en;
136  pin_name_t fo;
137 
138  // static variable
139 
140  uint32_t dev_pwm_freq;
141 
142 } vtohz2_cfg_t;
143  // End types group
145 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
146 
152 #ifdef __cplusplus
153 extern "C"{
154 #endif
155 
165 
174 
183 
193 void vtohz2_set_duty_cycle ( vtohz2_t *ctx, float duty_cycle );
194 
202 void vtohz2_pwm_stop ( vtohz2_t *ctx );
203 
212 
225 void vtohz2_enable ( vtohz2_t *ctx, uint8_t state );
226 
236 uint8_t vtohz2_get_freq_out ( vtohz2_t *ctx );
237 
238 #ifdef __cplusplus
239 }
240 #endif
241 #endif // _VTOHZ2_H_
242  // End public_function group
245 
246 // ------------------------------------------------------------------------- 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:136
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:131
vtohz2_t::pwm
pwm_t pwm
Definition: vtohz2.h:116
vtohz2_pwm_stop
void vtohz2_pwm_stop(vtohz2_t *ctx)
Stop PWM module.
vtohz2_cfg_t::en
pin_name_t en
Definition: vtohz2.h:135
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:104
vtohz2_t::en
digital_out_t en
Definition: vtohz2.h:108
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:128
vtohz2_t::fo
digital_in_t fo
Definition: vtohz2.h:112
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:140
vtohz2_t::pwm_freq
uint32_t pwm_freq
Definition: vtohz2.h:120
vtohz2_default_cfg
void vtohz2_default_cfg(vtohz2_t *ctx)
Click Default Configuration function.
VTOHZ2_RETVAL
#define VTOHZ2_RETVAL
Definition: vtohz2.h:72