hallcurrent10  2.0.0.0
hallcurrent10.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 HALLCURRENT10_H
29 #define HALLCURRENT10_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_digital_out.h"
46 #include "drv_digital_in.h"
47 #include "drv_i2c_master.h"
48 
70 #define HALLCURRENT10_SET_DEV_ADDR 0x4D
71  // hallcurrent10_set
73 
88 #define HALLCURRENT10_MAP_MIKROBUS( cfg, mikrobus ) \
89  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
90  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA )
91  // hallcurrent10_map // hallcurrent10
94 
99 typedef struct
100 {
101  // Modules
102  i2c_master_t i2c;
104  // I2C slave address
105  uint8_t slave_address;
108 
113 typedef struct
114 {
115  pin_name_t scl;
116  pin_name_t sda;
118  uint32_t i2c_speed;
119  uint8_t i2c_address;
122 
127 typedef enum
128 {
131 
133 
150 
166 
181 
195 err_t hallcurrent10_read_adc ( hallcurrent10_t *ctx, uint16_t *read_adc );
196 
210 err_t hallcurrent10_get_adc_voltage ( hallcurrent10_t *ctx, float *adc_vtg );
211 
225 err_t hallcurrent10_get_current ( hallcurrent10_t *ctx, float *current );
226 
227 #ifdef __cplusplus
228 }
229 #endif
230 #endif // HALLCURRENT10_H
231  // hallcurrent10
233 
234 // ------------------------------------------------------------------------ END
hallcurrent10_get_current
err_t hallcurrent10_get_current(hallcurrent10_t *ctx, float *current)
Hall Current 10 get current function.
hallcurrent10_return_value_t
hallcurrent10_return_value_t
Hall Current 10 Click return value data.
Definition: hallcurrent10.h:128
hallcurrent10_cfg_t::i2c_address
uint8_t i2c_address
Definition: hallcurrent10.h:119
hallcurrent10_read_adc
err_t hallcurrent10_read_adc(hallcurrent10_t *ctx, uint16_t *read_adc)
Hall Current 10 I2C ADC reading function.
hallcurrent10_cfg_setup
void hallcurrent10_cfg_setup(hallcurrent10_cfg_t *cfg)
Hall Current 10 configuration object setup function.
hallcurrent10_get_adc_voltage
err_t hallcurrent10_get_adc_voltage(hallcurrent10_t *ctx, float *adc_vtg)
Hall Current 10 get ADC voltage function.
hallcurrent10_cfg_t
Hall Current 10 Click configuration object.
Definition: hallcurrent10.h:114
hallcurrent10_cfg_t::sda
pin_name_t sda
Definition: hallcurrent10.h:116
hallcurrent10_init
err_t hallcurrent10_init(hallcurrent10_t *ctx, hallcurrent10_cfg_t *cfg)
Hall Current 10 initialization function.
hallcurrent10_t::i2c
i2c_master_t i2c
Definition: hallcurrent10.h:102
hallcurrent10_cfg_t::scl
pin_name_t scl
Definition: hallcurrent10.h:115
hallcurrent10_t
Hall Current 10 Click context object.
Definition: hallcurrent10.h:100
hallcurrent10_t::slave_address
uint8_t slave_address
Definition: hallcurrent10.h:105
hallcurrent10_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: hallcurrent10.h:118
HALLCURRENT10_OK
@ HALLCURRENT10_OK
Definition: hallcurrent10.h:129
HALLCURRENT10_ERROR
@ HALLCURRENT10_ERROR
Definition: hallcurrent10.h:130
hallcurrent10_default_cfg
err_t hallcurrent10_default_cfg(hallcurrent10_t *ctx)
Hall Current 10 default configuration function.