hallcurrent8120a  2.0.0.0
hallcurrent8120a.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 HALLCURRENT8120A_H
29 #define HALLCURRENT8120A_H
30 
31 #ifdef __cplusplus
32 extern "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 HALLCURRENT8120A_MAP_MIKROBUS( cfg, mikrobus ) \
74  cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN ); \
75  cfg.oc1 = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
76  cfg.oc2 = MIKROBUS( mikrobus, MIKROBUS_INT )
77  // hallcurrent8120a_map // hallcurrent8120a
80 
85 typedef struct
86 {
87  digital_in_t oc1;
88  digital_in_t oc2;
90  analog_in_t adc;
92  float offset;
95 
100 typedef struct
101 {
102  pin_name_t an;
103  pin_name_t oc1;
104  pin_name_t oc2;
106  analog_in_resolution_t resolution;
107  float vref;
110 
115 typedef enum
116 {
119 
121 
138 
154 
167 err_t hallcurrent8120a_read_pin_value ( hallcurrent8120a_t *ctx, uint16_t *data_out );
168 
183 err_t hallcurrent8120a_read_pin_volt ( hallcurrent8120a_t *ctx, float *data_out );
184 
200 
215 err_t hallcurrent8120a_get_voltage ( hallcurrent8120a_t *ctx, float *avr_voltage );
216 
231 err_t hallcurrent8120a_get_current ( hallcurrent8120a_t *ctx, float *current );
232 
247 
262 
263 #ifdef __cplusplus
264 }
265 #endif
266 #endif // HALLCURRENT8120A_H
267  // hallcurrent8120a
269 
270 // ------------------------------------------------------------------------ END
hallcurrent8120a_t::oc2
digital_in_t oc2
Definition: hallcurrent8120a.h:88
hallcurrent8120a_cfg_t::oc1
pin_name_t oc1
Definition: hallcurrent8120a.h:103
hallcurrent8120a_cfg_t
Hall Current 8 120A Click configuration object.
Definition: hallcurrent8120a.h:101
HALLCURRENT8120A_OK
@ HALLCURRENT8120A_OK
Definition: hallcurrent8120a.h:117
hallcurrent8120a_cfg_t::vref
float vref
Definition: hallcurrent8120a.h:107
hallcurrent8120a_cfg_t::an
pin_name_t an
Definition: hallcurrent8120a.h:102
hallcurrent8120a_calibration
err_t hallcurrent8120a_calibration(hallcurrent8120a_t *ctx)
Hall Current 8 120A calibration function.
hallcurrent8120a_get_odc1
uint8_t hallcurrent8120a_get_odc1(hallcurrent8120a_t *ctx)
Hall Current 8 120A get state of OC1 function.
HALLCURRENT8120A_ERROR
@ HALLCURRENT8120A_ERROR
Definition: hallcurrent8120a.h:118
hallcurrent8120a_cfg_t::oc2
pin_name_t oc2
Definition: hallcurrent8120a.h:104
hallcurrent8120a_read_pin_value
err_t hallcurrent8120a_read_pin_value(hallcurrent8120a_t *ctx, uint16_t *data_out)
Hall Current 8 120A read AN pin value function.
hallcurrent8120a_return_value_t
hallcurrent8120a_return_value_t
Hall Current 8 120A Click return value data.
Definition: hallcurrent8120a.h:116
hallcurrent8120a_get_voltage
err_t hallcurrent8120a_get_voltage(hallcurrent8120a_t *ctx, float *avr_voltage)
Hall Current 8 120A read voltage level function.
hallcurrent8120a_t::oc1
digital_in_t oc1
Definition: hallcurrent8120a.h:87
hallcurrent8120a_t
Hall Current 8 120A Click context object.
Definition: hallcurrent8120a.h:86
hallcurrent8120a_cfg_setup
void hallcurrent8120a_cfg_setup(hallcurrent8120a_cfg_t *cfg)
Hall Current 8 120A configuration object setup function.
hallcurrent8120a_t::offset
float offset
Definition: hallcurrent8120a.h:92
hallcurrent8120a_get_current
err_t hallcurrent8120a_get_current(hallcurrent8120a_t *ctx, float *current)
Hall Current 8 120A get current level function.
hallcurrent8120a_cfg_t::resolution
analog_in_resolution_t resolution
Definition: hallcurrent8120a.h:106
hallcurrent8120a_t::adc
analog_in_t adc
Definition: hallcurrent8120a.h:90
hallcurrent8120a_read_pin_volt
err_t hallcurrent8120a_read_pin_volt(hallcurrent8120a_t *ctx, float *data_out)
Hall Current 8 120A read AN pin voltage level function.
hallcurrent8120a_init
err_t hallcurrent8120a_init(hallcurrent8120a_t *ctx, hallcurrent8120a_cfg_t *cfg)
Hall Current 8 120A initialization function.
hallcurrent8120a_get_odc2
uint8_t hallcurrent8120a_get_odc2(hallcurrent8120a_t *ctx)
Hall Current 8 120A get state of OC2 function.