hztov2 2.0.0.0
hztov2.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
35#ifndef HZTOV2_H
36#define HZTOV2_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_analog_in.h"
55#include "drv_pwm.h"
56
57// -------------------------------------------------------------- PUBLIC MACROS
58
68#define HZTOV2_MAP_MIKROBUS( cfg, mikrobus ) \
69 cfg.an_pin = MIKROBUS( mikrobus, MIKROBUS_AN ); \
70 cfg.en = MIKROBUS( mikrobus, MIKROBUS_CS ); \
71 cfg.fin = MIKROBUS( mikrobus, MIKROBUS_PWM )
78#define HZTOV2_RETVAL uint8_t
79
80#define HZTOV2_OK 0x00
81#define HZTOV2_INIT_ERROR 0xFF
88#define HZTOV2_DEF_FREQ 10000
91 // End group macro
92// --------------------------------------------------------------- PUBLIC TYPES
101typedef uint16_t hztov2_data_t;
102
106typedef struct
107{
108 // Output pins
109
110 digital_out_t en;
111
112 // Modules
113
114 pwm_t fin;
115 analog_in_t adc;
116
117 // ctx variable
118
119 uint32_t pwm_freq;
120
121} hztov2_t;
122
126typedef struct
127{
128 // Communication gpio pins
129
130 pin_name_t an_pin;
131 pin_name_t fin;
132
133 // Additional gpio pins
134
135 pin_name_t en;
136
137 // static variable
138
139 analog_in_resolution_t resolution; // Resolution
140 float vref; // VRef
141 uint32_t dev_pwm_freq;
142
144
145 // End types group
146// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
147
153#ifdef __cplusplus
154extern "C"{
155#endif
156
166
176
186
196
205void hztov2_en_pin ( hztov2_t *ctx, uint8_t pin_state );
206
217HZTOV2_RETVAL hztov2_fin_set ( hztov2_t *ctx, uint32_t fin );
218
219#ifdef __cplusplus
220}
221#endif
222#endif // _HZTOV2_H_
223
224 // End public_function group
226
227// ------------------------------------------------------------------------ END
#define HZTOV2_RETVAL
Definition hztov2.h:78
hztov2_data_t hztov2_generic_read(hztov2_t *ctx)
Generic read function.
void hztov2_cfg_setup(hztov2_cfg_t *cfg)
Config Object Initialization function.
float hztov2_read_voltage(hztov2_t *ctx)
Read voltage function.
HZTOV2_RETVAL hztov2_fin_set(hztov2_t *ctx, uint32_t fin)
PWM frequency set function.
HZTOV2_RETVAL hztov2_init(hztov2_t *ctx, hztov2_cfg_t *cfg)
Initialization function.
void hztov2_en_pin(hztov2_t *ctx, uint8_t pin_state)
Function for enabling the click board.
uint16_t hztov2_data_t
Analog data type.
Definition hztov2.h:101
Click configuration structure definition.
Definition hztov2.h:127
analog_in_resolution_t resolution
Definition hztov2.h:139
float vref
Definition hztov2.h:140
pin_name_t an_pin
Definition hztov2.h:130
uint32_t dev_pwm_freq
Definition hztov2.h:141
pin_name_t en
Definition hztov2.h:135
pin_name_t fin
Definition hztov2.h:131
Click ctx object definition.
Definition hztov2.h:107
uint32_t pwm_freq
Definition hztov2.h:119
pwm_t fin
Definition hztov2.h:114
digital_out_t en
Definition hztov2.h:110
analog_in_t adc
Definition hztov2.h:115