hallcurrent13 2.0.0.0
hallcurrent13.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 HALLCURRENT13_H
29#define HALLCURRENT13_H
30
31#ifdef __cplusplus
32extern "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#include "drv_i2c_master.h"
53
74#define HALLCURRENT13_SENSITIVITY_V_TO_A 0.1
75#define HALLCURRENT13_ZERO_CURRENT_OFFSET 0.1
76#define HALLCURRENT13_NUM_CONVERSIONS 100
77
82#define HALLCURRENT13_ADC_RESOLUTION 0x0FFF
83#define HALLCURRENT13_VREF_3V3 3.3
84#define HALLCURRENT13_VREF_5V 5.0
85
91#define HALLCURRENT13_SET_DEV_ADDR 0x4D
92
93 // hallcurrent13_set
94
109#define HALLCURRENT13_MAP_MIKROBUS( cfg, mikrobus ) \
110 cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN ); \
111 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
112 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA );
113
114 // hallcurrent13_map
115 // hallcurrent13
116
127
132typedef struct
133{
134 analog_in_t adc;
135 i2c_master_t i2c;
138 pin_name_t chip_select;
139 float vref;
143
148typedef struct
149{
150 pin_name_t an;
151 pin_name_t scl;
152 pin_name_t sda;
154 analog_in_resolution_t resolution;
155 float vref;
157 uint32_t i2c_speed;
158 uint8_t i2c_address;
163
174
191
207
223
236err_t hallcurrent13_read_raw_adc ( hallcurrent13_t *ctx, uint16_t *raw_adc );
237
250err_t hallcurrent13_read_voltage ( hallcurrent13_t *ctx, float *voltage );
251
264err_t hallcurrent13_set_vref ( hallcurrent13_t *ctx, float vref );
265
279err_t hallcurrent13_read_current ( hallcurrent13_t *ctx, float *current );
280
281#ifdef __cplusplus
282}
283#endif
284#endif // HALLCURRENT13_H
285
286 // hallcurrent13
287
288// ------------------------------------------------------------------------ END
err_t hallcurrent13_read_raw_adc(hallcurrent13_t *ctx, uint16_t *raw_adc)
Hall Current 13 read raw ADC value function.
err_t hallcurrent13_read_current(hallcurrent13_t *ctx, float *current)
Hall Current 13 read current function.
void hallcurrent13_drv_interface_selection(hallcurrent13_cfg_t *cfg, hallcurrent13_drv_t drv_sel)
Hall Current 13 driver interface setup function.
err_t hallcurrent13_set_vref(hallcurrent13_t *ctx, float vref)
Hall Current 13 set vref function.
void hallcurrent13_cfg_setup(hallcurrent13_cfg_t *cfg)
Hall Current 13 configuration object setup function.
err_t hallcurrent13_init(hallcurrent13_t *ctx, hallcurrent13_cfg_t *cfg)
Hall Current 13 initialization function.
err_t hallcurrent13_read_voltage(hallcurrent13_t *ctx, float *voltage)
Hall Current 13 read voltage level function.
hallcurrent13_return_value_t
Hall Current 13 Click return value data.
Definition hallcurrent13.h:169
@ HALLCURRENT13_OK
Definition hallcurrent13.h:170
@ HALLCURRENT13_ERROR
Definition hallcurrent13.h:171
hallcurrent13_drv_t
Hall Current 13 Click driver selector.
Definition hallcurrent13.h:122
@ HALLCURRENT13_DRV_SEL_I2C
Definition hallcurrent13.h:124
@ HALLCURRENT13_DRV_SEL_ADC
Definition hallcurrent13.h:123
Hall Current 13 Click configuration object.
Definition hallcurrent13.h:149
analog_in_resolution_t resolution
Definition hallcurrent13.h:154
float vref
Definition hallcurrent13.h:155
uint32_t i2c_speed
Definition hallcurrent13.h:157
pin_name_t scl
Definition hallcurrent13.h:151
hallcurrent13_drv_t drv_sel
Definition hallcurrent13.h:160
pin_name_t sda
Definition hallcurrent13.h:152
pin_name_t an
Definition hallcurrent13.h:150
uint8_t i2c_address
Definition hallcurrent13.h:158
Hall Current 13 Click context object.
Definition hallcurrent13.h:133
float vref
Definition hallcurrent13.h:139
i2c_master_t i2c
Definition hallcurrent13.h:135
uint8_t slave_address
Definition hallcurrent13.h:137
hallcurrent13_drv_t drv_sel
Definition hallcurrent13.h:140
pin_name_t chip_select
Definition hallcurrent13.h:138
analog_in_t adc
Definition hallcurrent13.h:134