hallcurrent4  2.0.0.0
hallcurrent4.h
Go to the documentation of this file.
1 /*
2  * MikroSDK - MikroE Software Development Kit
3  * Copyright (c) 2019, MikroElektronika - www.mikroe.com
4  * All rights reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  */
24 
33 // ----------------------------------------------------------------------------
34 
35 #ifndef HALLCURRENT4_H
36 #define HALLCURRENT4_H
37 
38 #include "drv_digital_out.h"
39 #include "drv_digital_in.h"
40 #include "drv_i2c_master.h"
41 
42 
43 // -------------------------------------------------------------- PUBLIC MACROS
53 #define HALLCURRENT4_MAP_MIKROBUS( cfg, mikrobus ) \
54  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
55  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
56  //cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN ); \
57  //cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
58  //cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
59  //cfg.pwm = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
60  //cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT );
61 
67 #define HALLCURRENT4_RETVAL uint8_t
68 
69 #define HALLCURRENT4_OK 0x00
70 #define HALLCURRENT4_INIT_ERROR 0xFF
71 
77 #define HALLCURRENT4_DEVICE_SLAVE_ADDRESS 0x4D
78  // End group macro
81 // --------------------------------------------------------------- PUBLIC TYPES
90 typedef struct
91 {
92  // Modules
93 
94  i2c_master_t i2c;
95 
96  // ctx variable
97 
98  hal_i2c_address_t slave_address;
99 
101 
105 typedef struct
106 {
107  // Communication gpio pins
108 
109  pin_name_t scl;
110  pin_name_t sda;
111 
112  // static variable
113 
114  hal_i2c_speed_t i2c_speed;
115  hal_i2c_address_t i2c_address;
116 
118  // End types group
120 
121 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
122 
128 #ifdef __cplusplus
129 extern "C"{
130 #endif
131 
141 
150 
161 void hallcurrent4_generic_write ( hallcurrent4_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
162 
174 void hallcurrent4_generic_read ( hallcurrent4_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
175 
185 uint16_t hallcurrent4_get_raw_data ( hallcurrent4_t *ctx );
186 
194 
195 #ifdef __cplusplus
196 }
197 #endif
198 #endif // _HALLCURRENT4_H_
199  // End public_function group
202 
203 // ------------------------------------------------------------------------- END
hallcurrent4_get_current_data
float hallcurrent4_get_current_data(hallcurrent4_t *ctx)
Reads current in mA.
HALLCURRENT4_RETVAL
#define HALLCURRENT4_RETVAL
Definition: hallcurrent4.h:67
hallcurrent4_cfg_t::i2c_address
hal_i2c_address_t i2c_address
Definition: hallcurrent4.h:115
hallcurrent4_cfg_setup
void hallcurrent4_cfg_setup(hallcurrent4_cfg_t *cfg)
Config Object Initialization function.
hallcurrent4_cfg_t::scl
pin_name_t scl
Definition: hallcurrent4.h:109
hallcurrent4_generic_read
void hallcurrent4_generic_read(hallcurrent4_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
hallcurrent4_t::i2c
i2c_master_t i2c
Definition: hallcurrent4.h:94
hallcurrent4_cfg_t::i2c_speed
hal_i2c_speed_t i2c_speed
Definition: hallcurrent4.h:114
hallcurrent4_cfg_t::sda
pin_name_t sda
Definition: hallcurrent4.h:110
hallcurrent4_init
HALLCURRENT4_RETVAL hallcurrent4_init(hallcurrent4_t *ctx, hallcurrent4_cfg_t *cfg)
Initialization function.
hallcurrent4_generic_write
void hallcurrent4_generic_write(hallcurrent4_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
hallcurrent4_t::slave_address
hal_i2c_address_t slave_address
Definition: hallcurrent4.h:98
hallcurrent4_cfg_t
Click configuration structure definition.
Definition: hallcurrent4.h:105
hallcurrent4_get_raw_data
uint16_t hallcurrent4_get_raw_data(hallcurrent4_t *ctx)
Reads raw (ADC) current data.
hallcurrent4_t
Click ctx object definition.
Definition: hallcurrent4.h:90