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
35#include "drv_i2c_master.h"
36#include "drv_analog_in.h"
37
59#define HALLCURRENT11_SET_DEV_ADDR 0x4D
60 // hallcurrent11_set
62
77#define HALLCURRENT11_MAP_MIKROBUS( cfg, mikrobus ) \
78 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
79 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
80 cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN )
81
82 // hallcurrent11_map // hallcurrent11
85
90typedef enum
91{
96
101typedef err_t ( *hallcurrent11_master_io_t )( struct hallcurrent11_s*, uint16_t* );
102
107typedef struct hallcurrent11_s
108{
109 analog_in_t adc;
111 i2c_master_t i2c;
120
125typedef struct
126{
127 pin_name_t an;
129 analog_in_resolution_t resolution;
130 float vref;
132 pin_name_t scl;
133 pin_name_t sda;
135 uint32_t i2c_speed;
136 uint8_t i2c_address;
141
146typedef enum
147{
150
152
171
189
206
221err_t hallcurrent11_get_adc ( hallcurrent11_t *ctx, uint16_t *data_out );
222
237err_t hallcurrent11_get_adc_voltage ( hallcurrent11_t *ctx, float *adc_vtg );
238
253err_t hallcurrent11_get_current ( hallcurrent11_t *ctx, float *current );
254
271
272#ifdef __cplusplus
273}
274#endif
275#endif // HALLCURRENT11_H
276 // hallcurrent11
278
279// ------------------------------------------------------------------------ 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:101
hallcurrent11_drv_t
Hall Current 11 Click driver selector.
Definition: hallcurrent11.h:91
@ HALLCURRENT11_DRV_SEL_AN
Definition: hallcurrent11.h:92
@ HALLCURRENT11_DRV_SEL_I2C
Definition: hallcurrent11.h:93
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:147
@ HALLCURRENT11_ERROR
Definition: hallcurrent11.h:149
@ HALLCURRENT11_OK
Definition: hallcurrent11.h:148
Hall Current 11 Click configuration object.
Definition: hallcurrent11.h:126
analog_in_resolution_t resolution
Definition: hallcurrent11.h:129
hallcurrent11_drv_t drv_sel
Definition: hallcurrent11.h:138
float vref
Definition: hallcurrent11.h:130
uint32_t i2c_speed
Definition: hallcurrent11.h:135
pin_name_t scl
Definition: hallcurrent11.h:132
pin_name_t sda
Definition: hallcurrent11.h:133
pin_name_t an
Definition: hallcurrent11.h:127
uint8_t i2c_address
Definition: hallcurrent11.h:136
Hall Current 11 Click context object.
Definition: hallcurrent11.h:108
hallcurrent11_drv_t drv_sel
Definition: hallcurrent11.h:115
i2c_master_t i2c
Definition: hallcurrent11.h:111
hallcurrent11_master_io_t read_adc_f
Definition: hallcurrent11.h:117
uint8_t slave_address
Definition: hallcurrent11.h:113
analog_in_t adc
Definition: hallcurrent11.h:109