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
32 extern "C"{
33 #endif
34 
35 #include "mikrosdk_version.h"
36 
37 #ifdef __GNUC__
38 #if mikroSDK_GET_VERSION < 20800ul
39 #include "rcu_delays.h"
40 #else
41 #include "delays.h"
42 #endif
43 #endif
44 
45 #include "drv_digital_out.h"
46 #include "drv_digital_in.h"
47 #include "drv_analog_in.h"
48 
69 #define ANGLE10_FULL_CIRCLE 360.0
70 #define ANGLE10_NUM_CONVERSIONS 50
71 
76 #define ANGLE10_VREF_3V3 3.3
77 #define ANGLE10_VREF_5V 5.0
78  // angle10_set
80 
95 #define ANGLE10_MAP_MIKROBUS( cfg, mikrobus ) \
96  cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN );
97  // angle10_map // angle10
100 
105 typedef struct
106 {
107  analog_in_t adc;
109  float vref;
111 } angle10_t;
112 
117 typedef struct
118 {
119  pin_name_t an;
121  analog_in_resolution_t resolution;
122  float vref;
124 } angle10_cfg_t;
125 
130 typedef enum
131 {
133  ANGLE10_ERROR = -1
134 
136 
153 
167 err_t angle10_init ( angle10_t *ctx, angle10_cfg_t *cfg );
168 
180 err_t angle10_read_raw_adc ( angle10_t *ctx, uint16_t *raw_adc );
181 
193 err_t angle10_read_voltage ( angle10_t *ctx, float *voltage );
194 
206 err_t angle10_set_vref ( angle10_t *ctx, float vref );
207 
220 err_t angle10_get_angle ( angle10_t *ctx, float *angle );
221 
222 #ifdef __cplusplus
223 }
224 #endif
225 #endif // ANGLE10_H
226  // angle10
228 
229 // ------------------------------------------------------------------------ END
angle10_cfg_t
Angle 10 Click configuration object.
Definition: angle10.h:118
angle10_cfg_t::vref
float vref
Definition: angle10.h:122
angle10_return_value_t
angle10_return_value_t
Angle 10 Click return value data.
Definition: angle10.h:131
angle10_cfg_t::an
pin_name_t an
Definition: angle10.h:119
angle10_set_vref
err_t angle10_set_vref(angle10_t *ctx, float vref)
Angle 10 set vref function.
angle10_cfg_t::resolution
analog_in_resolution_t resolution
Definition: angle10.h:121
ANGLE10_ERROR
@ ANGLE10_ERROR
Definition: angle10.h:133
angle10_get_angle
err_t angle10_get_angle(angle10_t *ctx, float *angle)
Angle 10 get angle function.
angle10_read_voltage
err_t angle10_read_voltage(angle10_t *ctx, float *voltage)
Angle 10 read voltage level function.
angle10_t::vref
float vref
Definition: angle10.h:109
angle10_t::adc
analog_in_t adc
Definition: angle10.h:107
ANGLE10_OK
@ ANGLE10_OK
Definition: angle10.h:132
angle10_t
Angle 10 Click context object.
Definition: angle10.h:106
angle10_read_raw_adc
err_t angle10_read_raw_adc(angle10_t *ctx, uint16_t *raw_adc)
Angle 10 read raw ADC value function.
angle10_cfg_setup
void angle10_cfg_setup(angle10_cfg_t *cfg)
Angle 10 configuration object setup function.
angle10_init
err_t angle10_init(angle10_t *ctx, angle10_cfg_t *cfg)
Angle 10 initialization function.