diffpressure  2.0.0.0
diffpressure.h
Go to the documentation of this file.
1 /*
2  * MikroSDK - MikroE Software Development Kit
3  * Copyright (c) 2019, MikroElektronika - www.mikroe.com
4  * All rights reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  */
24 
33 // ----------------------------------------------------------------------------
34 
35 #ifndef DIFFPRESSURE_H
36 #define DIFFPRESSURE_H
37 
38 #include "drv_digital_out.h"
39 #include "drv_digital_in.h"
40 #include "drv_spi_master.h"
41 
42 
43 // -------------------------------------------------------------- PUBLIC MACROS
54 #define DIFFPRESSURE_MAP_MIKROBUS( cfg, mikrobus ) \
55  cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
56  cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
57  cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
58  cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS );
59 
66 #define DIFFPRESSURE_RETVAL uint8_t
67 
68 #define DIFFPRESSURE_OK 0x00
69 #define DIFFPRESSURE_INIT_ERROR 0xFF
70 
76 #define DIFFPRESSURE_NOT_RDY 0
77 #define DIFFPRESSURE_OK_RDY 1
78 #define DIFFPRESSURE_OVH 2
79 #define DIFFPRESSURE_OVL 3
80  // End group macro
83 // --------------------------------------------------------------- PUBLIC TYPES
92 typedef struct
93 {
94  // Modules
95 
96  spi_master_t spi;
97 
99 
103 typedef struct
104 {
105  // Communication gpio pins
106 
107  pin_name_t miso;
108  pin_name_t mosi;
109  pin_name_t sck;
110  pin_name_t cs;
111 
112  // static variable
113 
114  hal_spi_speed_t spi_speed;
115  hal_spi_mode_t spi_mode;
116 
118 
119 typedef enum
120 {
121  NOT_RDY = 0,
122  OVH = 2,
123  OVL = 3,
124  OK = 1
125 } status_t;
126  // End types group
128 
129 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
130 
135 #ifdef __cplusplus
136 extern "C"{
137 #endif
138 
148 
157 
166 void diffpressure_generic_transfer ( diffpressure_t *ctx, spi_master_transfer_data_t *block );
167 
175 int32_t diffpressure_read_data ( diffpressure_t *ctx );
176 
185 int32_t diffpressure_get_kpa_difference ( diffpressure_t *ctx, int32_t difference );
186 
195 status_t diffpressure_status_check ( diffpressure_t *ctx, int32_t result );
196 
197 #ifdef __cplusplus
198 }
199 #endif
200 #endif // _DIFFPRESSURE_H_
201  // End public_function group
204 
205 // ------------------------------------------------------------------------- END
diffpressure_cfg_t::spi_speed
hal_spi_speed_t spi_speed
Definition: diffpressure.h:114
diffpressure_init
DIFFPRESSURE_RETVAL diffpressure_init(diffpressure_t *ctx, diffpressure_cfg_t *cfg)
Initialization function.
diffpressure_cfg_t::mosi
pin_name_t mosi
Definition: diffpressure.h:108
diffpressure_generic_transfer
void diffpressure_generic_transfer(diffpressure_t *ctx, spi_master_transfer_data_t *block)
Generic transfer function.
diffpressure_t
Click ctx object definition.
Definition: diffpressure.h:92
diffpressure_cfg_t::cs
pin_name_t cs
Definition: diffpressure.h:110
DIFFPRESSURE_RETVAL
#define DIFFPRESSURE_RETVAL
Definition: diffpressure.h:66
diffpressure_cfg_setup
void diffpressure_cfg_setup(diffpressure_cfg_t *cfg)
Config Object Initialization function.
OVL
Definition: diffpressure.h:123
OVH
Definition: diffpressure.h:122
diffpressure_t::spi
spi_master_t spi
Definition: diffpressure.h:96
diffpressure_read_data
int32_t diffpressure_read_data(diffpressure_t *ctx)
Generic read data function.
diffpressure_cfg_t::sck
pin_name_t sck
Definition: diffpressure.h:109
diffpressure_status_check
status_t diffpressure_status_check(diffpressure_t *ctx, int32_t result)
Check status of measurement.
diffpressure_cfg_t::miso
pin_name_t miso
Definition: diffpressure.h:107
diffpressure_get_kpa_difference
int32_t diffpressure_get_kpa_difference(diffpressure_t *ctx, int32_t difference)
Get kPa Difference function.
status_t
status_t
Definition: diffpressure.h:119
diffpressure_cfg_t::spi_mode
hal_spi_mode_t spi_mode
Definition: diffpressure.h:115
diffpressure_cfg_t
Click configuration structure definition.
Definition: diffpressure.h:103
NOT_RDY
Definition: diffpressure.h:121
OK
Definition: diffpressure.h:124