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
35#include "drv_digital_out.h"
36#include "drv_digital_in.h"
37#include "drv_analog_in.h"
38#include "drv_i2c_master.h"
39
60#define HALLCURRENT13_SENSITIVITY_V_TO_A 0.1
61#define HALLCURRENT13_ZERO_CURRENT_OFFSET 0.1
62#define HALLCURRENT13_NUM_CONVERSIONS 100
63
68#define HALLCURRENT13_ADC_RESOLUTION 0x0FFF
69#define HALLCURRENT13_VREF_3V3 3.3
70#define HALLCURRENT13_VREF_5V 5.0
71
77#define HALLCURRENT13_SET_DEV_ADDR 0x4D
78 // hallcurrent13_set
80
95#define HALLCURRENT13_MAP_MIKROBUS( cfg, mikrobus ) \
96 cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN ); \
97 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
98 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA );
99 // hallcurrent13_map // hallcurrent13
102
107typedef enum
108{
113
118typedef struct
119{
120 analog_in_t adc;
121 i2c_master_t i2c;
124 pin_name_t chip_select;
125 float vref;
129
134typedef struct
135{
136 pin_name_t an;
137 pin_name_t scl;
138 pin_name_t sda;
140 analog_in_resolution_t resolution;
141 float vref;
143 uint32_t i2c_speed;
144 uint8_t i2c_address;
149
154typedef enum
155{
158
160
177
193
209
222err_t hallcurrent13_read_raw_adc ( hallcurrent13_t *ctx, uint16_t *raw_adc );
223
236err_t hallcurrent13_read_voltage ( hallcurrent13_t *ctx, float *voltage );
237
250err_t hallcurrent13_set_vref ( hallcurrent13_t *ctx, float vref );
251
265err_t hallcurrent13_read_current ( hallcurrent13_t *ctx, float *current );
266
267#ifdef __cplusplus
268}
269#endif
270#endif // HALLCURRENT13_H
271 // hallcurrent13
273
274// ------------------------------------------------------------------------ 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:155
@ HALLCURRENT13_OK
Definition: hallcurrent13.h:156
@ HALLCURRENT13_ERROR
Definition: hallcurrent13.h:157
hallcurrent13_drv_t
Hall Current 13 Click driver selector.
Definition: hallcurrent13.h:108
@ HALLCURRENT13_DRV_SEL_I2C
Definition: hallcurrent13.h:110
@ HALLCURRENT13_DRV_SEL_ADC
Definition: hallcurrent13.h:109
Hall Current 13 Click configuration object.
Definition: hallcurrent13.h:135
analog_in_resolution_t resolution
Definition: hallcurrent13.h:140
float vref
Definition: hallcurrent13.h:141
uint32_t i2c_speed
Definition: hallcurrent13.h:143
pin_name_t scl
Definition: hallcurrent13.h:137
hallcurrent13_drv_t drv_sel
Definition: hallcurrent13.h:146
pin_name_t sda
Definition: hallcurrent13.h:138
pin_name_t an
Definition: hallcurrent13.h:136
uint8_t i2c_address
Definition: hallcurrent13.h:144
Hall Current 13 Click context object.
Definition: hallcurrent13.h:119
float vref
Definition: hallcurrent13.h:125
i2c_master_t i2c
Definition: hallcurrent13.h:121
uint8_t slave_address
Definition: hallcurrent13.h:123
hallcurrent13_drv_t drv_sel
Definition: hallcurrent13.h:126
pin_name_t chip_select
Definition: hallcurrent13.h:124
analog_in_t adc
Definition: hallcurrent13.h:120