hallcurrent7 2.0.0.0
hallcurrent7.h
Go to the documentation of this file.
1/****************************************************************************
2** Copyright (C) 2021 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 HALLCURRENT7_H
29#define HALLCURRENT7_H
30
31#ifdef __cplusplus
32extern "C"{
33#endif
34
35#include "drv_digital_out.h"
36#include "drv_digital_in.h"
37#include "drv_i2c_master.h"
38
59#define HALLCURRENT7_RESOLUTION 4096
60#define HALLCURRENT7_12_BIT_DATA 0x0FFF
61#define HALLCURRENT7_ADC_NUM_OF_MEASURE 100.0
62#define HALLCURRENT7_VREF_5000_mV 5000.0
63
64#define HALLCURRENT7_ACS770LCB_050B_SENS 0.04
65
66#define HALLCURRENT7_ERR_COR_FACTOR 1.05
67
73#define HALLCURRENT7_SET_DEV_ADDR 0x4D
74 // hallcurrent7_set
76
91#define HALLCURRENT7_MAP_MIKROBUS( cfg, mikrobus ) \
92 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
93 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA )
94 // hallcurrent7_map // hallcurrent7
97
102typedef struct
103{
104 // Modules
105 i2c_master_t i2c;
107 // I2C slave address
111
116typedef struct
117{
118 pin_name_t scl;
119 pin_name_t sda;
121 uint32_t i2c_speed;
122 uint8_t i2c_address;
125
130typedef enum
131{
134
136
153
168
183err_t hallcurrent7_generic_write ( hallcurrent7_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len );
184
199err_t hallcurrent7_generic_read ( hallcurrent7_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len );
200
209
218uint16_t hallcurrent7_read_voltage ( hallcurrent7_t *ctx, uint16_t v_ref );
219
228int16_t hallcurrent7_calc_current ( hallcurrent7_t *ctx, uint16_t v_ref );
229
238int16_t hallcurrent7_avg_current ( hallcurrent7_t *ctx, uint16_t v_ref );
239
240#ifdef __cplusplus
241}
242#endif
243#endif // HALLCURRENT7_H
244 // hallcurrent7
246
247// ------------------------------------------------------------------------ END
uint16_t hallcurrent7_read_voltage(hallcurrent7_t *ctx, uint16_t v_ref)
Read voltage function.
uint16_t hallcurrent7_read_data(hallcurrent7_t *ctx)
Read data function.
err_t hallcurrent7_generic_read(hallcurrent7_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len)
Hall Current 7 I2C reading function.
void hallcurrent7_cfg_setup(hallcurrent7_cfg_t *cfg)
Hall Current 7 configuration object setup function.
err_t hallcurrent7_generic_write(hallcurrent7_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len)
Hall Current 7 I2C writing function.
int16_t hallcurrent7_avg_current(hallcurrent7_t *ctx, uint16_t v_ref)
Calculate Average current function.
int16_t hallcurrent7_calc_current(hallcurrent7_t *ctx, uint16_t v_ref)
Calculate current function.
err_t hallcurrent7_init(hallcurrent7_t *ctx, hallcurrent7_cfg_t *cfg)
Hall Current 7 initialization function.
hallcurrent7_return_value_t
Hall Current 7 Click return value data.
Definition: hallcurrent7.h:131
@ HALLCURRENT7_OK
Definition: hallcurrent7.h:132
@ HALLCURRENT7_ERROR
Definition: hallcurrent7.h:133
Hall Current 7 Click configuration object.
Definition: hallcurrent7.h:117
uint32_t i2c_speed
Definition: hallcurrent7.h:121
pin_name_t scl
Definition: hallcurrent7.h:118
pin_name_t sda
Definition: hallcurrent7.h:119
uint8_t i2c_address
Definition: hallcurrent7.h:122
Hall Current 7 Click context object.
Definition: hallcurrent7.h:103
i2c_master_t i2c
Definition: hallcurrent7.h:105
uint8_t slave_address
Definition: hallcurrent7.h:108