hallcurrent12  2.0.0.0
hallcurrent12.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 HALLCURRENT12_H
29 #define HALLCURRENT12_H
30 
31 #ifdef __cplusplus
32 extern "C"{
33 #endif
34 
35 #include "drv_i2c_master.h"
36 #include "drv_analog_in.h"
37 
54 #define HALLCURRENT12_SET_DEV_ADDR 0x4D
55  // hallcurrent12_set
57 
72 #define HALLCURRENT12_MAP_MIKROBUS( cfg, mikrobus ) \
73  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
74  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
75  cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN )
76  // hallcurrent12_map // hallcurrent12
79 
84 typedef enum
85 {
90 
95 typedef err_t ( *hallcurrent12_master_io_t )( struct hallcurrent12_s*, uint16_t* );
96 
101 typedef struct hallcurrent12_s
102 {
103  analog_in_t adc;
105  i2c_master_t i2c;
107  uint8_t slave_address;
113  int16_t offset;
116 
121 typedef struct
122 {
123  pin_name_t an;
125  analog_in_resolution_t resolution;
126  float vref;
128  pin_name_t scl;
129  pin_name_t sda;
131  uint32_t i2c_speed;
132  uint8_t i2c_address;
134  hallcurrent12_drv_t drv_sel;
136  int16_t adc_offset;
139 
144 typedef enum
145 {
148 
150 
169 
187 
204 
221 err_t hallcurrent12_get_adc ( hallcurrent12_t *ctx, uint16_t *data_out );
222 
239 err_t hallcurrent12_get_adc_voltage ( hallcurrent12_t *ctx, float *adc_vtg );
240 
257 err_t hallcurrent12_get_current ( hallcurrent12_t *ctx, float *current );
258 
274 err_t hallcurrent12_read_an_pin_voltage ( hallcurrent12_t *ctx, float *data_out );
275 
276 #ifdef __cplusplus
277 }
278 #endif
279 #endif // HALLCURRENT12_H
280  // hallcurrent12
282 
283 // ------------------------------------------------------------------------ END
hallcurrent12_cfg_t
Hall Current 12 Click configuration object.
Definition: hallcurrent12.h:120
hallcurrent12_master_io_t
err_t(* hallcurrent12_master_io_t)(struct hallcurrent12_s *, uint16_t *)
Hall Current 12 Click driver interface.
Definition: hallcurrent12.h:94
hallcurrent12_init
err_t hallcurrent12_init(hallcurrent12_t *ctx, hallcurrent12_cfg_t *cfg)
Hall Current 12 initialization function.
HALLCURRENT12_DRV_SEL_I2C
Definition: hallcurrent12.h:86
hallcurrent12_t
struct hallcurrent12_s hallcurrent12_t
Hall Current 12 Click context object.
hallcurrent12_s::slave_address
uint8_t slave_address
Definition: hallcurrent12.h:106
hallcurrent12_s::drv_sel
hallcurrent12_drv_t drv_sel
Definition: hallcurrent12.h:108
hallcurrent12_s::adc
analog_in_t adc
Definition: hallcurrent12.h:102
HALLCURRENT12_ERROR
Definition: hallcurrent12.h:146
HALLCURRENT12_OK
Definition: hallcurrent12.h:145
hallcurrent12_return_value_t
hallcurrent12_return_value_t
Hall Current 12 Click return value data.
Definition: hallcurrent12.h:143
hallcurrent12_cfg_setup
void hallcurrent12_cfg_setup(hallcurrent12_cfg_t *cfg)
Hall Current 12 configuration object setup function.
hallcurrent12_s::i2c
i2c_master_t i2c
Definition: hallcurrent12.h:104
hallcurrent12_drv_t
hallcurrent12_drv_t
Hall Current 12 Click driver selector.
Definition: hallcurrent12.h:83
hallcurrent12_get_adc
err_t hallcurrent12_get_adc(hallcurrent12_t *ctx, uint16_t *data_out)
Hall Current 12 get ADC function.
hallcurrent12_s::read_adc_f
hallcurrent12_master_io_t read_adc_f
Definition: hallcurrent12.h:110
HALLCURRENT12_DRV_SEL_AN
Definition: hallcurrent12.h:85
hallcurrent12_s
Hall Current 12 Click context object.
Definition: hallcurrent12.h:100
hallcurrent12_get_current
err_t hallcurrent12_get_current(hallcurrent12_t *ctx, float *current)
Hall Current 12 get current function.
hallcurrent12_read_an_pin_voltage
err_t hallcurrent12_read_an_pin_voltage(hallcurrent12_t *ctx, float *data_out)
Hall Current 12 read AN pin voltage level function.
hallcurrent12_s::offset
int16_t offset
Definition: hallcurrent12.h:112
hallcurrent12_default_cfg
err_t hallcurrent12_default_cfg(hallcurrent12_t *ctx)
Hall Current 12 default configuration function.
hallcurrent12_get_adc_voltage
err_t hallcurrent12_get_adc_voltage(hallcurrent12_t *ctx, float *adc_vtg)
Hall Current 12 get ADC voltage function.