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 "mikrosdk_version.h"
38 
39 #ifdef __GNUC__
40 #if mikroSDK_GET_VERSION < 20800ul
41 #include "rcu_delays.h"
42 #else
43 #include "delays.h"
44 #endif
45 #endif
46 
47 #include "drv_digital_in.h"
48 #include "drv_analog_in.h"
49 
50 // -------------------------------------------------------------- PUBLIC MACROS
51 
61 #define HALLCURRENT5_MAP_MIKROBUS( cfg, mikrobus ) \
62  cfg.an_pin = MIKROBUS( mikrobus, MIKROBUS_AN ); \
63  cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
64 
70 #define HALLCURRENT5_RETVAL uint8_t
71 
72 #define HALLCURRENT5_OK 0x00
73 #define HALLCURRENT5_INIT_ERROR 0xFF
74  // End group macro
78 // --------------------------------------------------------------- PUBLIC TYPES
87 typedef uint16_t hallcurrent5_data_t;
88 
92 typedef struct
93 {
94  // Input pins
95 
96  digital_in_t int_pin;
97 
98  // Modules
99 
100  analog_in_t adc;
101 
102  uint16_t dev_init_volt;
103 
105 
109 typedef struct
110 {
111  // Communication gpio pins
112 
113  pin_name_t an_pin;
114 
115  // Additional gpio pins
116 
117  pin_name_t int_pin;
118 
119  // static variable
120 
121  analog_in_resolution_t resolution; // Resolution
122  float vref; // VRef
123 
124  uint16_t init_volt;
125 
127  // End types group
129 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
130 
136 #ifdef __cplusplus
137 extern "C"{
138 #endif
139 
149 
159 
169 
179 
180 
189 
198 
207 void hallcurrent5_set_init_voltage ( hallcurrent5_t *ctx, uint16_t voltage );
208 
209 #ifdef __cplusplus
210 }
211 #endif
212 #endif // _HALLCURRENT5_H_
213  // End public_function group
216 
217 // ------------------------------------------------------------------------ END
hallcurrent5_cfg_t::an_pin
pin_name_t an_pin
Definition: hallcurrent5.h:113
hallcurrent5_t::dev_init_volt
uint16_t dev_init_volt
Definition: hallcurrent5.h:102
hallcurrent5_t::adc
analog_in_t adc
Definition: hallcurrent5.h:100
HALLCURRENT5_RETVAL
#define HALLCURRENT5_RETVAL
Definition: hallcurrent5.h:70
hallcurrent5_t::int_pin
digital_in_t int_pin
Definition: hallcurrent5.h:96
hallcurrent5_t
Click ctx object definition.
Definition: hallcurrent5.h:93
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:124
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:87
hallcurrent5_cfg_t::int_pin
pin_name_t int_pin
Definition: hallcurrent5.h:117
hallcurrent5_cfg_t::resolution
analog_in_resolution_t resolution
Definition: hallcurrent5.h:121
hallcurrent5_cfg_t::vref
float vref
Definition: hallcurrent5.h:122
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:110