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 "drv_digital_out.h"
39 #include "drv_digital_in.h"
40 #include "drv_pwm.h"
41 
42 // -------------------------------------------------------------- PUBLIC MACROS
52 #define VTOHZ2_MAP_MIKROBUS( cfg, mikrobus ) \
53  cfg.pwm = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
54  cfg.en = MIKROBUS( mikrobus, MIKROBUS_CS ); \
55  cfg.fo = MIKROBUS( mikrobus, MIKROBUS_INT )
56 
62 #define VTOHZ2_RETVAL uint8_t
63 
64 #define VTOHZ2_OK 0x00
65 #define VTOHZ2_INIT_ERROR 0xFF
66 
72 #define VTOHZ2_ENABLE 1
73 #define VTOHZ2_DISABLE 0
74 
80 #define VTOHZ2_DEF_FREQ 20000
81  // End group macro
84 // --------------------------------------------------------------- PUBLIC TYPES
93 typedef struct
94 {
95 
96  // Output pins
97 
98  digital_out_t en;
99 
100  // Input pins
101 
102  digital_in_t fo;
103 
104  // Modules
105 
106  pwm_t pwm;
107 
108  // ctx variable
109 
110  uint32_t pwm_freq;
111 
112 } vtohz2_t;
113 
117 typedef struct
118 {
119  // Communication gpio pins
120 
121  pin_name_t pwm;
122 
123  // Additional gpio pins
124 
125  pin_name_t en;
126  pin_name_t fo;
127 
128  // static variable
129 
130  uint32_t dev_pwm_freq;
131 
132 } vtohz2_cfg_t;
133  // End types group
135 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
136 
142 #ifdef __cplusplus
143 extern "C"{
144 #endif
145 
154 void vtohz2_cfg_setup ( vtohz2_cfg_t *cfg );
155 
164 
172 void vtohz2_default_cfg ( vtohz2_t *ctx );
173 
183 void vtohz2_set_duty_cycle ( vtohz2_t *ctx, float duty_cycle );
184 
192 void vtohz2_pwm_stop ( vtohz2_t *ctx );
193 
201 void vtohz2_pwm_start ( vtohz2_t *ctx );
202 
215 void vtohz2_enable ( vtohz2_t *ctx, uint8_t state );
216 
226 uint8_t vtohz2_get_freq_out ( vtohz2_t *ctx );
227 
228 #ifdef __cplusplus
229 }
230 #endif
231 #endif // _VTOHZ2_H_
232  // End public_function group
235 
236 // ------------------------------------------------------------------------- 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:126
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:121
vtohz2_t::pwm
pwm_t pwm
Definition: vtohz2.h:106
vtohz2_pwm_stop
void vtohz2_pwm_stop(vtohz2_t *ctx)
Stop PWM module.
vtohz2_cfg_t::en
pin_name_t en
Definition: vtohz2.h:125
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:93
vtohz2_t::en
digital_out_t en
Definition: vtohz2.h:98
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:117
vtohz2_t::fo
digital_in_t fo
Definition: vtohz2.h:102
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:130
vtohz2_t::pwm_freq
uint32_t pwm_freq
Definition: vtohz2.h:110
vtohz2_default_cfg
void vtohz2_default_cfg(vtohz2_t *ctx)
Click Default Configuration function.
VTOHZ2_RETVAL
#define VTOHZ2_RETVAL
Definition: vtohz2.h:62