hallcurrent11 2.0.0.0
hallcurrent11.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 HALLCURRENT11_H
29#define HALLCURRENT11_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
73#define HALLCURRENT11_SET_DEV_ADDR 0x4D
74
75 // hallcurrent11_set
76
91#define HALLCURRENT11_MAP_MIKROBUS( cfg, mikrobus ) \
92 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
93 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
94 cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN )
95
96
97 // hallcurrent11_map
98 // hallcurrent11
99
110
115typedef err_t ( *hallcurrent11_master_io_t )( struct hallcurrent11_s*, uint16_t* );
116
134
139typedef struct
140{
141 pin_name_t an;
143 analog_in_resolution_t resolution;
144 float vref;
146 pin_name_t scl;
147 pin_name_t sda;
149 uint32_t i2c_speed;
150 uint8_t i2c_address;
155
166
185
203
220
235err_t hallcurrent11_get_adc ( hallcurrent11_t *ctx, uint16_t *data_out );
236
251err_t hallcurrent11_get_adc_voltage ( hallcurrent11_t *ctx, float *adc_vtg );
252
267err_t hallcurrent11_get_current ( hallcurrent11_t *ctx, float *current );
268
285
286#ifdef __cplusplus
287}
288#endif
289#endif // HALLCURRENT11_H
290
291 // hallcurrent11
292
293// ------------------------------------------------------------------------ END
err_t hallcurrent11_read_an_pin_voltage(hallcurrent11_t *ctx, float *data_out)
Hall Current 11 read AN pin voltage level function.
err_t hallcurrent11_default_cfg(hallcurrent11_t *ctx)
Hall Current 11 default configuration function.
void hallcurrent11_cfg_setup(hallcurrent11_cfg_t *cfg)
Hall Current 11 configuration object setup function.
err_t hallcurrent11_get_adc_voltage(hallcurrent11_t *ctx, float *adc_vtg)
Hall Current 11 get ADC voltage function.
err_t hallcurrent11_get_adc(hallcurrent11_t *ctx, uint16_t *data_out)
Hall Current 11 ADC reading function.
err_t hallcurrent11_get_current(hallcurrent11_t *ctx, float *current)
Hall Current 11 get current function.
err_t hallcurrent11_init(hallcurrent11_t *ctx, hallcurrent11_cfg_t *cfg)
Hall Current 11 initialization function.
err_t(* hallcurrent11_master_io_t)(struct hallcurrent11_s *, uint16_t *)
Hall Current 11 Click driver interface.
Definition hallcurrent11.h:115
hallcurrent11_drv_t
Hall Current 11 Click driver selector.
Definition hallcurrent11.h:105
@ HALLCURRENT11_DRV_SEL_AN
Definition hallcurrent11.h:106
@ HALLCURRENT11_DRV_SEL_I2C
Definition hallcurrent11.h:107
struct hallcurrent11_s hallcurrent11_t
Hall Current 11 Click context object.
hallcurrent11_return_value_t
Hall Current 11 Click return value data.
Definition hallcurrent11.h:161
@ HALLCURRENT11_ERROR
Definition hallcurrent11.h:163
@ HALLCURRENT11_OK
Definition hallcurrent11.h:162
Hall Current 11 Click configuration object.
Definition hallcurrent11.h:140
analog_in_resolution_t resolution
Definition hallcurrent11.h:143
hallcurrent11_drv_t drv_sel
Definition hallcurrent11.h:152
float vref
Definition hallcurrent11.h:144
uint32_t i2c_speed
Definition hallcurrent11.h:149
pin_name_t scl
Definition hallcurrent11.h:146
pin_name_t sda
Definition hallcurrent11.h:147
pin_name_t an
Definition hallcurrent11.h:141
uint8_t i2c_address
Definition hallcurrent11.h:150
Hall Current 11 Click context object.
Definition hallcurrent11.h:122
hallcurrent11_drv_t drv_sel
Definition hallcurrent11.h:129
i2c_master_t i2c
Definition hallcurrent11.h:125
hallcurrent11_master_io_t read_adc_f
Definition hallcurrent11.h:131
uint8_t slave_address
Definition hallcurrent11.h:127
analog_in_t adc
Definition hallcurrent11.h:123