proximity14  2.0.0.0
proximity14.h
Go to the documentation of this file.
1 /****************************************************************************
2 ** Copyright (C) 2020 MikroElektronika d.o.o.
3 ** Contact: https://www.mikroe.com/contact
4 **
5 ** Permission is hereby granted, free of charge, to any person obtaining a copy
6 ** of this software and associated documentation files (the "Software"), to deal
7 ** in the Software without restriction, including without limitation the rights
8 ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 ** copies of the Software, and to permit persons to whom the Software is
10 ** furnished to do so, subject to the following conditions:
11 ** The above copyright notice and this permission notice shall be
12 ** included in all copies or substantial portions of the Software.
13 **
14 ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16 ** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18 ** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19 ** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 ** USE OR OTHER DEALINGS IN THE SOFTWARE.
21 ****************************************************************************/
22 
28 #ifndef PROXIMITY14_H
29 #define PROXIMITY14_H
30 
31 #ifdef __cplusplus
32 extern "C"{
33 #endif
34 
39 #ifdef PREINIT_SUPPORTED
40 #include "preinit.h"
41 #endif
42 
43 #ifdef MikroCCoreVersion
44  #if MikroCCoreVersion >= 1
45  #include "delays.h"
46  #endif
47 #endif
48 
49 #include "drv_digital_out.h"
50 #include "drv_digital_in.h"
51 #include "drv_i2c_master.h"
52 
73 #define PROXIMITY14_REG_CFG1 0x00
74 #define PROXIMITY14_REG_CFG2 0x03
75 #define PROXIMITY14_REG_CFG3 0x04
76 #define PROXIMITY14_REG_CFG4 0x08
77 #define PROXIMITY14_REG_THRESHOLD_LOW 0x05
78 #define PROXIMITY14_REG_THRESHOLD_HIGH 0x06
79 #define PROXIMITY14_REG_CANCELLATION 0x07
80 #define PROXIMITY14_REG_DATA 0xF8
81 #define PROXIMITY14_REG_INT_FLAG 0xF9
82 #define PROXIMITY14_REG_ID 0xFA
83 #define PROXIMITY14_REG_AC_DATA 0xFB
84  // proximity14_reg
86 
102 #define PROXIMITY14_SET_DEV_ADDR 0x60
103  // proximity14_set
105 
120 #define PROXIMITY14_MAP_MIKROBUS( cfg, mikrobus ) \
121  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
122  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
123  cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
124  // proximity14_map // proximity14
127 
132 typedef struct
133 {
134  // Input pins
135  digital_in_t int_pin;
137  // Modules
138  i2c_master_t i2c;
140  // I2C slave address
141  uint8_t slave_address;
143 } proximity14_t;
144 
149 typedef struct
150 {
151  pin_name_t scl;
152  pin_name_t sda;
154  pin_name_t int_pin;
156  uint32_t i2c_speed;
157  uint8_t i2c_address;
160 
165 typedef enum
166 {
168  PROXIMITY14_ERROR = -1
169 
171 
188 
203 
218 
231 err_t proximity14_generic_write ( proximity14_t *ctx, uint8_t reg, uint16_t tx_data );
232 
245 err_t proximity14_generic_read ( proximity14_t *ctx, uint8_t reg, uint16_t *rx_data );
246 
255 
256 #ifdef __cplusplus
257 }
258 #endif
259 #endif // PROXIMITY14_H
260  // proximity14
262 
263 // ------------------------------------------------------------------------ END
proximity14_default_cfg
err_t proximity14_default_cfg(proximity14_t *ctx)
Proximity 14 default configuration function.
PROXIMITY14_OK
@ PROXIMITY14_OK
Definition: proximity14.h:167
proximity14_return_value_t
proximity14_return_value_t
Proximity 14 Click return value data.
Definition: proximity14.h:166
proximity14_t::int_pin
digital_in_t int_pin
Definition: proximity14.h:135
proximity14_cfg_setup
void proximity14_cfg_setup(proximity14_cfg_t *cfg)
Proximity 14 configuration object setup function.
proximity14_cfg_t
Proximity 14 Click configuration object.
Definition: proximity14.h:150
proximity14_get_int
uint8_t proximity14_get_int(proximity14_t *ctx)
Get INT pin state.
PROXIMITY14_ERROR
@ PROXIMITY14_ERROR
Definition: proximity14.h:168
proximity14_generic_write
err_t proximity14_generic_write(proximity14_t *ctx, uint8_t reg, uint16_t tx_data)
Writing function.
proximity14_cfg_t::sda
pin_name_t sda
Definition: proximity14.h:152
proximity14_init
err_t proximity14_init(proximity14_t *ctx, proximity14_cfg_t *cfg)
Proximity 14 initialization function.
proximity14_generic_read
err_t proximity14_generic_read(proximity14_t *ctx, uint8_t reg, uint16_t *rx_data)
Reading function.
proximity14_cfg_t::scl
pin_name_t scl
Definition: proximity14.h:151
proximity14_cfg_t::i2c_address
uint8_t i2c_address
Definition: proximity14.h:157
proximity14_t
Proximity 14 Click context object.
Definition: proximity14.h:133
proximity14_t::slave_address
uint8_t slave_address
Definition: proximity14.h:141
proximity14_t::i2c
i2c_master_t i2c
Definition: proximity14.h:138
proximity14_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: proximity14.h:156
proximity14_cfg_t::int_pin
pin_name_t int_pin
Definition: proximity14.h:154