tamper 2.0.0.0
pressure8.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 PRESSURE8_H
36#define PRESSURE8_H
37
38#include "drv_digital_out.h"
39#include "drv_digital_in.h"
40#include "drv_i2c_master.h"
41
42
43// -------------------------------------------------------------- PUBLIC MACROS
53#define PRESSURE8_MAP_MIKROBUS( cfg, mikrobus ) \
54 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
55 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
56 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
57 cfg.eoc = MIKROBUS( mikrobus, MIKROBUS_INT );
64#define PRESSURE8_RETVAL uint8_t
65
66#define PRESSURE8_OK 0x00
67#define PRESSURE8_INIT_ERROR 0xFF
74#define PRESSURE8_DATA_IN_mBar 1
75#define PRESSURE8_DATA_IN_hPa 2
76#define PRESSURE8_DATA_IN_kPa 3
77#define PRESSURE8_DATA_IN_Torr 4
78#define PRESSURE8_DATA_IN_mmHg 5 // End group macro
82// --------------------------------------------------------------- PUBLIC TYPES
91typedef struct
92{
93 // Output pins
94
95 digital_out_t rst;
96
97 // Input pins
98
99 digital_in_t eoc;
100
101 // Modules
102
103 i2c_master_t i2c;
104
105 // ctx variable
106
107 hal_i2c_address_t slave_address;
109
111
115typedef struct
116{
117 // Communication gpio pins
118
119 pin_name_t scl;
120 pin_name_t sda;
121
122 // Additional gpio pins
123
124 pin_name_t rst;
125 pin_name_t eoc;
126
127 // static variable
128
129 hal_i2c_speed_t i2c_speed;
130 hal_i2c_address_t i2c_address;
131
133 // End types group
135
136// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
137
143#ifdef __cplusplus
144extern "C"{
145#endif
146
156
165
176void pressure8_generic_read ( pressure8_t *ctx, uint8_t *data_buf, uint8_t len );
177
187float pressure8_get_pressure ( pressure8_t *ctx, uint8_t press_foramt );
188
195
204
213
226void pressure8_set_psi_range ( float psi_min, float psi_max );
227
228#ifdef __cplusplus
229}
230#endif
231#endif // _PRESSURE8_H_
232 // End public_function group
235
236// ------------------------------------------------------------------------- END
#define PRESSURE8_RETVAL
Definition: pressure8.h:64
void pressure8_set_psi_range(float psi_min, float psi_max)
Functions for set PSI range.
uint8_t pressure8_get_interrupt_state(pressure8_t *ctx)
Functions for get interrupt pin state.
uint8_t pressure8_get_device_status(pressure8_t *ctx)
Functions for get device status.
PRESSURE8_RETVAL pressure8_init(pressure8_t *ctx, pressure8_cfg_t *cfg)
Initialization function.
float pressure8_get_pressure(pressure8_t *ctx, uint8_t press_foramt)
Functions for get Pressure data.
void pressure8_generic_read(pressure8_t *ctx, uint8_t *data_buf, uint8_t len)
Generic read function.
void pressure8_cfg_setup(pressure8_cfg_t *cfg)
Config Object Initialization function.
void pressure8_device_reset(pressure8_t *ctx)
Functions for hardware device reset.
Click configuration structure definition.
Definition: pressure8.h:116
hal_i2c_address_t i2c_address
Definition: pressure8.h:130
pin_name_t eoc
Definition: pressure8.h:125
hal_i2c_speed_t i2c_speed
Definition: pressure8.h:129
pin_name_t scl
Definition: pressure8.h:119
pin_name_t sda
Definition: pressure8.h:120
pin_name_t rst
Definition: pressure8.h:124
Click ctx object definition.
Definition: pressure8.h:92
uint8_t device_status
Definition: pressure8.h:108
digital_in_t eoc
Definition: pressure8.h:99
i2c_master_t i2c
Definition: pressure8.h:103
digital_out_t rst
Definition: pressure8.h:95
hal_i2c_address_t slave_address
Definition: pressure8.h:107