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
32extern "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 HALLCURRENT19_SENSITIVITY_V_TO_A 0.1
70#define HALLCURRENT19_ZERO_CURRENT_OFFSET 0.5
71#define HALLCURRENT19_NUM_CONVERSIONS 1000
72#define HALLCURRENT19_OUTPUT_VOLTAGE 3.0f
73
78#define HALLCURRENT19_OCD_ACTIVE 0
79#define HALLCURRENT19_OCD_INACTIVE 1
80 // hallcurrent19_set
82
97#define HALLCURRENT19_MAP_MIKROBUS( cfg, mikrobus ) \
98 cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN ); \
99 cfg.oc2 = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
100 cfg.oc1 = MIKROBUS( mikrobus, MIKROBUS_INT )
101 // hallcurrent19_map // hallcurrent19
104
109typedef struct
110{
111 digital_in_t oc2;
112 digital_in_t oc1;
114 analog_in_t adc;
116 float zero_vref;
119
124typedef struct
125{
126 pin_name_t an;
127 pin_name_t oc2;
128 pin_name_t oc1;
130 analog_in_resolution_t resolution;
131 float vref;
134
139typedef enum
140{
143
145
162
177
191
203err_t hallcurrent19_read_an_pin_value ( hallcurrent19_t *ctx, uint16_t *data_out );
204
218err_t hallcurrent19_read_voltage ( hallcurrent19_t *ctx, float *data_out );
219
232
245
258
271err_t hallcurrent19_get_current ( hallcurrent19_t *ctx, float *current );
272
273#ifdef __cplusplus
274}
275#endif
276#endif // HALLCURRENT19_H
277 // hallcurrent19
279
280// ------------------------------------------------------------------------ END
err_t hallcurrent19_init(hallcurrent19_t *ctx, hallcurrent19_cfg_t *cfg)
Hall Current 19 initialization function.
uint8_t hallcurrent19_get_oc1(hallcurrent19_t *ctx)
Hall Current 19 get over current detection 1 state function.
err_t hallcurrent19_read_voltage(hallcurrent19_t *ctx, float *data_out)
Hall Current 19 read AN pin voltage level function.
uint8_t hallcurrent19_get_oc2(hallcurrent19_t *ctx)
Hall Current 19 get over current detection 2 state function.
void hallcurrent19_cfg_setup(hallcurrent19_cfg_t *cfg)
Hall Current 19 configuration object setup function.
err_t hallcurrent19_set_zero_ref(hallcurrent19_t *ctx)
Hall Current 19 set zero reference function.
err_t hallcurrent19_get_current(hallcurrent19_t *ctx, float *current)
Hall Current 19 get current function.
err_t hallcurrent19_default_cfg(hallcurrent19_t *ctx)
Hall Current 19 default configuration function.
err_t hallcurrent19_read_an_pin_value(hallcurrent19_t *ctx, uint16_t *data_out)
Hall Current 19 read AN pin value function.
hallcurrent19_return_value_t
Hall Current 19 Click return value data.
Definition: hallcurrent19.h:140
@ HALLCURRENT19_OK
Definition: hallcurrent19.h:141
@ HALLCURRENT19_ERROR
Definition: hallcurrent19.h:142
Hall Current 19 Click configuration object.
Definition: hallcurrent19.h:125
analog_in_resolution_t resolution
Definition: hallcurrent19.h:130
float vref
Definition: hallcurrent19.h:131
pin_name_t oc2
Definition: hallcurrent19.h:127
pin_name_t oc1
Definition: hallcurrent19.h:128
pin_name_t an
Definition: hallcurrent19.h:126
Hall Current 19 Click context object.
Definition: hallcurrent19.h:110
float zero_vref
Definition: hallcurrent19.h:116
digital_in_t oc1
Definition: hallcurrent19.h:112
digital_in_t oc2
Definition: hallcurrent19.h:111
analog_in_t adc
Definition: hallcurrent19.h:114