vtohz  2.0.0.0
vtohz.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 VTOHZ_H
36 #define VTOHZ_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 VTOHZ_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 VTOHZ_RETVAL uint8_t
63 
64 #define VTOHZ_OK 0x00
65 #define VTOHZ_INIT_ERROR 0xFF
66 
72 #define VTOHZ_DEF_FREQ 50000
73  // End group macro
76 // --------------------------------------------------------------- PUBLIC TYPES
85 typedef struct
86 {
87 
88  // Output pins
89 
90  digital_out_t en;
91 
92 
93  // Input pins
94 
95  digital_in_t fo;
96 
97  // Modules
98 
99  pwm_t pwm;
100 
101  // ctx variable
102 
103  uint32_t pwm_freq;
104 
105 } vtohz_t;
106 
110 typedef struct
111 {
112  // Communication gpio pins
113 
114  pin_name_t pwm;
115 
116  // Additional gpio pins
117 
118  pin_name_t en;
119  pin_name_t fo;
120 
121  // static variable
122 
123  uint32_t dev_pwm_freq;
124 
125 } vtohz_cfg_t;
126  // End types group
128 
129 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
130 
136 #ifdef __cplusplus
137 extern "C"{
138 #endif
139 
148 void vtohz_cfg_setup ( vtohz_cfg_t *cfg );
149 
158 
168 void vtohz_set_duty_cycle ( vtohz_t *ctx, float duty_cycle );
169 
177 void vtohz_pwm_stop ( vtohz_t *ctx );
178 
186 void vtohz_pwm_start ( vtohz_t *ctx );
187 
195 void vtohz_enable ( vtohz_t *ctx );
196 
197 #ifdef __cplusplus
198 }
199 #endif
200 #endif // _VTOHZ_H_
201  // End public_function group
204 
205 // ------------------------------------------------------------------------- END
vtohz_cfg_t
Click configuration structure definition.
Definition: vtohz.h:110
vtohz_cfg_t::dev_pwm_freq
uint32_t dev_pwm_freq
Definition: vtohz.h:123
vtohz_t::en
digital_out_t en
Definition: vtohz.h:90
VTOHZ_RETVAL
#define VTOHZ_RETVAL
Definition: vtohz.h:62
vtohz_set_duty_cycle
void vtohz_set_duty_cycle(vtohz_t *ctx, float duty_cycle)
Generic sets PWM duty cycle.
vtohz_cfg_t::en
pin_name_t en
Definition: vtohz.h:118
vtohz_cfg_t::pwm
pin_name_t pwm
Definition: vtohz.h:114
vtohz_enable
void vtohz_enable(vtohz_t *ctx)
Enable the click module.
vtohz_cfg_t::fo
pin_name_t fo
Definition: vtohz.h:119
vtohz_t::pwm
pwm_t pwm
Definition: vtohz.h:99
vtohz_pwm_stop
void vtohz_pwm_stop(vtohz_t *ctx)
Stop PWM module.
vtohz_t::pwm_freq
uint32_t pwm_freq
Definition: vtohz.h:103
vtohz_init
VTOHZ_RETVAL vtohz_init(vtohz_t *ctx, vtohz_cfg_t *cfg)
Initialization function.
vtohz_t
Click ctx object definition.
Definition: vtohz.h:85
vtohz_pwm_start
void vtohz_pwm_start(vtohz_t *ctx)
Start PWM module.
vtohz_t::fo
digital_in_t fo
Definition: vtohz.h:95
vtohz_cfg_setup
void vtohz_cfg_setup(vtohz_cfg_t *cfg)
Config Object Initialization function.