hydrogen 2.0.0.0
hydrogen.h
Go to the documentation of this file.
1/****************************************************************************
2** Copyright (C) 2020 MikroElektronika d.o.o.
3** Contact: https://www.mikroe.com/contact
4**
5** Permission is hereby granted, free of charge, to any person obtaining a copy
6** of this software and associated documentation files (the "Software"), to deal
7** in the Software without restriction, including without limitation the rights
8** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9** copies of the Software, and to permit persons to whom the Software is
10** furnished to do so, subject to the following conditions:
11** The above copyright notice and this permission notice shall be
12** included in all copies or substantial portions of the Software.
13**
14** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20** USE OR OTHER DEALINGS IN THE SOFTWARE.
21****************************************************************************/
22
28#ifndef HYDROGEN_H
29#define HYDROGEN_H
30
31#ifdef __cplusplus
32extern "C"{
33#endif
34
39#ifdef PREINIT_SUPPORTED
40#include "preinit.h"
41#endif
42
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
45 #include "delays.h"
46 #endif
47#endif
48
49#include "drv_analog_in.h"
50
71// TODO -- dodati makroe koji definisu adrese registara
72
73 // hydrogen_reg
74
89// TODO -- dodati makroe koji definisu komande/vrednosti koje se upisuju u registre
90
91 // hydrogen_set
92
107#define HYDROGEN_MAP_MIKROBUS( cfg, mikrobus ) \
108 cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN ); \
109
110 // hydrogen_map
111 // hydrogen
112
117typedef struct
118{
119 analog_in_t adc;
121} hydrogen_t;
122
127typedef struct
128{
129 pin_name_t an;
131 // static variable
132 analog_in_resolution_t resolution;
133 float vref;
136
141typedef enum
142{
144 HYDROGEN_ERROR = -1
145
147
164
180
193err_t hydrogen_read_an_pin_value ( hydrogen_t *ctx, uint16_t *data_out );
194
209err_t hydrogen_read_an_pin_voltage ( hydrogen_t *ctx, float *data_out );
210
211#ifdef __cplusplus
212}
213#endif
214#endif // HYDROGEN_H
215
216 // hydrogen
217
218// ------------------------------------------------------------------------ END
err_t hydrogen_read_an_pin_voltage(hydrogen_t *ctx, float *data_out)
Hydrogen read AN pin voltage level function.
err_t hydrogen_init(hydrogen_t *ctx, hydrogen_cfg_t *cfg)
Hydrogen initialization function.
void hydrogen_cfg_setup(hydrogen_cfg_t *cfg)
Hydrogen configuration object setup function.
err_t hydrogen_read_an_pin_value(hydrogen_t *ctx, uint16_t *data_out)
Hydrogen read AN pin value function.
hydrogen_return_value_t
Hydrogen Click return value data.
Definition hydrogen.h:142
@ HYDROGEN_ERROR
Definition hydrogen.h:144
@ HYDROGEN_OK
Definition hydrogen.h:143
Hydrogen Click configuration object.
Definition hydrogen.h:128
analog_in_resolution_t resolution
Definition hydrogen.h:132
float vref
Definition hydrogen.h:133
pin_name_t an
Definition hydrogen.h:129
Hydrogen Click context object.
Definition hydrogen.h:118
analog_in_t adc
Definition hydrogen.h:119