pressure6  2.0.0.0
pressure6.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 PRESSURE6_H
36 #define PRESSURE6_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
44 
49 #define PRESSURE6_MAP_MIKROBUS( cfg, mikrobus ) \
50  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
51  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
52  cfg.dri = MIKROBUS( mikrobus, MIKROBUS_INT )
53 
58 #define PRESSURE6_RETVAL uint8_t
59 
60 #define PRESSURE6_OK 0x00
61 #define PRESSURE6_INIT_ERROR 0xFF
62 
67 #define PRESSURE6_MC_AVE_NUM_SINGLE 0x00
68 #define PRESSURE6_MC_AVE_NUM_2_TIMES 0x20
69 #define PRESSURE6_MC_AVE_NUM_4_TIMES 0x40
70 #define PRESSURE6_MC_AVE_NUM_8_TIMES 0x60
71 #define PRESSURE6_MC_AVE_NUM_16_TIMES 0x80
72 #define PRESSURE6_MC_AVE_NUM_32_TIMES 0xA0
73 #define PRESSURE6_MC_AVE_NUM_64_TIMES 0xC0
74 #define PRESSURE6_MC_AVE_NUM_PROHIBITED 0xE0
75 #define PRESSURE6_MC_DATA_READY_ENABLED 0x10
76 #define PRESSURE6_MC_DATA_READY_DISABLED 0x00
77 #define PRESSURE6_MC_FULL_DATA_ENABLED 0x08
78 #define PRESSURE6_MC_FULL_DATA_DISABLED 0x00
79 #define PRESSURE6_MC_WATER_MARK_ENABLED 0x04
80 #define PRESSURE6_MC_WATER_MARK_DISABLED 0x00
81 #define PRESSURE6_MC_MODE_STAND_BY 0x00
82 #define PRESSURE6_MC_MODE_ONE_SHOT 0x01
83 #define PRESSURE6_MC_MODE_CONTINUOUS 0x02
84 #define PRESSURE6_REG_MODE_CONTROL 0x14
85  // End group macro
87 // --------------------------------------------------------------- PUBLIC TYPES
96 typedef struct
97 {
98  // Input pins
99 
100  digital_in_t dri;
101 
102  // Modules
103 
104  i2c_master_t i2c;
105 
106  // ctx variable
107 
108  hal_i2c_address_t slave_address;
109 
110 } pressure6_t;
111 
115 typedef 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 dri;
125 
126  // static variable
127 
128  hal_i2c_speed_t i2c_speed;
129  hal_i2c_address_t i2c_address;
130 
132  // End types group
134 
135 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
136 
142 #ifdef __cplusplus
143 extern "C"{
144 #endif
145 
155 
164 
177 void pressure6_default_cfg ( pressure6_t *ctx );
178 
188 void pressure6_write_byte( pressure6_t *ctx, uint8_t reg, uint8_t data_in );
189 
201 uint8_t pressure6_read_byte( pressure6_t *ctx, uint8_t reg);
202 
213 uint16_t pressure6_get_pressure( pressure6_t *ctx );
214 
225 uint8_t pressure6_get_temperature( pressure6_t *ctx );
226 
237 uint8_t pressure6_get_interrupt( pressure6_t *ctx );
238 
249 uint8_t pressure6_get_status( pressure6_t *ctx);
250 
259 void pressure6_power_on( pressure6_t *ctx );
260 
269 void pressure6_power_off( pressure6_t *ctx);
270 
280 
281 #ifdef __cplusplus
282 }
283 #endif
284 #endif // _PRESSURE6_H_
285  // End public_function group
288 
289 // ------------------------------------------------------------------------- END
pin_name_t scl
Definition: pressure6.h:119
pin_name_t dri
Definition: pressure6.h:124
hal_i2c_address_t i2c_address
Definition: pressure6.h:129
uint8_t pressure6_get_temperature(pressure6_t *ctx)
Temperature value.
pin_name_t sda
Definition: pressure6.h:120
PRESSURE6_RETVAL pressure6_init(pressure6_t *ctx, pressure6_cfg_t *cfg)
Initialization function.
uint8_t pressure6_get_interrupt(pressure6_t *ctx)
Interupt.
uint8_t pressure6_get_status(pressure6_t *ctx)
Status.
Click configuration structure definition.
Definition: pressure6.h:115
i2c_master_t i2c
Definition: pressure6.h:104
void pressure6_write_byte(pressure6_t *ctx, uint8_t reg, uint8_t data_in)
Byte write function.
digital_in_t dri
Definition: pressure6.h:100
void pressure6_default_cfg(pressure6_t *ctx)
Click Default Configuration function.
uint8_t pressure6_read_byte(pressure6_t *ctx, uint8_t reg)
Byte read function.
void pressure6_power_on(pressure6_t *ctx)
Power ON.
void pressure6_waiting_for_new_data(pressure6_t *ctx)
Waits for new data.
#define PRESSURE6_RETVAL
Definition: pressure6.h:58
uint16_t pressure6_get_pressure(pressure6_t *ctx)
Pressure value.
void pressure6_cfg_setup(pressure6_cfg_t *cfg)
Config Object Initialization function.
hal_i2c_address_t slave_address
Definition: pressure6.h:108
hal_i2c_speed_t i2c_speed
Definition: pressure6.h:128
void pressure6_power_off(pressure6_t *ctx)
Power OFF.
Click ctx object definition.
Definition: pressure6.h:96