hallcurrent5  2.0.0.0
hallcurrent5.h
Go to the documentation of this file.
1 /*
2  * MikroSDK - MikroE Software Development Kit
3  * Copyright© 2020 MikroElektronika d.o.o.
4  *
5  * Permission is hereby granted, free of charge, to any person
6  * obtaining a copy of this software and associated documentation
7  * files (the "Software"), to deal in the Software without restriction,
8  * including without limitation the rights to use, copy, modify, merge,
9  * publish, distribute, sublicense, and/or sell copies of the Software,
10  * and to permit persons to whom the Software is furnished to do so,
11  * subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be
14  * included in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
22  * OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24 
34 #ifndef HALLCURRENT5_H
35 #define HALLCURRENT5_H
36 
37 #include "drv_digital_in.h"
38 #include "drv_analog_in.h"
39 
40 // -------------------------------------------------------------- PUBLIC MACROS
41 
51 #define HALLCURRENT5_MAP_MIKROBUS( cfg, mikrobus ) \
52  cfg.an_pin = MIKROBUS( mikrobus, MIKROBUS_AN ); \
53  cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
54 
60 #define HALLCURRENT5_RETVAL uint8_t
61 
62 #define HALLCURRENT5_OK 0x00
63 #define HALLCURRENT5_INIT_ERROR 0xFF
64  // End group macro
68 // --------------------------------------------------------------- PUBLIC TYPES
77 typedef uint16_t hallcurrent5_data_t;
78 
82 typedef struct
83 {
84  // Input pins
85 
86  digital_in_t int_pin;
87 
88  // Modules
89 
90  analog_in_t adc;
91 
92  uint16_t dev_init_volt;
93 
95 
99 typedef struct
100 {
101  // Communication gpio pins
102 
103  pin_name_t an_pin;
104 
105  // Additional gpio pins
106 
107  pin_name_t int_pin;
108 
109  // static variable
110 
111  analog_in_resolution_t resolution; // Resolution
112  float vref; // VRef
113 
114  uint16_t init_volt;
115 
117  // End types group
119 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
120 
126 #ifdef __cplusplus
127 extern "C"{
128 #endif
129 
139 
149 
159 
169 
170 
179 
188 
197 void hallcurrent5_set_init_voltage ( hallcurrent5_t *ctx, uint16_t voltage );
198 
199 #ifdef __cplusplus
200 }
201 #endif
202 #endif // _HALLCURRENT5_H_
203  // End public_function group
206 
207 // ------------------------------------------------------------------------ END
hallcurrent5_cfg_t::an_pin
pin_name_t an_pin
Definition: hallcurrent5.h:103
hallcurrent5_t::dev_init_volt
uint16_t dev_init_volt
Definition: hallcurrent5.h:92
hallcurrent5_t::adc
analog_in_t adc
Definition: hallcurrent5.h:90
HALLCURRENT5_RETVAL
#define HALLCURRENT5_RETVAL
Definition: hallcurrent5.h:60
hallcurrent5_t::int_pin
digital_in_t int_pin
Definition: hallcurrent5.h:86
hallcurrent5_t
Click ctx object definition.
Definition: hallcurrent5.h:83
hallcurrent5_get_fault
uint8_t hallcurrent5_get_fault(hallcurrent5_t *ctx)
Get ADC fault function.
hallcurrent5_cfg_t::init_volt
uint16_t init_volt
Definition: hallcurrent5.h:114
hallcurrent5_set_init_voltage
void hallcurrent5_set_init_voltage(hallcurrent5_t *ctx, uint16_t voltage)
Get ADC current value function.
hallcurrent5_generic_read_voltage
float hallcurrent5_generic_read_voltage(hallcurrent5_t *ctx)
Generic function for read voltage.
hallcurrent5_generic_read
hallcurrent5_data_t hallcurrent5_generic_read(hallcurrent5_t *ctx)
Generic read function.
hallcurrent5_data_t
uint16_t hallcurrent5_data_t
Analog data type.
Definition: hallcurrent5.h:77
hallcurrent5_cfg_t::int_pin
pin_name_t int_pin
Definition: hallcurrent5.h:107
hallcurrent5_cfg_t::resolution
analog_in_resolution_t resolution
Definition: hallcurrent5.h:111
hallcurrent5_cfg_t::vref
float vref
Definition: hallcurrent5.h:112
hallcurrent5_init
HALLCURRENT5_RETVAL hallcurrent5_init(hallcurrent5_t *ctx, hallcurrent5_cfg_t *cfg)
Initialization function.
hallcurrent5_cfg_setup
void hallcurrent5_cfg_setup(hallcurrent5_cfg_t *cfg)
Config Object Initialization function.
hallcurrent5_get_current
float hallcurrent5_get_current(hallcurrent5_t *ctx)
Get ADC current value function.
hallcurrent5_cfg_t
Click configuration structure definition.
Definition: hallcurrent5.h:100