multimeter 2.0.0.0
multimeter.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
33// ----------------------------------------------------------------------------
34
35#ifndef MULTIMETER_H
36#define MULTIMETER_H
37
42#ifdef PREINIT_SUPPORTED
43#include "preinit.h"
44#endif
45
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
48 #include "delays.h"
49 #endif
50#endif
51
52#include "drv_digital_out.h"
53#include "drv_spi_master.h"
54
55// -------------------------------------------------------------- PUBLIC MACROS
66#define MULTIMETER_MAP_MIKROBUS( cfg, mikrobus ) \
67 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
68 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
69 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
70 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
71 cfg.a = MIKROBUS( mikrobus, MIKROBUS_AN ); \
72 cfg.b = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
73 cfg.c = MIKROBUS( mikrobus, MIKROBUS_INT )
80#define MULTIMETER_RETVAL uint8_t
81
82#define MULTIMETER_OK 0x00
83#define MULTIMETER_INIT_ERROR 0xFF
90#define MULTIMETER_I_CHANNEL 0x00
91#define MULTIMETER_U_CHANNEL 0x01
92#define MULTIMETER_R_CHANNEL 0x02
93#define MULTIMETER_C_CHANNEL 0x03
100#define MULTIMETER_MAX_VOLTAGE 4095.0
103 // End group macro
104// --------------------------------------------------------------- PUBLIC TYPES
113typedef struct
114{
118 uint8_t scan_range;
119
121
125typedef struct
126{
131
133
137typedef struct
138{
139 // Output pins
140
141 digital_out_t a;
142 digital_out_t b;
143 digital_out_t c;
144 digital_out_t cs;
145
146 // Modules
147
148 spi_master_t spi;
150 pin_name_t chip_select;
151
153
157typedef struct
158{
159 // Communication gpio pins
160
161 pin_name_t miso;
162 pin_name_t mosi;
163 pin_name_t sck;
164 pin_name_t cs;
165
166 // Additional gpio pins
167
168 pin_name_t a;
169 pin_name_t b;
170 pin_name_t c;
171
172 // static variable
173
174 uint32_t spi_speed;
175 spi_master_mode_t spi_mode;
176 spi_master_chip_select_polarity_t cs_polarity;
178
180
181 // End types group
182// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
183
188#ifdef __cplusplus
189extern "C"{
190#endif
191
201
210
219
228
237
246
255
265uint16_t multimeter_get_resistance_range ( multimeter_t *ctx, uint8_t range );
266
277
278#ifdef __cplusplus
279}
280#endif
281#endif // _MULTIMETER_H_
282
283 // End public_function group
285
286// ------------------------------------------------------------------------- END
#define MULTIMETER_RETVAL
Definition multimeter.h:80
float multimeter_read_voltage(multimeter_t *ctx)
Read voltage function.
MULTIMETER_RETVAL multimeter_init(multimeter_t *ctx, multimeter_cfg_t *cfg)
Initialization function.
void multimeter_cfg_setup(multimeter_cfg_t *cfg)
Config Object Initialization function.
void multimeter_set_resistance_range(multimeter_t *ctx, uint8_t range)
Set resistance range function.
float multimeter_read_capacitance(multimeter_t *ctx)
Read capacitance function.
float multimeter_read_current(multimeter_t *ctx)
Read current function.
uint16_t multimeter_get_resistance_range(multimeter_t *ctx, uint8_t range)
Get resistance range function.
void multimeter_default_cfg(multimeter_t *ctx)
Click Default Configuration function.
float multimeter_read_resistance(multimeter_t *ctx)
Read resistance function.
Calibration configuration structure.
Definition multimeter.h:126
uint8_t scan_range_cfg
Definition multimeter.h:130
float curr_cal_cfg
Definition multimeter.h:129
float volt_cal_cfg
Definition multimeter.h:128
float capa_cal_cfg
Definition multimeter.h:127
Calibration structure.
Definition multimeter.h:114
float voltage_cal
Definition multimeter.h:116
float capacitance_cal
Definition multimeter.h:115
float current_cal
Definition multimeter.h:117
uint8_t scan_range
Definition multimeter.h:118
Click configuration structure definition.
Definition multimeter.h:158
calibration_cfg_t calibration_cfg
Definition multimeter.h:177
spi_master_chip_select_polarity_t cs_polarity
Definition multimeter.h:176
pin_name_t sck
Definition multimeter.h:163
spi_master_mode_t spi_mode
Definition multimeter.h:175
pin_name_t b
Definition multimeter.h:169
pin_name_t a
Definition multimeter.h:168
pin_name_t mosi
Definition multimeter.h:162
uint32_t spi_speed
Definition multimeter.h:174
pin_name_t miso
Definition multimeter.h:161
pin_name_t c
Definition multimeter.h:170
pin_name_t cs
Definition multimeter.h:164
Click ctx object definition.
Definition multimeter.h:138
digital_out_t cs
Definition multimeter.h:144
spi_master_t spi
Definition multimeter.h:148
digital_out_t a
Definition multimeter.h:141
calibration_t calibration
Definition multimeter.h:149
digital_out_t c
Definition multimeter.h:143
digital_out_t b
Definition multimeter.h:142
pin_name_t chip_select
Definition multimeter.h:150