vacuum 2.0.0.0
vacuum.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 VACCUM_H
36#define VACCUM_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_digital_in.h"
54#include "drv_i2c_master.h"
55
56
57// -------------------------------------------------------------- PUBLIC MACROS
67#define VACCUM_MAP_MIKROBUS( cfg, mikrobus ) \
68 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
69 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
70 cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN )
77#define VACCUM_RETVAL uint8_t
78
79#define VACCUM_OK 0x00
80#define VACCUM_INIT_ERROR 0xFF
83 // End group macro
84// --------------------------------------------------------------- PUBLIC TYPES
93typedef struct
94{
95 // Output pins
96
97 digital_out_t an;
98
99 // Modules
100
101 i2c_master_t i2c;
102
103 // ctx variable
104
106 uint16_t pressure;
107
108} vacuum_t;
109
113typedef struct
114{
115 // Communication gpio pins
116
117 pin_name_t scl;
118 pin_name_t sda;
119
120 // Additional gpio pins
121
122 pin_name_t an;
123
124 // static variable
125
126 uint32_t i2c_speed;
127 uint8_t i2c_address;
128
130
131 // End variable group
132// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
133
139#ifdef __cplusplus
140extern "C"{
141#endif
142
152
162
171
179uint16_t vacuum_read_data ( vacuum_t *ctx );
180
189
198
207
216
217#ifdef __cplusplus
218}
219#endif
220#endif // _VACCUM_H_
221
222 // End public_function group
224
225// ------------------------------------------------------------------------- END
#define VACCUM_RETVAL
Definition vacuum.h:77
void vacuum_default_cfg(vacuum_t *ctx)
Click Default Configuration function.
VACCUM_RETVAL vacuum_init(vacuum_t *ctx, vacuum_cfg_t *cfg)
Initialization function.
void vacuum_calibration(vacuum_t *ctx)
Sensor calibration.
float vacuum_get_pressure(vacuum_t *ctx)
Function for converting ADC value to pressure data.
void vacuum_cfg_setup(vacuum_cfg_t *cfg)
Config Object Initialization function.
uint16_t vacuum_read_data(vacuum_t *ctx)
Function for reads 12 bit ADC data.
float vacuum_get_percentage_of_vacuum(vacuum_t *ctx)
Function for converting ADC value to percentage of Vacuum.
float vacuum_get_voltage(vacuum_t *ctx)
Voltage reading function.
Click configuration structure definition.
Definition vacuum.h:114
uint32_t i2c_speed
Definition vacuum.h:126
pin_name_t scl
Definition vacuum.h:117
pin_name_t sda
Definition vacuum.h:118
pin_name_t an
Definition vacuum.h:122
uint8_t i2c_address
Definition vacuum.h:127
Click ctx object definition.
Definition vacuum.h:94
uint16_t pressure
Definition vacuum.h:106
i2c_master_t i2c
Definition vacuum.h:101
uint8_t slave_address
Definition vacuum.h:105
digital_out_t an
Definition vacuum.h:97