angle10 2.1.0.0
angle10.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 ANGLE10_H
29#define ANGLE10_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_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_analog_in.h"
52
73#define ANGLE10_FULL_CIRCLE 360.0
74#define ANGLE10_NUM_CONVERSIONS 50
75
80#define ANGLE10_VREF_3V3 3.3
81#define ANGLE10_VREF_5V 5.0
82
83 // angle10_set
84
99#define ANGLE10_MAP_MIKROBUS( cfg, mikrobus ) \
100 cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN );
101
102 // angle10_map
103 // angle10
104
109typedef struct
110{
111 analog_in_t adc;
113 float vref;
115} angle10_t;
116
121typedef struct
122{
123 pin_name_t an;
125 analog_in_resolution_t resolution;
126 float vref;
129
134typedef enum
135{
137 ANGLE10_ERROR = -1
138
140
157
172
184err_t angle10_read_raw_adc ( angle10_t *ctx, uint16_t *raw_adc );
185
197err_t angle10_read_voltage ( angle10_t *ctx, float *voltage );
198
210err_t angle10_set_vref ( angle10_t *ctx, float vref );
211
224err_t angle10_get_angle ( angle10_t *ctx, float *angle );
225
226#ifdef __cplusplus
227}
228#endif
229#endif // ANGLE10_H
230
231 // angle10
232
233// ------------------------------------------------------------------------ END
angle10_return_value_t
Angle 10 Click return value data.
Definition angle10.h:135
@ ANGLE10_ERROR
Definition angle10.h:137
@ ANGLE10_OK
Definition angle10.h:136
err_t angle10_read_raw_adc(angle10_t *ctx, uint16_t *raw_adc)
Angle 10 read raw ADC value function.
err_t angle10_init(angle10_t *ctx, angle10_cfg_t *cfg)
Angle 10 initialization function.
err_t angle10_set_vref(angle10_t *ctx, float vref)
Angle 10 set vref function.
void angle10_cfg_setup(angle10_cfg_t *cfg)
Angle 10 configuration object setup function.
err_t angle10_get_angle(angle10_t *ctx, float *angle)
Angle 10 get angle function.
err_t angle10_read_voltage(angle10_t *ctx, float *voltage)
Angle 10 read voltage level function.
Angle 10 Click configuration object.
Definition angle10.h:122
analog_in_resolution_t resolution
Definition angle10.h:125
float vref
Definition angle10.h:126
pin_name_t an
Definition angle10.h:123
Angle 10 Click context object.
Definition angle10.h:110
float vref
Definition angle10.h:113
analog_in_t adc
Definition angle10.h:111