ambient11 2.0.0.0
ambient11.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 AMBIENT11_H
36#define AMBIENT11_H
37
38#include "drv_digital_out.h"
39#include "drv_digital_in.h"
40#include "drv_i2c_master.h"
41
42
43// -------------------------------------------------------------- PUBLIC MACROS
53#define AMBIENT11_MAP_MIKROBUS( cfg, mikrobus ) \
54 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
55 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
56 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
63#define AMBIENT11_RETVAL uint8_t
64
65#define AMBIENT11_OK 0x00
66#define AMBIENT11_INIT_ERROR 0xFF
73#define AMBIENT11_SLAVE_ADDRESS 0x29
80#define AMBIENT11_ALS_CONF_WR 0x00
81#define AMBIENT11_TRSHLD_WINDOW_SET_HIGH 0x01
82#define AMBIENT11_TRSHLD_WINDOW_SET_LOW 0x02
83#define AMBIENT11_ALS_CONF_RD 0x04
84#define AMBIENT11_WHITE_VAL 0x05
85#define AMBIENT11_TRSHLD_TRIG_INT 0x06
92#define AMBIENT11_ALS_CONF_SENS_LOW 0x1000
93#define AMBIENT11_ALS_CONF_DG_DOUBLE 0x0800
94#define AMBIENT11_ALS_CONF_GAIN_DOUBLE_SENS 0x0400
95#define AMBIENT11_ALS_CONF_IT_25 0x0300
96#define AMBIENT11_ALS_CONF_IT_50 0x0200
97#define AMBIENT11_ALS_CONF_IT_100 0x0000
98#define AMBIENT11_ALS_CONF_IT_200 0x0040
99#define AMBIENT11_ALS_CONF_IT_400 0x0080
100#define AMBIENT11_ALS_CONF_IT_800 0x00C0
101#define AMBIENT11_ALS_CONF_PERS_1 0x0000
102#define AMBIENT11_ALS_CONF_PERS_2 0x0010
103#define AMBIENT11_ALS_CONF_PERS_4 0x0020
104#define AMBIENT11_ALS_CONF_PERS_8 0x0030
105#define AMBIENT11_ALS_CONF_INT_CHAN 0x0008
106#define AMBIENT11_ALS_CONF_CHAN_EN 0x0004
107#define AMBIENT11_ALS_CONF_INT_EN 0x0002
108#define AMBIENT11_ALS_CONF_SHUT_DOWN 0x0001 // End group macro
112// --------------------------------------------------------------- PUBLIC TYPES
121typedef struct
122{
123 // Output pins
124
125 // Input pins
126
127 digital_in_t int_pin;
128
129 // Modules
130
131 i2c_master_t i2c;
132
133 // ctx variable
134
136
138
142typedef struct
143{
144 // Communication gpio pins
145
146 pin_name_t scl;
147 pin_name_t sda;
148
149 // Additional gpio pins
150
151 pin_name_t int_pin;
152
153 // static variable
154
155 uint32_t i2c_speed;
156 uint8_t i2c_address;
157
159 // End types group
161// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
162
168#ifdef __cplusplus
169extern "C"{
170#endif
171
181
191
200
211void ambient11_generic_write ( ambient11_t *ctx, uint8_t wr_cmd, uint16_t wr_data );
212
223uint16_t ambient11_generic_read ( ambient11_t *ctx, uint8_t reg_addr );
224
237float ambient11_calc_illumination ( ambient11_t *ctx, float typical_res );
238
247
248#ifdef __cplusplus
249}
250#endif
251#endif // _AMBIENT11_H_
252 // End public_function group
255
256// ------------------------------------------------------------------------- END
#define AMBIENT11_RETVAL
Definition: ambient11.h:63
uint16_t ambient11_generic_read(ambient11_t *ctx, uint8_t reg_addr)
Generic read function.
uint8_t ambient11_check_int(ambient11_t *ctx)
Check interrupt function.
void ambient11_cfg_setup(ambient11_cfg_t *cfg)
Config Object Initialization function.
float ambient11_calc_illumination(ambient11_t *ctx, float typical_res)
Calculate Illumination function.
void ambient11_default_cfg(ambient11_t *ctx)
Click Default Configuration function.
void ambient11_generic_write(ambient11_t *ctx, uint8_t wr_cmd, uint16_t wr_data)
Generic write function.
AMBIENT11_RETVAL ambient11_init(ambient11_t *ctx, ambient11_cfg_t *cfg)
Initialization function.
Click configuration structure definition.
Definition: ambient11.h:143
uint32_t i2c_speed
Definition: ambient11.h:155
pin_name_t scl
Definition: ambient11.h:146
pin_name_t int_pin
Definition: ambient11.h:151
pin_name_t sda
Definition: ambient11.h:147
uint8_t i2c_address
Definition: ambient11.h:156
Click ctx object definition.
Definition: ambient11.h:122
digital_in_t int_pin
Definition: ambient11.h:127
i2c_master_t i2c
Definition: ambient11.h:131
uint8_t slave_address
Definition: ambient11.h:135