proximity11 2.0.0.0
proximity11.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 PROXIMITY11_H
36#define PROXIMITY11_H
37
38#include "drv_digital_out.h"
39#include "drv_digital_in.h"
40#include "drv_i2c_master.h"
41
42// -------------------------------------------------------------- PUBLIC MACROS
52#define PROXIMITY11_MAP_MIKROBUS( cfg, mikrobus ) \
53 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
54 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
55 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
62#define PROXIMITY11_RETVAL uint8_t
63
64#define PROXIMITY11_OK 0x00
65#define PROXIMITY11_INIT_ERROR 0xFF
73#define PROXIMITY11_DEVICE_ADDRESS 0x38
81#define PROXIMITY11_SYS_CTRL 0x40
82#define PROXIMITY11_MODE_CTRL 0x41
83#define PROXIMITY11_ALS_PS_CTRL 0x42
84#define PROXIMITY11_PS_CTRL 0x43
85#define PROXIMITY11_PS_DATA_LSB 0x44
86#define PROXIMITY11_PS_DATA_MSB 0x45
87#define PROXIMITY11_ALS_DATA0_LSB 0x46
88#define PROXIMITY11_ALS_DATA0_MSB 0x47
89#define PROXIMITY11_ALS_DATA1_LSB 0x48
90#define PROXIMITY11_ALS_DATA1_MSB 0x49
91#define PROXIMITY11_INTERRUPT 0x4A
92#define PROXIMITY11_PS_TH_LSB 0x4B
93#define PROXIMITY11_PS_TH_MSB 0x4C
94#define PROXIMITY11_PS_TL_LSB 0x4D
95#define PROXIMITY11_PS_TL_MSB 0x4E
96#define PROXIMITY11_ALS_DATA0_TH_LSB 0x4F
97#define PROXIMITY11_ALS_DATA0_TH_MSB 0x50
98#define PROXIMITY11_ALS_DATA0_TL_LSB 0x51
99#define PROXIMITY11_ALS_DATA0_TL_MSB 0x52
100#define PROXIMITY11_PS_OFFSET_LSB 0x53
101#define PROXIMITY11_PS_OFFSET_MSB 0x54
102#define PROXIMITY11_MANUFACT_ID 0x92 // End group macro
106// --------------------------------------------------------------- PUBLIC TYPES
113typedef struct
114{
118
119} als_data_t;
120
124typedef struct
125{
126 // Input pins
127
128 digital_in_t int_pin;
129
130 // Modules
131
132 i2c_master_t i2c;
133
134 // ctx variable
135
137
138 //als data object
139
141
143
147typedef struct
148{
149 // Communication gpio pins
150
151 pin_name_t scl;
152 pin_name_t sda;
153
154 // Additional gpio pins
155
156 pin_name_t int_pin;
157
158 // static variable
159
160 uint32_t i2c_speed;
161 uint8_t i2c_address;
162
163 // als_data default values
164
168
170
171
172 // End types group
174// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
175
181#ifdef __cplusplus
182extern "C"{
183#endif
184
194
204
213
224void proximity11_generic_write ( proximity11_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
225
236void proximity11_generic_read ( proximity11_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
237
248
259uint8_t proximity11_get ( proximity11_t *ctx, uint8_t register_address, uint8_t *output_buffer, uint8_t n_bytes );
260
271uint8_t proximity11_set ( proximity11_t *ctx, uint8_t register_address, uint8_t *input_buffer, uint8_t n_bytes );
272
281
292float proximity11_convert_lx ( proximity11_t *ctx, uint16_t *input_data );
293
302void proximity11_get_raw_ps_als_values ( proximity11_t *ctx, uint8_t *data_buffer );
303
313void proximity11_get_ps_als_values ( proximity11_t *ctx, uint16_t *ps_value, float *als_value );
314
326uint8_t proximity11_set_ps_threshold_high ( proximity11_t *ctx, uint16_t threshold_value );
327
339uint8_t proximity11_set_ps_threshold_low ( proximity11_t *ctx, uint16_t threshold_value );
340
349void proximity11_set_als_threshold_high ( proximity11_t *ctx, uint16_t threshold_value );
350
359void proximity11_set_als_threshold_low ( proximity11_t *ctx, uint16_t threshold_value );
360
372uint8_t proximity11_set_ps_offset ( proximity11_t *ctx, uint16_t offset_value );
373
374#ifdef __cplusplus
375}
376#endif
377#endif // _PROXIMITY11_H_
378 // End public_function group
381
382// ------------------------------------------------------------------------- END
#define PROXIMITY11_RETVAL
Definition: proximity11.h:62
uint8_t proximity11_set_ps_threshold_low(proximity11_t *ctx, uint16_t threshold_value)
Setting Low PS threshold value.
uint8_t proximity11_default_cfg(proximity11_t *ctx)
Click Default Configuration function.
PROXIMITY11_RETVAL proximity11_init(proximity11_t *ctx, proximity11_cfg_t *cfg)
Initialization function.
void proximity11_update(proximity11_t *ctx)
Updating data for Lux calculation.
uint8_t proximity11_set_ps_threshold_high(proximity11_t *ctx, uint16_t threshold_value)
Setting High PS threshold value.
uint8_t proximity11_set(proximity11_t *ctx, uint8_t register_address, uint8_t *input_buffer, uint8_t n_bytes)
Proximity value set function.
void proximity11_set_als_threshold_high(proximity11_t *ctx, uint16_t threshold_value)
Setting High Als threshold value.
void proximity11_get_raw_ps_als_values(proximity11_t *ctx, uint8_t *data_buffer)
Getting raw ALS and PS data.
void proximity11_generic_write(proximity11_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
float proximity11_convert_lx(proximity11_t *ctx, uint16_t *input_data)
Converting raw data to Lux.
void proximity11_cfg_setup(proximity11_cfg_t *cfg)
Config Object Initialization function.
void proximity11_get_ps_als_values(proximity11_t *ctx, uint16_t *ps_value, float *als_value)
Getting ALS and PS values.
void proximity11_set_als_threshold_low(proximity11_t *ctx, uint16_t threshold_value)
Setting Low Als threshold value.
void proximity11_generic_read(proximity11_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
uint8_t proximity11_get(proximity11_t *ctx, uint8_t register_address, uint8_t *output_buffer, uint8_t n_bytes)
Proximity value get function.
uint8_t proximity11_int_get(proximity11_t *ctx)
Int pin get functuin.
uint8_t proximity11_set_ps_offset(proximity11_t *ctx, uint16_t offset_value)
Setting PS offset value.
Definition: proximity11.h:114
uint16_t als_measure_time
Definition: proximity11.h:117
uint8_t als_data0_gain
Definition: proximity11.h:115
uint8_t als_data1_gain
Definition: proximity11.h:116
Click configuration structure definition.
Definition: proximity11.h:148
uint32_t i2c_speed
Definition: proximity11.h:160
pin_name_t scl
Definition: proximity11.h:151
uint8_t als_data1_gain_cfg
Definition: proximity11.h:166
pin_name_t int_pin
Definition: proximity11.h:156
uint16_t als_measure_time_cfg
Definition: proximity11.h:167
pin_name_t sda
Definition: proximity11.h:152
uint8_t als_data0_gain_cfg
Definition: proximity11.h:165
uint8_t i2c_address
Definition: proximity11.h:161
Click ctx object definition.
Definition: proximity11.h:125
als_data_t als
Definition: proximity11.h:140
digital_in_t int_pin
Definition: proximity11.h:128
i2c_master_t i2c
Definition: proximity11.h:132
uint8_t slave_address
Definition: proximity11.h:136