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
32 extern "C"{
33 #endif
34 
35 #include "mikrosdk_version.h"
36 
37 #ifdef __GNUC__
38 #if mikroSDK_GET_VERSION < 20800ul
39 #include "rcu_delays.h"
40 #else
41 #include "delays.h"
42 #endif
43 #endif
44 
45 #include "drv_i2c_master.h"
46 #include "drv_analog_in.h"
47 
69 #define HALLCURRENT11_SET_DEV_ADDR 0x4D
70  // hallcurrent11_set
72 
87 #define HALLCURRENT11_MAP_MIKROBUS( cfg, mikrobus ) \
88  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
89  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
90  cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN )
91 
92  // hallcurrent11_map // hallcurrent11
95 
100 typedef enum
101 {
106 
111 typedef err_t ( *hallcurrent11_master_io_t )( struct hallcurrent11_s*, uint16_t* );
112 
117 typedef struct hallcurrent11_s
118 {
119  analog_in_t adc;
121  i2c_master_t i2c;
123  uint8_t slave_address;
130 
135 typedef 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 
156 typedef enum
157 {
160 
162 
181 
199 
216 
231 err_t hallcurrent11_get_adc ( hallcurrent11_t *ctx, uint16_t *data_out );
232 
247 err_t hallcurrent11_get_adc_voltage ( hallcurrent11_t *ctx, float *adc_vtg );
248 
263 err_t hallcurrent11_get_current ( hallcurrent11_t *ctx, float *current );
264 
280 err_t hallcurrent11_read_an_pin_voltage ( hallcurrent11_t *ctx, float *data_out );
281 
282 #ifdef __cplusplus
283 }
284 #endif
285 #endif // HALLCURRENT11_H
286  // hallcurrent11
288 
289 // ------------------------------------------------------------------------ END
hallcurrent11_s
Hall Current 11 Click context object.
Definition: hallcurrent11.h:118
hallcurrent11_s::drv_sel
hallcurrent11_drv_t drv_sel
Definition: hallcurrent11.h:125
hallcurrent11_s::i2c
i2c_master_t i2c
Definition: hallcurrent11.h:121
hallcurrent11_cfg_t::an
pin_name_t an
Definition: hallcurrent11.h:137
hallcurrent11_s::read_adc_f
hallcurrent11_master_io_t read_adc_f
Definition: hallcurrent11.h:127
hallcurrent11_cfg_t::i2c_address
uint8_t i2c_address
Definition: hallcurrent11.h:146
hallcurrent11_get_current
err_t hallcurrent11_get_current(hallcurrent11_t *ctx, float *current)
Hall Current 11 get current function.
hallcurrent11_cfg_t
Hall Current 11 Click configuration object.
Definition: hallcurrent11.h:136
hallcurrent11_return_value_t
hallcurrent11_return_value_t
Hall Current 11 Click return value data.
Definition: hallcurrent11.h:157
HALLCURRENT11_DRV_SEL_I2C
@ HALLCURRENT11_DRV_SEL_I2C
Definition: hallcurrent11.h:103
HALLCURRENT11_OK
@ HALLCURRENT11_OK
Definition: hallcurrent11.h:158
hallcurrent11_init
err_t hallcurrent11_init(hallcurrent11_t *ctx, hallcurrent11_cfg_t *cfg)
Hall Current 11 initialization function.
hallcurrent11_default_cfg
err_t hallcurrent11_default_cfg(hallcurrent11_t *ctx)
Hall Current 11 default configuration function.
hallcurrent11_get_adc
err_t hallcurrent11_get_adc(hallcurrent11_t *ctx, uint16_t *data_out)
Hall Current 11 ADC reading function.
hallcurrent11_s::slave_address
uint8_t slave_address
Definition: hallcurrent11.h:123
hallcurrent11_cfg_t::vref
float vref
Definition: hallcurrent11.h:140
HALLCURRENT11_DRV_SEL_AN
@ HALLCURRENT11_DRV_SEL_AN
Definition: hallcurrent11.h:102
hallcurrent11_cfg_t::scl
pin_name_t scl
Definition: hallcurrent11.h:142
hallcurrent11_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: hallcurrent11.h:145
hallcurrent11_cfg_setup
void hallcurrent11_cfg_setup(hallcurrent11_cfg_t *cfg)
Hall Current 11 configuration object setup function.
hallcurrent11_s::adc
analog_in_t adc
Definition: hallcurrent11.h:119
hallcurrent11_cfg_t::resolution
analog_in_resolution_t resolution
Definition: hallcurrent11.h:139
hallcurrent11_master_io_t
err_t(* hallcurrent11_master_io_t)(struct hallcurrent11_s *, uint16_t *)
Hall Current 11 Click driver interface.
Definition: hallcurrent11.h:111
HALLCURRENT11_ERROR
@ HALLCURRENT11_ERROR
Definition: hallcurrent11.h:159
hallcurrent11_cfg_t::drv_sel
hallcurrent11_drv_t drv_sel
Definition: hallcurrent11.h:148
hallcurrent11_read_an_pin_voltage
err_t hallcurrent11_read_an_pin_voltage(hallcurrent11_t *ctx, float *data_out)
Hall Current 11 read AN pin voltage level function.
hallcurrent11_drv_t
hallcurrent11_drv_t
Hall Current 11 Click driver selector.
Definition: hallcurrent11.h:101
hallcurrent11_cfg_t::sda
pin_name_t sda
Definition: hallcurrent11.h:143
hallcurrent11_get_adc_voltage
err_t hallcurrent11_get_adc_voltage(hallcurrent11_t *ctx, float *adc_vtg)
Hall Current 11 get ADC voltage function.
hallcurrent11_t
struct hallcurrent11_s hallcurrent11_t
Hall Current 11 Click context object.