Go to the documentation of this file.
35 #include "mikrosdk_version.h"
38 #if mikroSDK_GET_VERSION < 20800ul
39 #include "rcu_delays.h"
45 #include "drv_digital_out.h"
46 #include "drv_digital_in.h"
47 #include "drv_i2c_master.h"
69 #define AMBIENT19_REG_SYSM_CTRL 0x00
70 #define AMBIENT19_REG_INT_CTRL 0x01
71 #define AMBIENT19_REG_INT_FLAG 0x02
72 #define AMBIENT19_REG_WAIT_TIME 0x03
73 #define AMBIENT19_REG_ALS_GAIN 0x04
74 #define AMBIENT19_REG_ALS_TIME 0x05
75 #define AMBIENT19_REG_LED_CTRL 0x06
76 #define AMBIENT19_REG_PS_GAIN 0x07
77 #define AMBIENT19_REG_PS_PULSE 0x08
78 #define AMBIENT19_REG_PS_TIME 0x09
79 #define AMBIENT19_REG_PERSISTENCE 0x0B
80 #define AMBIENT19_REG_ALS_THRES_LL 0x0C
81 #define AMBIENT19_REG_ALS_THRES_LH 0x0D
82 #define AMBIENT19_REG_ALS_THRES_HL 0x0E
83 #define AMBIENT19_REG_ALS_THRES_HH 0x0F
84 #define AMBIENT19_REG_PS_THRES_LL 0x10
85 #define AMBIENT19_REG_PS_THRES_LH 0x11
86 #define AMBIENT19_REG_PS_THRES_HL 0x12
87 #define AMBIENT19_REG_PS_THRES_HH 0x13
88 #define AMBIENT19_REG_PS_OFFSET_L 0x14
89 #define AMBIENT19_REG_PS_OFFSET_H 0x15
90 #define AMBIENT19_REG_INT_SOURCE 0x16
91 #define AMBIENT19_REG_ERROR_FLAG 0x17
92 #define AMBIENT19_REG_PS_DATA_L 0x18
93 #define AMBIENT19_REG_PS_DATA_H 0x19
94 #define AMBIENT19_REG_IR_DATA_L 0x1A
95 #define AMBIENT19_REG_IR_DATA_H 0x1B
96 #define AMBIENT19_REG_CH0_DATA_L 0x1C
97 #define AMBIENT19_REG_CH0_DATA_H 0x1D
98 #define AMBIENT19_REG_CH1_DATA_L 0x1E
99 #define AMBIENT19_REG_CH1_DATA_H 0x1F
100 #define AMBIENT19_REG_PNO_LB 0xBC
101 #define AMBIENT19_REG_PNO_HB 0xBD
119 #define AMBIENT19_SYSM_CTRL_SWRST 0x80
120 #define AMBIENT19_SYSM_EN_WAIT 0x40
121 #define AMBIENT19_SYSM_EN_PS 0x02
122 #define AMBIENT19_SYSM_EN_ALS 0x01
128 #define AMBIENT19_INT_CTRL_PS_INT_MODE 0x80
129 #define AMBIENT19_INT_CTRL_SINT_MODE 0x40
130 #define AMBIENT19_INT_CTRL_PS_SYNC 0x20
131 #define AMBIENT19_INT_CTRL_ALS_SYNC 0x10
132 #define AMBIENT19_INT_CTRL_EN_PINT 0x02
133 #define AMBIENT19_INT_CTRL_EN_AINT 0x01
139 #define AMBIENT19_INT_FLAG_INT_POR 0x80
140 #define AMBIENT19_INT_FLAG_DATA_FLAG 0x40
141 #define AMBIENT19_INT_FLAG_OBJ 0x20
142 #define AMBIENT19_INT_FLAG_INT_PS 0x02
143 #define AMBIENT19_INT_FLAG_INT_ALS 0x01
149 #define AMBIENT19_WAIT_TIME_MAX 1280.0
150 #define AMBIENT19_WAIT_TIME_MIN 5.0
151 #define AMBIENT19_WAIT_TIME_STEP 5.0
152 #define AMBIENT19_WAIT_TIME_DEFAULT 100.0
158 #define AMBIENT19_ALS_GAIN_1X 0x00
159 #define AMBIENT19_ALS_GAIN_4X 0x01
160 #define AMBIENT19_ALS_GAIN_8X 0x02
161 #define AMBIENT19_ALS_GAIN_32X 0x03
162 #define AMBIENT19_ALS_GAIN_96X 0x04
168 #define AMBIENT19_ALS_TIME_MAX 674.888
169 #define AMBIENT19_ALS_TIME_MIN 5.513
170 #define AMBIENT19_ALS_TIME_STEP 2.625
171 #define AMBIENT19_ALS_TIME_DEFAULT 400.0
177 #define AMBIENT19_LED_CTRL_IRDR_SEL_50mA 0x00
178 #define AMBIENT19_LED_CTRL_IRDR_SEL_100mA 0x40
179 #define AMBIENT19_LED_CTRL_IRDR_SEL_150mA 0x80
180 #define AMBIENT19_LED_CTRL_IRDR_SEL_200mA 0xC0
181 #define AMBIENT19_LED_CTRL_IRDR_SEL_BIT_MASK 0xC0
182 #define AMBIENT19_LED_CTRL_ITW_PS_MAX 875.213
183 #define AMBIENT19_LED_CTRL_ITW_PS_MIN 13.675
184 #define AMBIENT19_LED_CTRL_ITW_PS_STEP 13.675
185 #define AMBIENT19_LED_CTRL_ITW_PS_BIT_MASK 0x3F
191 #define AMBIENT19_PS_GAIN_1X 0x00
192 #define AMBIENT19_PS_GAIN_2X 0x01
193 #define AMBIENT19_PS_GAIN_4X 0x02
194 #define AMBIENT19_PS_GAIN_8X 0x03
200 #define AMBIENT19_PS_TIME_MAX_COUNT_4095 0x0F
206 #define AMBIENT19_PERSISTANCE_EVERY_ALS_CONV 0x00
212 #define AMBIENT19_INT_SOURCE_CH0_DATA 0x00
213 #define AMBIENT19_INT_SOURCE_CH1_DATA 0x01
219 #define AMBIENT19_LUX_K1 0.52
220 #define AMBIENT19_LUX_K2 0.94
221 #define AMBIENT19_LUX_K3 1.12 // calculated using lux meter
227 #define AMBIENT19_PRODUCT_NUM_LOW 0x14
228 #define AMBIENT19_PRODUCT_NUM_HIGH 0x16
235 #define AMBIENT19_DEVICE_ADDRESS 0x38
253 #define AMBIENT19_MAP_MIKROBUS( cfg, mikrobus ) \
254 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
255 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
256 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
537 #endif // AMBIENT19_H
pin_name_t sda
Definition: ambient19.h:288
pin_name_t int_pin
Definition: ambient19.h:290
err_t ambient19_read_register(ambient19_t *ctx, uint8_t reg, uint8_t *data_out)
Ambient 19 read register function.
err_t ambient19_default_cfg(ambient19_t *ctx)
Ambient 19 default configuration function.
Ambient 19 Click context object.
Definition: ambient19.h:266
Ambient 19 Click configuration object.
Definition: ambient19.h:286
uint8_t slave_address
Definition: ambient19.h:274
void ambient19_cfg_setup(ambient19_cfg_t *cfg)
Ambient 19 configuration object setup function.
err_t ambient19_set_als_time(ambient19_t *ctx, float als_time_ms)
Ambient 19 set als time function.
err_t ambient19_read_raw_als(ambient19_t *ctx, uint16_t *ch_0, uint16_t *ch_1)
Ambient 19 read raw als function.
ambient19_return_value_t
Ambient 19 Click return value data.
Definition: ambient19.h:302
err_t ambient19_init(ambient19_t *ctx, ambient19_cfg_t *cfg)
Ambient 19 initialization function.
err_t ambient19_generic_write(ambient19_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
Ambient 19 I2C writing function.
uint8_t pga_als
Definition: ambient19.h:276
@ AMBIENT19_ERROR
Definition: ambient19.h:304
uint8_t alsconv
Definition: ambient19.h:277
err_t ambient19_set_wait_time(ambient19_t *ctx, float wait_time_ms)
Ambient 19 set wait time function.
digital_in_t int_pin
Definition: ambient19.h:268
uint8_t ambient19_get_int_pin(ambient19_t *ctx)
Ambient 19 get INT pin function.
err_t ambient19_write_register(ambient19_t *ctx, uint8_t reg, uint8_t data_in)
Ambient 19 write register function.
err_t ambient19_read_raw_proximity(ambient19_t *ctx, uint16_t *ps_data, uint16_t *ir_data)
Ambient 19 read raw proximity function.
pin_name_t scl
Definition: ambient19.h:287
@ AMBIENT19_OK
Definition: ambient19.h:303
uint8_t i2c_address
Definition: ambient19.h:293
err_t ambient19_generic_read(ambient19_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
Ambient 19 I2C reading function.
err_t ambient19_check_communication(ambient19_t *ctx)
Ambient 19 check communication function.
err_t ambient19_set_als_gain(ambient19_t *ctx, uint8_t als_gain)
Ambient 19 set als gain function.
i2c_master_t i2c
Definition: ambient19.h:271
uint32_t i2c_speed
Definition: ambient19.h:292
err_t ambient19_clear_interrupts(ambient19_t *ctx)
Ambient 19 clear interrupts function.
err_t ambient19_measure_light_level(ambient19_t *ctx, uint16_t *lux)
Ambient 19 measure light level function.