hallcurrent9  2.0.0.0
hallcurrent9.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 HALLCURRENT9_H
29 #define HALLCURRENT9_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 
80 #define HALLCURRENT9_SET_DEV_ADDR 0x4D
81  // hallcurrent9_set
83 
98 #define HALLCURRENT9_MAP_MIKROBUS( cfg, mikrobus ) \
99  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
100  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
101  cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN )
102  // hallcurrent9_map // hallcurrent9
105 
110 typedef struct
111 {
112  // Input pins
113 
114  digital_in_t an;
116  // Modules
117 
118  i2c_master_t i2c;
120  // I2C slave address
121 
122  uint8_t slave_address;
125 
130 typedef struct
131 {
132  pin_name_t scl;
133  pin_name_t sda;
135  pin_name_t an;
137  uint32_t i2c_speed;
138  uint8_t i2c_address;
141 
146 typedef struct
147 {
148  uint16_t zero_adc_val;
149 
151 
156 typedef enum
157 {
159  HALLCURRENT9_ERROR = -1
160 
162 
181 
199 
215 err_t hallcurrent9_read_adc ( hallcurrent9_t *ctx, uint16_t *read_adc );
216 
232 
248 
249 #ifdef __cplusplus
250 }
251 #endif
252 #endif // HALLCURRENT9_H
253  // hallcurrent9
255 
256 // ------------------------------------------------------------------------ END
hallcurrent9_t::an
digital_in_t an
Definition: hallcurrent9.h:114
hallcurrent9_cfg_t::i2c_address
uint8_t i2c_address
Definition: hallcurrent9.h:138
hallcurrent9_t
Hall Current 9 Click context object.
Definition: hallcurrent9.h:111
hallcurrent9_t::slave_address
uint8_t slave_address
Definition: hallcurrent9.h:122
hallcurrent9_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: hallcurrent9.h:137
HALLCURRENT9_ERROR
@ HALLCURRENT9_ERROR
Definition: hallcurrent9.h:159
hallcurrent9_cfg_t::sda
pin_name_t sda
Definition: hallcurrent9.h:133
hallcurrent9_set_calibration
err_t hallcurrent9_set_calibration(hallcurrent9_t *ctx, hallcurrent9_calibration_data_t *adc_val)
Hall Current 9 set calibration function.
hallcurrent9_init
err_t hallcurrent9_init(hallcurrent9_t *ctx, hallcurrent9_cfg_t *cfg)
Hall Current 9 initialization function.
hallcurrent9_return_value_t
hallcurrent9_return_value_t
Hall Current 9 Click return value data.
Definition: hallcurrent9.h:157
hallcurrent9_cfg_t::scl
pin_name_t scl
Definition: hallcurrent9.h:132
hallcurrent9_read_adc
err_t hallcurrent9_read_adc(hallcurrent9_t *ctx, uint16_t *read_adc)
Hall Current 9 I2C ADC reading function.
hallcurrent9_cfg_setup
void hallcurrent9_cfg_setup(hallcurrent9_cfg_t *cfg)
Hall Current 9 configuration object setup function.
hallcurrent9_cfg_t::an
pin_name_t an
Definition: hallcurrent9.h:135
hallcurrent9_calibration_data_t::zero_adc_val
uint16_t zero_adc_val
Definition: hallcurrent9.h:148
HALLCURRENT9_OK
@ HALLCURRENT9_OK
Definition: hallcurrent9.h:158
hallcurrent9_cfg_t
Hall Current 9 Click configuration object.
Definition: hallcurrent9.h:131
hallcurrent9_t::i2c
i2c_master_t i2c
Definition: hallcurrent9.h:118
hallcurrent9_calibration_data_t
Hall Current 9 Click calibration object.
Definition: hallcurrent9.h:147
hallcurrent9_get_current
float hallcurrent9_get_current(hallcurrent9_t *ctx, hallcurrent9_calibration_data_t *adc_val)
Hall Current 9 get current function.