hallcurrent12 2.0.0.0
hallcurrent12.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 HALLCURRENT12_H
29#define HALLCURRENT12_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_i2c_master.h"
50#include "drv_analog_in.h"
51
68#define HALLCURRENT12_SET_DEV_ADDR 0x4D
69
70 // hallcurrent12_set
71
86#define HALLCURRENT12_MAP_MIKROBUS( cfg, mikrobus ) \
87 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
88 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
89 cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN )
90
91 // hallcurrent12_map
92 // hallcurrent12
93
104
109typedef err_t ( *hallcurrent12_master_io_t )( struct hallcurrent12_s*, float* );
110
130
135typedef struct
136{
137 pin_name_t an;
139 analog_in_resolution_t resolution;
140 float vref;
142 pin_name_t scl;
143 pin_name_t sda;
145 uint32_t i2c_speed;
146 uint8_t i2c_address;
151
162
179
194
208err_t hallcurrent12_get_adc ( hallcurrent12_t *ctx, float *adc_vtg );
209
223err_t hallcurrent12_get_adc_voltage ( hallcurrent12_t *ctx, float *adc_vtg );
224
238err_t hallcurrent12_get_current ( hallcurrent12_t *ctx, float *current );
239
252err_t hallcurrent12_get_pin_voltage ( hallcurrent12_t *ctx, float *adc_vtg );
253
265
266#ifdef __cplusplus
267}
268#endif
269#endif // HALLCURRENT12_H
270
271 // hallcurrent12
272
273// ------------------------------------------------------------------------ END
err_t hallcurrent12_init(hallcurrent12_t *ctx, hallcurrent12_cfg_t *cfg)
Hall Current 12 initialization function.
err_t hallcurrent12_get_adc(hallcurrent12_t *ctx, float *adc_vtg)
Hall Current 12 get ADC function.
err_t hallcurrent12_get_pin_voltage(hallcurrent12_t *ctx, float *adc_vtg)
Hall Current 12 read AN pin voltage level function.
err_t hallcurrent12_calibration(hallcurrent12_t *ctx)
Hall Current 12 calibration function.
err_t hallcurrent12_get_adc_voltage(hallcurrent12_t *ctx, float *adc_vtg)
Hall Current 12 get ADC voltage function.
err_t hallcurrent12_get_current(hallcurrent12_t *ctx, float *current)
Hall Current 12 get current function.
void hallcurrent12_cfg_setup(hallcurrent12_cfg_t *cfg)
Hall Current 12 configuration object setup function.
struct hallcurrent12_s hallcurrent12_t
Hall Current 12 Click context object.
hallcurrent12_return_value_t
Hall Current 12 Click return value data.
Definition hallcurrent12.h:157
@ HALLCURRENT12_ERROR
Definition hallcurrent12.h:159
@ HALLCURRENT12_OK
Definition hallcurrent12.h:158
err_t(* hallcurrent12_master_io_t)(struct hallcurrent12_s *, float *)
Hall Current 12 Click driver interface.
Definition hallcurrent12.h:109
hallcurrent12_drv_t
Hall Current 12 Click driver selector.
Definition hallcurrent12.h:99
@ HALLCURRENT12_DRV_SEL_I2C
Definition hallcurrent12.h:101
@ HALLCURRENT12_DRV_SEL_AN
Definition hallcurrent12.h:100
Hall Current 12 Click configuration object.
Definition hallcurrent12.h:136
analog_in_resolution_t resolution
Definition hallcurrent12.h:139
float vref
Definition hallcurrent12.h:140
hallcurrent12_drv_t drv_sel
Definition hallcurrent12.h:148
uint32_t i2c_speed
Definition hallcurrent12.h:145
pin_name_t scl
Definition hallcurrent12.h:142
pin_name_t sda
Definition hallcurrent12.h:143
pin_name_t an
Definition hallcurrent12.h:137
uint8_t i2c_address
Definition hallcurrent12.h:146
Hall Current 12 Click context object.
Definition hallcurrent12.h:116
float offset
Definition hallcurrent12.h:127
hallcurrent12_drv_t drv_sel
Definition hallcurrent12.h:123
hallcurrent12_master_io_t read_adc_f
Definition hallcurrent12.h:125
i2c_master_t i2c
Definition hallcurrent12.h:119
uint8_t slave_address
Definition hallcurrent12.h:121
analog_in_t adc
Definition hallcurrent12.h:117