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 
35 #include "mikrosdk_version.h"
36 
37 #ifdef __GNUC__
38 #if mikroSDK_GET_VERSION < 20800ul
39 #include "rcu_delays.h"
40 #else
41 #include "delays.h"
42 #endif
43 #endif
44 
45 #include "drv_digital_out.h"
46 #include "drv_digital_in.h"
47 #include "drv_i2c_master.h"
48 
69 #define PROXIMITY14_REG_CFG1 0x00
70 #define PROXIMITY14_REG_CFG2 0x03
71 #define PROXIMITY14_REG_CFG3 0x04
72 #define PROXIMITY14_REG_CFG4 0x08
73 #define PROXIMITY14_REG_THRESHOLD_LOW 0x05
74 #define PROXIMITY14_REG_THRESHOLD_HIGH 0x06
75 #define PROXIMITY14_REG_CANCELLATION 0x07
76 #define PROXIMITY14_REG_DATA 0xF8
77 #define PROXIMITY14_REG_INT_FLAG 0xF9
78 #define PROXIMITY14_REG_ID 0xFA
79 #define PROXIMITY14_REG_AC_DATA 0xFB
80  // proximity14_reg
82 
98 #define PROXIMITY14_SET_DEV_ADDR 0x60
99  // proximity14_set
101 
116 #define PROXIMITY14_MAP_MIKROBUS( cfg, mikrobus ) \
117  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
118  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
119  cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
120  // proximity14_map // proximity14
123 
128 typedef struct
129 {
130  // Input pins
131  digital_in_t int_pin;
133  // Modules
134  i2c_master_t i2c;
136  // I2C slave address
137  uint8_t slave_address;
139 } proximity14_t;
140 
145 typedef struct
146 {
147  pin_name_t scl;
148  pin_name_t sda;
150  pin_name_t int_pin;
152  uint32_t i2c_speed;
153  uint8_t i2c_address;
156 
161 typedef enum
162 {
164  PROXIMITY14_ERROR = -1
165 
167 
184 
199 
214 
227 err_t proximity14_generic_write ( proximity14_t *ctx, uint8_t reg, uint16_t tx_data );
228 
241 err_t proximity14_generic_read ( proximity14_t *ctx, uint8_t reg, uint16_t *rx_data );
242 
251 
252 #ifdef __cplusplus
253 }
254 #endif
255 #endif // PROXIMITY14_H
256  // proximity14
258 
259 // ------------------------------------------------------------------------ END
proximity14_default_cfg
err_t proximity14_default_cfg(proximity14_t *ctx)
Proximity 14 default configuration function.
PROXIMITY14_OK
@ PROXIMITY14_OK
Definition: proximity14.h:163
proximity14_return_value_t
proximity14_return_value_t
Proximity 14 Click return value data.
Definition: proximity14.h:162
proximity14_t::int_pin
digital_in_t int_pin
Definition: proximity14.h:131
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:146
proximity14_get_int
uint8_t proximity14_get_int(proximity14_t *ctx)
Get INT pin state.
PROXIMITY14_ERROR
@ PROXIMITY14_ERROR
Definition: proximity14.h:164
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:148
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:147
proximity14_cfg_t::i2c_address
uint8_t i2c_address
Definition: proximity14.h:153
proximity14_t
Proximity 14 Click context object.
Definition: proximity14.h:129
proximity14_t::slave_address
uint8_t slave_address
Definition: proximity14.h:137
proximity14_t::i2c
i2c_master_t i2c
Definition: proximity14.h:134
proximity14_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: proximity14.h:152
proximity14_cfg_t::int_pin
pin_name_t int_pin
Definition: proximity14.h:150