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 
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_i2c_master.h"
55 
56 // -------------------------------------------------------------- PUBLIC MACROS
57 
62 #define PRESSURE6_MAP_MIKROBUS( cfg, mikrobus ) \
63  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
64  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
65  cfg.dri = MIKROBUS( mikrobus, MIKROBUS_INT )
66 
71 #define PRESSURE6_RETVAL uint8_t
72 
73 #define PRESSURE6_OK 0x00
74 #define PRESSURE6_INIT_ERROR 0xFF
75 
80 #define PRESSURE6_MC_AVE_NUM_SINGLE 0x00
81 #define PRESSURE6_MC_AVE_NUM_2_TIMES 0x20
82 #define PRESSURE6_MC_AVE_NUM_4_TIMES 0x40
83 #define PRESSURE6_MC_AVE_NUM_8_TIMES 0x60
84 #define PRESSURE6_MC_AVE_NUM_16_TIMES 0x80
85 #define PRESSURE6_MC_AVE_NUM_32_TIMES 0xA0
86 #define PRESSURE6_MC_AVE_NUM_64_TIMES 0xC0
87 #define PRESSURE6_MC_AVE_NUM_PROHIBITED 0xE0
88 #define PRESSURE6_MC_DATA_READY_ENABLED 0x10
89 #define PRESSURE6_MC_DATA_READY_DISABLED 0x00
90 #define PRESSURE6_MC_FULL_DATA_ENABLED 0x08
91 #define PRESSURE6_MC_FULL_DATA_DISABLED 0x00
92 #define PRESSURE6_MC_WATER_MARK_ENABLED 0x04
93 #define PRESSURE6_MC_WATER_MARK_DISABLED 0x00
94 #define PRESSURE6_MC_MODE_STAND_BY 0x00
95 #define PRESSURE6_MC_MODE_ONE_SHOT 0x01
96 #define PRESSURE6_MC_MODE_CONTINUOUS 0x02
97 #define PRESSURE6_REG_MODE_CONTROL 0x14
98  // End group macro
100 // --------------------------------------------------------------- PUBLIC TYPES
109 typedef struct
110 {
111  // Input pins
112 
113  digital_in_t dri;
114 
115  // Modules
116 
117  i2c_master_t i2c;
118 
119  // ctx variable
120 
121  uint8_t slave_address;
122 
123 } pressure6_t;
124 
128 typedef struct
129 {
130  // Communication gpio pins
131 
132  pin_name_t scl;
133  pin_name_t sda;
134 
135  // Additional gpio pins
136 
137  pin_name_t dri;
138 
139  // static variable
140 
141  uint32_t i2c_speed;
142  uint8_t i2c_address;
143 
145  // End types group
147 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
148 
154 #ifdef __cplusplus
155 extern "C"{
156 #endif
157 
167 
177 
191 
201 void pressure6_write_byte( pressure6_t *ctx, uint8_t reg, uint8_t data_in );
202 
213 uint8_t pressure6_read_byte( pressure6_t *ctx, uint8_t reg);
214 
225 
236 
247 
258 
267 
276 
285 
286 #ifdef __cplusplus
287 }
288 #endif
289 #endif // _PRESSURE6_H_
290  // End public_function group
293 
294 // ------------------------------------------------------------------------- END
PRESSURE6_RETVAL
#define PRESSURE6_RETVAL
Definition: pressure6.h:71
pressure6_waiting_for_new_data
void pressure6_waiting_for_new_data(pressure6_t *ctx)
Waits for new data.
pressure6_power_on
void pressure6_power_on(pressure6_t *ctx)
Power ON.
pressure6_cfg_t::scl
pin_name_t scl
Definition: pressure6.h:132
pressure6_default_cfg
void pressure6_default_cfg(pressure6_t *ctx)
Click Default Configuration function.
pressure6_t::dri
digital_in_t dri
Definition: pressure6.h:113
pressure6_cfg_setup
void pressure6_cfg_setup(pressure6_cfg_t *cfg)
Config Object Initialization function.
pressure6_t
Click ctx object definition.
Definition: pressure6.h:110
pressure6_t::slave_address
uint8_t slave_address
Definition: pressure6.h:121
pressure6_get_status
uint8_t pressure6_get_status(pressure6_t *ctx)
Status.
pressure6_get_temperature
uint8_t pressure6_get_temperature(pressure6_t *ctx)
Temperature value.
pressure6_read_byte
uint8_t pressure6_read_byte(pressure6_t *ctx, uint8_t reg)
Byte read function.
pressure6_cfg_t::dri
pin_name_t dri
Definition: pressure6.h:137
pressure6_init
PRESSURE6_RETVAL pressure6_init(pressure6_t *ctx, pressure6_cfg_t *cfg)
Initialization function.
pressure6_write_byte
void pressure6_write_byte(pressure6_t *ctx, uint8_t reg, uint8_t data_in)
Byte write function.
pressure6_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: pressure6.h:141
pressure6_cfg_t::sda
pin_name_t sda
Definition: pressure6.h:133
pressure6_cfg_t
Click configuration structure definition.
Definition: pressure6.h:129
pressure6_power_off
void pressure6_power_off(pressure6_t *ctx)
Power OFF.
pressure6_cfg_t::i2c_address
uint8_t i2c_address
Definition: pressure6.h:142
pressure6_get_interrupt
uint8_t pressure6_get_interrupt(pressure6_t *ctx)
Interupt.
pressure6_get_pressure
uint16_t pressure6_get_pressure(pressure6_t *ctx)
Pressure value.
pressure6_t::i2c
i2c_master_t i2c
Definition: pressure6.h:117