pressure6  2.0.0.0
pressure6.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 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 // -------------------------------------------------------------- PUBLIC MACROS
43 
48 #define PRESSURE6_MAP_MIKROBUS( cfg, mikrobus ) \
49  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
50  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
51  cfg.dri = MIKROBUS( mikrobus, MIKROBUS_INT )
52 
57 #define PRESSURE6_RETVAL uint8_t
58 
59 #define PRESSURE6_OK 0x00
60 #define PRESSURE6_INIT_ERROR 0xFF
61 
66 #define PRESSURE6_MC_AVE_NUM_SINGLE 0x00
67 #define PRESSURE6_MC_AVE_NUM_2_TIMES 0x20
68 #define PRESSURE6_MC_AVE_NUM_4_TIMES 0x40
69 #define PRESSURE6_MC_AVE_NUM_8_TIMES 0x60
70 #define PRESSURE6_MC_AVE_NUM_16_TIMES 0x80
71 #define PRESSURE6_MC_AVE_NUM_32_TIMES 0xA0
72 #define PRESSURE6_MC_AVE_NUM_64_TIMES 0xC0
73 #define PRESSURE6_MC_AVE_NUM_PROHIBITED 0xE0
74 #define PRESSURE6_MC_DATA_READY_ENABLED 0x10
75 #define PRESSURE6_MC_DATA_READY_DISABLED 0x00
76 #define PRESSURE6_MC_FULL_DATA_ENABLED 0x08
77 #define PRESSURE6_MC_FULL_DATA_DISABLED 0x00
78 #define PRESSURE6_MC_WATER_MARK_ENABLED 0x04
79 #define PRESSURE6_MC_WATER_MARK_DISABLED 0x00
80 #define PRESSURE6_MC_MODE_STAND_BY 0x00
81 #define PRESSURE6_MC_MODE_ONE_SHOT 0x01
82 #define PRESSURE6_MC_MODE_CONTINUOUS 0x02
83 #define PRESSURE6_REG_MODE_CONTROL 0x14
84  // End group macro
86 // --------------------------------------------------------------- PUBLIC TYPES
95 typedef struct
96 {
97  // Input pins
98 
99  digital_in_t dri;
100 
101  // Modules
102 
103  i2c_master_t i2c;
104 
105  // ctx variable
106 
107  uint8_t slave_address;
108 
109 } pressure6_t;
110 
114 typedef struct
115 {
116  // Communication gpio pins
117 
118  pin_name_t scl;
119  pin_name_t sda;
120 
121  // Additional gpio pins
122 
123  pin_name_t dri;
124 
125  // static variable
126 
127  uint32_t i2c_speed;
128  uint8_t i2c_address;
129 
131  // End types group
133 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
134 
140 #ifdef __cplusplus
141 extern "C"{
142 #endif
143 
153 
163 
176 void pressure6_default_cfg ( pressure6_t *ctx );
177 
187 void pressure6_write_byte( pressure6_t *ctx, uint8_t reg, uint8_t data_in );
188 
199 uint8_t pressure6_read_byte( pressure6_t *ctx, uint8_t reg);
200 
210 uint16_t pressure6_get_pressure( pressure6_t *ctx );
211 
221 uint8_t pressure6_get_temperature( pressure6_t *ctx );
222 
232 uint8_t pressure6_get_interrupt( pressure6_t *ctx );
233 
243 uint8_t pressure6_get_status( pressure6_t *ctx);
244 
252 void pressure6_power_on( pressure6_t *ctx );
253 
261 void pressure6_power_off( pressure6_t *ctx);
262 
271 
272 #ifdef __cplusplus
273 }
274 #endif
275 #endif // _PRESSURE6_H_
276  // End public_function group
279 
280 // ------------------------------------------------------------------------- END
pin_name_t scl
Definition: pressure6.h:118
pin_name_t dri
Definition: pressure6.h:123
uint32_t i2c_speed
Definition: pressure6.h:127
uint8_t pressure6_get_temperature(pressure6_t *ctx)
Temperature value.
pin_name_t sda
Definition: pressure6.h:119
uint8_t i2c_address
Definition: pressure6.h:128
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:114
i2c_master_t i2c
Definition: pressure6.h:103
void pressure6_write_byte(pressure6_t *ctx, uint8_t reg, uint8_t data_in)
Byte write function.
digital_in_t dri
Definition: pressure6.h:99
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:57
uint16_t pressure6_get_pressure(pressure6_t *ctx)
Pressure value.
void pressure6_cfg_setup(pressure6_cfg_t *cfg)
Config Object Initialization function.
void pressure6_power_off(pressure6_t *ctx)
Power OFF.
uint8_t slave_address
Definition: pressure6.h:107
Click ctx object definition.
Definition: pressure6.h:95