currentsens2 2.1.0.0
currentsens2.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 CURRENTSENS2_H
29#define CURRENTSENS2_H
30
31#ifdef __cplusplus
32extern "C"{
33#endif
34
35#include "drv_digital_out.h"
36#include "drv_digital_in.h"
37#include "drv_analog_in.h"
38
59#define CURRENTSENS2_CONV_FACTOR 10
60#define CURRENTSENS2_NUM_CONVERSIONS 10
61 // currentsens2_set
63
78#define CURRENTSENS2_MAP_MIKROBUS( cfg, mikrobus ) \
79 cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN ); \
80 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
81 // currentsens2_map // currentsens2
84
89typedef struct
90{
91 digital_in_t int_pin;
93 analog_in_t adc;
95 float zero_val;
98
103typedef struct
104{
105 pin_name_t an;
106 pin_name_t int_pin;
108 analog_in_resolution_t resolution;
109 float vref;
112
117typedef enum
118{
121
123
140
155
167err_t currentsens2_read_an_pin_value ( currentsens2_t *ctx, uint16_t *data_out );
168
182err_t currentsens2_read_an_pin_voltage ( currentsens2_t *ctx, float *data_out );
183
194
206
218err_t currentsens2_get_current ( currentsens2_t *ctx, float *current );
219
220#ifdef __cplusplus
221}
222#endif
223#endif // CURRENTSENS2_H
224 // currentsens2
226
227// ------------------------------------------------------------------------ END
currentsens2_return_value_t
Current Sens 2 Click return value data.
Definition: currentsens2.h:118
@ CURRENTSENS2_ERROR
Definition: currentsens2.h:120
@ CURRENTSENS2_OK
Definition: currentsens2.h:119
void currentsens2_cfg_setup(currentsens2_cfg_t *cfg)
Current Sens 2 configuration object setup function.
err_t currentsens2_tare(currentsens2_t *ctx)
Current Sens 2 tare function.
err_t currentsens2_read_an_pin_value(currentsens2_t *ctx, uint16_t *data_out)
Current Sens 2 read AN pin value function.
err_t currentsens2_get_current(currentsens2_t *ctx, float *current)
Current Sens 2 read current function.
err_t currentsens2_read_an_pin_voltage(currentsens2_t *ctx, float *data_out)
Current Sens 2 read AN pin voltage level function.
uint8_t currentsens2_get_int_pin(currentsens2_t *ctx)
Current Sens 2 get int pin state function.
err_t currentsens2_init(currentsens2_t *ctx, currentsens2_cfg_t *cfg)
Current Sens 2 initialization function.
Current Sens 2 Click configuration object.
Definition: currentsens2.h:104
analog_in_resolution_t resolution
Definition: currentsens2.h:108
float vref
Definition: currentsens2.h:109
pin_name_t int_pin
Definition: currentsens2.h:106
pin_name_t an
Definition: currentsens2.h:105
Current Sens 2 Click context object.
Definition: currentsens2.h:90
digital_in_t int_pin
Definition: currentsens2.h:91
analog_in_t adc
Definition: currentsens2.h:93
float zero_val
Definition: currentsens2.h:95