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 "drv_digital_out.h"
36 #include "drv_digital_in.h"
37 #include "drv_analog_in.h"
38 
59 #define ANGLE10_FULL_CIRCLE 360.0
60 #define ANGLE10_NUM_CONVERSIONS 50
61 
66 #define ANGLE10_VREF_3V3 3.3
67 #define ANGLE10_VREF_5V 5.0
68  // angle10_set
70 
85 #define ANGLE10_MAP_MIKROBUS( cfg, mikrobus ) \
86  cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN );
87  // angle10_map // angle10
90 
95 typedef struct
96 {
97  analog_in_t adc;
99  float vref;
101 } angle10_t;
102 
107 typedef struct
108 {
109  pin_name_t an;
111  analog_in_resolution_t resolution;
112  float vref;
114 } angle10_cfg_t;
115 
120 typedef enum
121 {
123  ANGLE10_ERROR = -1
124 
126 
143 
157 err_t angle10_init ( angle10_t *ctx, angle10_cfg_t *cfg );
158 
170 err_t angle10_read_raw_adc ( angle10_t *ctx, uint16_t *raw_adc );
171 
183 err_t angle10_read_voltage ( angle10_t *ctx, float *voltage );
184 
196 err_t angle10_set_vref ( angle10_t *ctx, float vref );
197 
210 err_t angle10_get_angle ( angle10_t *ctx, float *angle );
211 
212 #ifdef __cplusplus
213 }
214 #endif
215 #endif // ANGLE10_H
216  // angle10
218 
219 // ------------------------------------------------------------------------ END
angle10_cfg_t
Angle 10 Click configuration object.
Definition: angle10.h:108
angle10_cfg_t::vref
float vref
Definition: angle10.h:112
angle10_return_value_t
angle10_return_value_t
Angle 10 Click return value data.
Definition: angle10.h:121
angle10_cfg_t::an
pin_name_t an
Definition: angle10.h:109
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:111
ANGLE10_ERROR
@ ANGLE10_ERROR
Definition: angle10.h:123
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:99
angle10_t::adc
analog_in_t adc
Definition: angle10.h:97
ANGLE10_OK
@ ANGLE10_OK
Definition: angle10.h:122
angle10_t
Angle 10 Click context object.
Definition: angle10.h:96
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.