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 "drv_digital_out.h"
36 #include "drv_digital_in.h"
37 #include "drv_i2c_master.h"
38 
59 #define PROXIMITY14_REG_CFG1 0x00
60 #define PROXIMITY14_REG_CFG2 0x03
61 #define PROXIMITY14_REG_CFG3 0x04
62 #define PROXIMITY14_REG_CFG4 0x08
63 #define PROXIMITY14_REG_THRESHOLD_LOW 0x05
64 #define PROXIMITY14_REG_THRESHOLD_HIGH 0x06
65 #define PROXIMITY14_REG_CANCELLATION 0x07
66 #define PROXIMITY14_REG_DATA 0xF8
67 #define PROXIMITY14_REG_INT_FLAG 0xF9
68 #define PROXIMITY14_REG_ID 0xFA
69 #define PROXIMITY14_REG_AC_DATA 0xFB
70  // proximity14_reg
72 
88 #define PROXIMITY14_SET_DEV_ADDR 0x60
89  // proximity14_set
91 
106 #define PROXIMITY14_MAP_MIKROBUS( cfg, mikrobus ) \
107  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
108  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
109  cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
110  // proximity14_map // proximity14
113 
118 typedef struct
119 {
120  // Input pins
121  digital_in_t int_pin;
123  // Modules
124  i2c_master_t i2c;
126  // I2C slave address
127  uint8_t slave_address;
129 } proximity14_t;
130 
135 typedef struct
136 {
137  pin_name_t scl;
138  pin_name_t sda;
140  pin_name_t int_pin;
142  uint32_t i2c_speed;
143  uint8_t i2c_address;
146 
151 typedef enum
152 {
154  PROXIMITY14_ERROR = -1
155 
157 
174 
189 
204 
217 err_t proximity14_generic_write ( proximity14_t *ctx, uint8_t reg, uint16_t tx_data );
218 
231 err_t proximity14_generic_read ( proximity14_t *ctx, uint8_t reg, uint16_t *rx_data );
232 
241 
242 #ifdef __cplusplus
243 }
244 #endif
245 #endif // PROXIMITY14_H
246  // proximity14
248 
249 // ------------------------------------------------------------------------ END
proximity14_default_cfg
err_t proximity14_default_cfg(proximity14_t *ctx)
Proximity 14 default configuration function.
PROXIMITY14_OK
@ PROXIMITY14_OK
Definition: proximity14.h:153
proximity14_return_value_t
proximity14_return_value_t
Proximity 14 Click return value data.
Definition: proximity14.h:152
proximity14_t::int_pin
digital_in_t int_pin
Definition: proximity14.h:121
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:136
proximity14_get_int
uint8_t proximity14_get_int(proximity14_t *ctx)
Get INT pin state.
PROXIMITY14_ERROR
@ PROXIMITY14_ERROR
Definition: proximity14.h:154
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:138
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:137
proximity14_cfg_t::i2c_address
uint8_t i2c_address
Definition: proximity14.h:143
proximity14_t
Proximity 14 Click context object.
Definition: proximity14.h:119
proximity14_t::slave_address
uint8_t slave_address
Definition: proximity14.h:127
proximity14_t::i2c
i2c_master_t i2c
Definition: proximity14.h:124
proximity14_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: proximity14.h:142
proximity14_cfg_t::int_pin
pin_name_t int_pin
Definition: proximity14.h:140