diffpressure  2.0.0.0
diffpressure.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 DIFFPRESSURE_H
36 #define DIFFPRESSURE_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_spi_master.h"
55 
56 // -------------------------------------------------------------- PUBLIC MACROS
67 #define DIFFPRESSURE_MAP_MIKROBUS( cfg, mikrobus ) \
68  cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
69  cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
70  cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
71  cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS )
72 
79 #define DIFFPRESSURE_OK 0
80 #define DIFFPRESSURE_ERROR -1
81  // End group macro
84 // --------------------------------------------------------------- PUBLIC TYPES
93 typedef struct
94 {
95  // Modules
96  spi_master_t spi;
97 
98  // ctx variable
99  pin_name_t chip_select;
100 
102 
106 typedef struct
107 {
108  // Communication gpio pins
109  pin_name_t miso;
110  pin_name_t mosi;
111  pin_name_t sck;
112  pin_name_t cs;
113 
114  // static variable
115  uint32_t spi_speed;
116  spi_master_mode_t spi_mode;
117  spi_master_chip_select_polarity_t cs_polarity;
118 
120  // End types group
122 
123 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
124 
129 #ifdef __cplusplus
130 extern "C"{
131 #endif
132 
142 
152 
161 
170 int32_t diffpressure_get_pa_difference ( diffpressure_t *ctx, float adc_voltage );
171 
172 #ifdef __cplusplus
173 }
174 #endif
175 #endif // _DIFFPRESSURE_H_
176  // End public_function group
179 
180 // ------------------------------------------------------------------------- END
diffpressure_get_pa_difference
int32_t diffpressure_get_pa_difference(diffpressure_t *ctx, float adc_voltage)
Get pressure difference [Pa] function.
diffpressure_init
err_t diffpressure_init(diffpressure_t *ctx, diffpressure_cfg_t *cfg)
Initialization function.
diffpressure_cfg_t::spi_speed
uint32_t spi_speed
Definition: diffpressure.h:115
diffpressure_read_adc_voltage
float diffpressure_read_adc_voltage(diffpressure_t *ctx)
Read adc voltage function.
diffpressure_cfg_t::mosi
pin_name_t mosi
Definition: diffpressure.h:110
diffpressure_t
Click ctx object definition.
Definition: diffpressure.h:94
diffpressure_cfg_t::cs
pin_name_t cs
Definition: diffpressure.h:112
diffpressure_cfg_t::spi_mode
spi_master_mode_t spi_mode
Definition: diffpressure.h:116
diffpressure_cfg_setup
void diffpressure_cfg_setup(diffpressure_cfg_t *cfg)
Config Object Initialization function.
diffpressure_t::spi
spi_master_t spi
Definition: diffpressure.h:96
diffpressure_cfg_t::sck
pin_name_t sck
Definition: diffpressure.h:111
diffpressure_cfg_t::cs_polarity
spi_master_chip_select_polarity_t cs_polarity
Definition: diffpressure.h:117
diffpressure_cfg_t::miso
pin_name_t miso
Definition: diffpressure.h:109
diffpressure_cfg_t
Click configuration structure definition.
Definition: diffpressure.h:107
diffpressure_t::chip_select
pin_name_t chip_select
Definition: diffpressure.h:99