hallcurrent19  2.1.0.0
hallcurrent19.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 HALLCURRENT19_H
29 #define HALLCURRENT19_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 HALLCURRENT19_SENSITIVITY_V_TO_A 0.1
74 #define HALLCURRENT19_ZERO_CURRENT_OFFSET 0.5
75 #define HALLCURRENT19_NUM_CONVERSIONS 1000
76 #define HALLCURRENT19_OUTPUT_VOLTAGE 3.0f
77 
82 #define HALLCURRENT19_OCD_ACTIVE 0
83 #define HALLCURRENT19_OCD_INACTIVE 1
84  // hallcurrent19_set
86 
101 #define HALLCURRENT19_MAP_MIKROBUS( cfg, mikrobus ) \
102  cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN ); \
103  cfg.oc2 = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
104  cfg.oc1 = MIKROBUS( mikrobus, MIKROBUS_INT )
105  // hallcurrent19_map // hallcurrent19
108 
113 typedef struct
114 {
115  digital_in_t oc2;
116  digital_in_t oc1;
118  analog_in_t adc;
120  float zero_vref;
123 
128 typedef struct
129 {
130  pin_name_t an;
131  pin_name_t oc2;
132  pin_name_t oc1;
134  analog_in_resolution_t resolution;
135  float vref;
138 
143 typedef enum
144 {
147 
149 
166 
181 
195 
207 err_t hallcurrent19_read_an_pin_value ( hallcurrent19_t *ctx, uint16_t *data_out );
208 
222 err_t hallcurrent19_read_voltage ( hallcurrent19_t *ctx, float *data_out );
223 
236 
249 
262 
275 err_t hallcurrent19_get_current ( hallcurrent19_t *ctx, float *current );
276 
277 #ifdef __cplusplus
278 }
279 #endif
280 #endif // HALLCURRENT19_H
281  // hallcurrent19
283 
284 // ------------------------------------------------------------------------ END
hallcurrent19_cfg_t::resolution
analog_in_resolution_t resolution
Definition: hallcurrent19.h:134
hallcurrent19_t
Hall Current 19 Click context object.
Definition: hallcurrent19.h:114
hallcurrent19_read_an_pin_value
err_t hallcurrent19_read_an_pin_value(hallcurrent19_t *ctx, uint16_t *data_out)
Hall Current 19 read AN pin value function.
hallcurrent19_cfg_t::oc1
pin_name_t oc1
Definition: hallcurrent19.h:132
hallcurrent19_cfg_t::vref
float vref
Definition: hallcurrent19.h:135
hallcurrent19_return_value_t
hallcurrent19_return_value_t
Hall Current 19 Click return value data.
Definition: hallcurrent19.h:144
hallcurrent19_cfg_t
Hall Current 19 Click configuration object.
Definition: hallcurrent19.h:129
hallcurrent19_cfg_setup
void hallcurrent19_cfg_setup(hallcurrent19_cfg_t *cfg)
Hall Current 19 configuration object setup function.
hallcurrent19_cfg_t::an
pin_name_t an
Definition: hallcurrent19.h:130
hallcurrent19_get_oc1
uint8_t hallcurrent19_get_oc1(hallcurrent19_t *ctx)
Hall Current 19 get over current detection 1 state function.
hallcurrent19_cfg_t::oc2
pin_name_t oc2
Definition: hallcurrent19.h:131
hallcurrent19_t::oc2
digital_in_t oc2
Definition: hallcurrent19.h:115
hallcurrent19_get_current
err_t hallcurrent19_get_current(hallcurrent19_t *ctx, float *current)
Hall Current 19 get current function.
hallcurrent19_set_zero_ref
err_t hallcurrent19_set_zero_ref(hallcurrent19_t *ctx)
Hall Current 19 set zero reference function.
hallcurrent19_t::oc1
digital_in_t oc1
Definition: hallcurrent19.h:116
hallcurrent19_init
err_t hallcurrent19_init(hallcurrent19_t *ctx, hallcurrent19_cfg_t *cfg)
Hall Current 19 initialization function.
hallcurrent19_t::adc
analog_in_t adc
Definition: hallcurrent19.h:118
hallcurrent19_get_oc2
uint8_t hallcurrent19_get_oc2(hallcurrent19_t *ctx)
Hall Current 19 get over current detection 2 state function.
hallcurrent19_t::zero_vref
float zero_vref
Definition: hallcurrent19.h:120
HALLCURRENT19_OK
@ HALLCURRENT19_OK
Definition: hallcurrent19.h:145
hallcurrent19_default_cfg
err_t hallcurrent19_default_cfg(hallcurrent19_t *ctx)
Hall Current 19 default configuration function.
hallcurrent19_read_voltage
err_t hallcurrent19_read_voltage(hallcurrent19_t *ctx, float *data_out)
Hall Current 19 read AN pin voltage level function.
HALLCURRENT19_ERROR
@ HALLCURRENT19_ERROR
Definition: hallcurrent19.h:146