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 
41 #ifdef PREINIT_SUPPORTED
42 #include "preinit.h"
43 #endif
44 
45 #ifdef MikroCCoreVersion
46  #if MikroCCoreVersion >= 1
47  #include "delays.h"
48  #endif
49 #endif
50 
51 #include "drv_digital_in.h"
52 #include "drv_analog_in.h"
53 
54 // -------------------------------------------------------------- PUBLIC MACROS
55 
65 #define HALLCURRENT5_MAP_MIKROBUS( cfg, mikrobus ) \
66  cfg.an_pin = MIKROBUS( mikrobus, MIKROBUS_AN ); \
67  cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
68 
74 #define HALLCURRENT5_RETVAL uint8_t
75 
76 #define HALLCURRENT5_OK 0x00
77 #define HALLCURRENT5_INIT_ERROR 0xFF
78  // End group macro
82 // --------------------------------------------------------------- PUBLIC TYPES
91 typedef uint16_t hallcurrent5_data_t;
92 
96 typedef struct
97 {
98  // Input pins
99 
100  digital_in_t int_pin;
101 
102  // Modules
103 
104  analog_in_t adc;
105 
106  uint16_t dev_init_volt;
107 
109 
113 typedef struct
114 {
115  // Communication gpio pins
116 
117  pin_name_t an_pin;
118 
119  // Additional gpio pins
120 
121  pin_name_t int_pin;
122 
123  // static variable
124 
125  analog_in_resolution_t resolution; // Resolution
126  float vref; // VRef
127 
128  uint16_t init_volt;
129 
131  // End types group
133 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
134 
140 #ifdef __cplusplus
141 extern "C"{
142 #endif
143 
153 
163 
173 
183 
184 
193 
202 
211 void hallcurrent5_set_init_voltage ( hallcurrent5_t *ctx, uint16_t voltage );
212 
213 #ifdef __cplusplus
214 }
215 #endif
216 #endif // _HALLCURRENT5_H_
217  // End public_function group
220 
221 // ------------------------------------------------------------------------ END
hallcurrent5_cfg_t::an_pin
pin_name_t an_pin
Definition: hallcurrent5.h:117
hallcurrent5_t::dev_init_volt
uint16_t dev_init_volt
Definition: hallcurrent5.h:106
hallcurrent5_t::adc
analog_in_t adc
Definition: hallcurrent5.h:104
HALLCURRENT5_RETVAL
#define HALLCURRENT5_RETVAL
Definition: hallcurrent5.h:74
hallcurrent5_t::int_pin
digital_in_t int_pin
Definition: hallcurrent5.h:100
hallcurrent5_t
Click ctx object definition.
Definition: hallcurrent5.h:97
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:128
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:91
hallcurrent5_cfg_t::int_pin
pin_name_t int_pin
Definition: hallcurrent5.h:121
hallcurrent5_cfg_t::resolution
analog_in_resolution_t resolution
Definition: hallcurrent5.h:125
hallcurrent5_cfg_t::vref
float vref
Definition: hallcurrent5.h:126
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:114