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 
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 VTOHZ_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 VTOHZ_RETVAL uint8_t
77 
78 #define VTOHZ_OK 0x00
79 #define VTOHZ_INIT_ERROR 0xFF
80 
86 #define VTOHZ_DEF_FREQ 50000
87  // End group macro
90 // --------------------------------------------------------------- PUBLIC TYPES
99 typedef struct
100 {
101 
102  // Output pins
103 
104  digital_out_t en;
105 
106 
107  // Input pins
108 
109  digital_in_t fo;
110 
111  // Modules
112 
113  pwm_t pwm;
114 
115  // ctx variable
116 
117  uint32_t pwm_freq;
118 
119 } vtohz_t;
120 
124 typedef struct
125 {
126  // Communication gpio pins
127 
128  pin_name_t pwm;
129 
130  // Additional gpio pins
131 
132  pin_name_t en;
133  pin_name_t fo;
134 
135  // static variable
136 
137  uint32_t dev_pwm_freq;
138 
139 } vtohz_cfg_t;
140  // End types group
142 
143 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
144 
150 #ifdef __cplusplus
151 extern "C"{
152 #endif
153 
163 
172 
182 void vtohz_set_duty_cycle ( vtohz_t *ctx, float duty_cycle );
183 
191 void vtohz_pwm_stop ( vtohz_t *ctx );
192 
200 void vtohz_pwm_start ( vtohz_t *ctx );
201 
209 void vtohz_enable ( vtohz_t *ctx );
210 
211 #ifdef __cplusplus
212 }
213 #endif
214 #endif // _VTOHZ_H_
215  // End public_function group
218 
219 // ------------------------------------------------------------------------- END
vtohz_cfg_t
Click configuration structure definition.
Definition: vtohz.h:125
vtohz_cfg_t::dev_pwm_freq
uint32_t dev_pwm_freq
Definition: vtohz.h:137
vtohz_t::en
digital_out_t en
Definition: vtohz.h:104
VTOHZ_RETVAL
#define VTOHZ_RETVAL
Definition: vtohz.h:76
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:132
vtohz_cfg_t::pwm
pin_name_t pwm
Definition: vtohz.h:128
vtohz_enable
void vtohz_enable(vtohz_t *ctx)
Enable the click module.
vtohz_cfg_t::fo
pin_name_t fo
Definition: vtohz.h:133
vtohz_t::pwm
pwm_t pwm
Definition: vtohz.h:113
vtohz_pwm_stop
void vtohz_pwm_stop(vtohz_t *ctx)
Stop PWM module.
vtohz_t::pwm_freq
uint32_t pwm_freq
Definition: vtohz.h:117
vtohz_init
VTOHZ_RETVAL vtohz_init(vtohz_t *ctx, vtohz_cfg_t *cfg)
Initialization function.
vtohz_t
Click ctx object definition.
Definition: vtohz.h:100
vtohz_pwm_start
void vtohz_pwm_start(vtohz_t *ctx)
Start PWM module.
vtohz_t::fo
digital_in_t fo
Definition: vtohz.h:109
vtohz_cfg_setup
void vtohz_cfg_setup(vtohz_cfg_t *cfg)
Config Object Initialization function.