Go to the documentation of this file.
35 #include "drv_digital_out.h"
36 #include "drv_digital_in.h"
37 #include "drv_i2c_master.h"
38 #include "drv_spi_master.h"
62 #define IRSENSE4_REG_LPF1 0x0C
63 #define IRSENSE4_REG_LPF2 0x0D
64 #define IRSENSE4_REG_WHO_AM_I 0x0F
65 #define IRSENSE4_REG_AVG_TRIM 0x10
66 #define IRSENSE4_REG_CTRL0 0x17
67 #define IRSENSE4_REG_SENS_DATA 0x1D
68 #define IRSENSE4_REG_CTRL1 0x20
69 #define IRSENSE4_REG_CTRL2 0x21
70 #define IRSENSE4_REG_CTRL3 0x22
71 #define IRSENSE4_REG_STATUS 0x23
72 #define IRSENSE4_REG_FUNC_STATUS 0x25
73 #define IRSENSE4_REG_TOBJECT_L 0x26
74 #define IRSENSE4_REG_TOBJECT_H 0x27
75 #define IRSENSE4_REG_TAMBIENT_L 0x28
76 #define IRSENSE4_REG_TAMBIENT_H 0x29
77 #define IRSENSE4_REG_TOBJ_COMP_L 0x38
78 #define IRSENSE4_REG_TOBJ_COMP_H 0x39
79 #define IRSENSE4_REG_TPRESENCE_L 0x3A
80 #define IRSENSE4_REG_TPRESENCE_H 0x3B
81 #define IRSENSE4_REG_TMOTION_L 0x3C
82 #define IRSENSE4_REG_TMOTION_H 0x3D
83 #define IRSENSE4_REG_TAMB_SHOCK_L 0x3E
84 #define IRSENSE4_REG_TAMB_SHOCK_H 0x3F
90 #define IRSENSE4_REG_EMB_FUNC_CFG_ADDR 0x08
91 #define IRSENSE4_REG_EMB_FUNC_CFG_DATA 0x09
92 #define IRSENSE4_REG_EMB_PAGE_RW 0x11
93 #define IRSENSE4_REG_EMB_PRESENCE_THS_L 0x20
94 #define IRSENSE4_REG_EMB_PRESENCE_THS_H 0x21
95 #define IRSENSE4_REG_EMB_MOTION_THS_L 0x22
96 #define IRSENSE4_REG_EMB_MOTION_THS_H 0x23
97 #define IRSENSE4_REG_EMB_TAMB_SHOCK_THS_L 0x24
98 #define IRSENSE4_REG_EMB_TAMB_SHOCK_THS_H 0x25
99 #define IRSENSE4_REG_EMB_HYST_MOTION 0x26
100 #define IRSENSE4_REG_EMB_HYST_PRESENCE 0x27
101 #define IRSENSE4_REG_EMB_ALGO_CONFIG 0x28
102 #define IRSENSE4_REG_EMB_HYST_TAMB_SHOCK 0x29
103 #define IRSENSE4_REG_EMB_RESET_ALGO 0x2A
122 #define IRSENSE4_LPF1_M_ODR_9 0x00
123 #define IRSENSE4_LPF1_M_ODR_20 0x01
124 #define IRSENSE4_LPF1_M_ODR_50 0x02
125 #define IRSENSE4_LPF1_M_ODR_100 0x03
126 #define IRSENSE4_LPF1_M_ODR_200 0x04
127 #define IRSENSE4_LPF1_M_ODR_400 0x05
128 #define IRSENSE4_LPF1_M_ODR_800 0x06
129 #define IRSENSE4_LPF1_M_BIT_MASK 0x07
130 #define IRSENSE4_LPF1_P_M_ODR_9 0x00
131 #define IRSENSE4_LPF1_P_M_ODR_20 0x08
132 #define IRSENSE4_LPF1_P_M_ODR_50 0x10
133 #define IRSENSE4_LPF1_P_M_ODR_100 0x18
134 #define IRSENSE4_LPF1_P_M_ODR_200 0x20
135 #define IRSENSE4_LPF1_P_M_ODR_400 0x28
136 #define IRSENSE4_LPF1_P_M_ODR_800 0x30
144 #define IRSENSE4_LPF2_A_T_ODR_9 0x00
145 #define IRSENSE4_LPF2_A_T_ODR_20 0x01
146 #define IRSENSE4_LPF2_A_T_ODR_50 0x02
147 #define IRSENSE4_LPF2_A_T_ODR_100 0x03
148 #define IRSENSE4_LPF2_A_T_ODR_200 0x04
149 #define IRSENSE4_LPF2_A_T_ODR_400 0x05
150 #define IRSENSE4_LPF2_A_T_ODR_800 0x06
151 #define IRSENSE4_LPF2_A_T_BIT_MASK 0x07
152 #define IRSENSE4_LPF2_P_ODR_9 0x00
153 #define IRSENSE4_LPF2_P_ODR_20 0x08
154 #define IRSENSE4_LPF2_P_ODR_50 0x10
155 #define IRSENSE4_LPF2_P_ODR_100 0x18
156 #define IRSENSE4_LPF2_P_ODR_200 0x20
157 #define IRSENSE4_LPF2_P_ODR_400 0x28
158 #define IRSENSE4_LPF2_P_ODR_800 0x30
159 #define IRSENSE4_LPF2_P_BIT_MASK 0x38
166 #define IRSENSE4_DEVICE_ID 0xD3
174 #define IRSENSE4_AVG_TRIM_TMOS_2 0x00
175 #define IRSENSE4_AVG_TRIM_TMOS_8 0x01
176 #define IRSENSE4_AVG_TRIM_TMOS_32 0x02
177 #define IRSENSE4_AVG_TRIM_TMOS_128 0x03
178 #define IRSENSE4_AVG_TRIM_TMOS_256 0x04
179 #define IRSENSE4_AVG_TRIM_TMOS_512 0x05
180 #define IRSENSE4_AVG_TRIM_TMOS_1024 0x06
181 #define IRSENSE4_AVG_TRIM_TMOS_2048 0x07
182 #define IRSENSE4_AVG_TRIM_TMOS_BIT_MASK 0x07
183 #define IRSENSE4_AVG_TRIM_T_8 0x00
184 #define IRSENSE4_AVG_TRIM_T_4 0x10
185 #define IRSENSE4_AVG_TRIM_T_2 0x20
186 #define IRSENSE4_AVG_TRIM_T_1 0x30
187 #define IRSENSE4_AVG_TRIM_T_BIT_MASK 0x30
193 #define IRSENSE4_CTRL0_GAIN_1 0x00
194 #define IRSENSE4_CTRL0_GAIN_2 0x10
195 #define IRSENSE4_CTRL0_GAIN_3 0x20
196 #define IRSENSE4_CTRL0_GAIN_4 0x30
197 #define IRSENSE4_CTRL0_GAIN_5 0x40
198 #define IRSENSE4_CTRL0_GAIN_6 0x50
199 #define IRSENSE4_CTRL0_GAIN_7 0x60
200 #define IRSENSE4_CTRL0_GAIN_8 0x70
201 #define IRSENSE4_CTRL0_DEFAULT 0x81
208 #define IRSENSE4_SENS_DATA_CALC_DEV 16u
209 #define IRSENSE4_SENS_DATA_MIN 2048u
210 #define IRSENSE4_SENS_DATA_MAX 6128u
217 #define IRSENSE4_CTRL1_ODR_POWER_DOWN 0x00
218 #define IRSENSE4_CTRL1_ODR_0_25 0x01
219 #define IRSENSE4_CTRL1_ODR_0_5 0x02
220 #define IRSENSE4_CTRL1_ODR_1 0x03
221 #define IRSENSE4_CTRL1_ODR_2 0x04
222 #define IRSENSE4_CTRL1_ODR_4 0x05
223 #define IRSENSE4_CTRL1_ODR_8 0x06
224 #define IRSENSE4_CTRL1_ODR_15 0x07
225 #define IRSENSE4_CTRL1_ODR_30 0x08
226 #define IRSENSE4_CTRL1_ODR_BIT_MASK 0x0F
227 #define IRSENSE4_CTRL1_BDU_DIS 0x00
228 #define IRSENSE4_CTRL1_BDU_EN 0x01
234 #define IRSENSE4_CTRL2_ONE_SHOT_DIS 0x00
235 #define IRSENSE4_CTRL2_ONE_SHOT_EN 0x01
236 #define IRSENSE4_CTRL2_F_CFG_ACCESS_DIS 0x00
237 #define IRSENSE4_CTRL2_F_CFG_ACCESS_EN 0x10
243 #define IRSENSE4_CTRL3_IEN_HIGH_Z 0x00
244 #define IRSENSE4_CTRL3_IEN_DRDY 0x01
245 #define IRSENSE4_CTRL3_IEN_INT_OR 0x02
246 #define IRSENSE4_CTRL3_IEN_BIT_MASK 0x03
247 #define IRSENSE4_CTRL3_INT_LATCHED_PLS 0x00
248 #define IRSENSE4_CTRL3_INT_LATCHED_LAT 0x04
249 #define IRSENSE4_CTRL3_INT_MSK_T_SHOCK 0x08
250 #define IRSENSE4_CTRL3_INT_MSK_MOT 0x10
251 #define IRSENSE4_CTRL3_INT_MSK_PRES 0x20
252 #define IRSENSE4_CTRL3_PP_OD_PUSH_PULL 0x00
253 #define IRSENSE4_CTRL3_PP_OD_OPEN_DRAIN 0x04
254 #define IRSENSE4_CTRL3_INT_H_L_HIGH 0x00
255 #define IRSENSE4_CTRL3_INT_H_L_LOW 0x80
256 #define IRSENSE4_CTRL3_BIT_MASK 0x38
262 #define IRSENSE4_STATUS_TAMB_SHOCK_FLAG 0x01
263 #define IRSENSE4_STATUS_MOT_FLAG 0x02
264 #define IRSENSE4_STATUS_PRES_FLAG 0x04
265 #define IRSENSE4_STATUS_DETECT_FLAG 0x07
266 #define IRSENSE4_STATUS_NOT_DRDY 0x00
267 #define IRSENSE4_STATUS_DRDY 0x04
274 #define IRSENSE4_SET_THS_PRESENCE_DEFAULT 5000u
275 #define IRSENSE4_SET_THS_MOTION_DEFAULT 3000u
276 #define IRSENSE4_SET_THS_T_SHOCK_DEFAULT 2000u
277 #define IRSENSE4_SET_THS_MAX 0x7FFFu
284 #define IRSENSE4_SENS_TOBJECT 2000.0f
285 #define IRSENSE4_SENS_TAMBIENT 100.0f
286 #define IRSENSE4_SENS_TOBJ_COMP 2000.0f
293 #define IRSENSE4_EMB_PAGE_RW_READ_DIS 0x00
294 #define IRSENSE4_EMB_PAGE_RW_READ_EN 0x20
295 #define IRSENSE4_EMB_PAGE_RW_WRITE_DIS 0x00
296 #define IRSENSE4_EMB_PAGE_RW_WRITE_EN 0x40
303 #define IRSENSE4_DEVICE_ADDRESS 0x5A
313 #define IRSENSE4_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
314 #define IRSENSE4_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
332 #define IRSENSE4_MAP_MIKROBUS( cfg, mikrobus ) \
333 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
334 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
335 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
336 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
337 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
338 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
339 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
@ IRSENSE4_THS_TAMB_SHOCK
Definition: irsense4.h:425
err_t irsense4_set_lp_filter_presence(irsense4_t *ctx, uint8_t lpf_p)
IR Sense 4 set low-pass filter for presence function.
spi_master_chip_select_polarity_t cs_polarity
Definition: irsense4.h:400
uint8_t i2c_address
Definition: irsense4.h:396
err_t irsense4_set_sens_data(irsense4_t *ctx, uint16_t sens)
IR Sense 4 set sensitivity data function.
err_t irsense4_get_presence_data(irsense4_t *ctx, int16_t *presence)
IR Sense 4 get the presence detection data function.
pin_name_t sda
Definition: irsense4.h:388
err_t irsense4_init(irsense4_t *ctx, irsense4_cfg_t *cfg)
IR Sense 4 initialization function.
@ IRSENSE4_OK
Definition: irsense4.h:412
err_t irsense4_config_odr(irsense4_t *ctx, uint8_t odr)
IR Sense 4 set output data rate function.
pin_name_t scl
Definition: irsense4.h:387
irsense4_drv_t
IR Sense 4 Click driver selector.
Definition: irsense4.h:349
err_t irsense4_set_avr_temp(irsense4_t *ctx, uint8_t avr_amp_temp, uint8_t avr_obj_temp)
IR Sense 4 set averages for temperature function.
err_t irsense4_generic_write(irsense4_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
IR Sense 4 data writing function.
IR Sense 4 Click context object.
Definition: irsense4.h:366
This file contains SPI specific macros, functions, etc.
irsense4_drv_t drv_sel
Definition: irsense4.h:374
err_t irsense4_read_emb_reg(irsense4_t *ctx, uint8_t reg_emb, uint8_t *data_out)
IR Sense 4 write register function.
irsense4_master_io_t read_f
Definition: irsense4.h:377
err_t irsense4_wait_new_data_ready(irsense4_t *ctx)
IR Sense 4 wait new data ready function.
IR Sense 4 Click configuration object.
Definition: irsense4.h:386
err_t irsense4_get_amb_temperature(irsense4_t *ctx, float *temperature)
IR Sense 4 get the ambient temperature function.
err_t irsense4_get_motion_data(irsense4_t *ctx, int16_t *motion)
IR Sense 4 get the motion detection data function.
err_t irsense4_default_cfg(irsense4_t *ctx)
IR Sense 4 default configuration function.
@ IRSENSE4_ERROR
Definition: irsense4.h:413
irsense4_drv_t drv_sel
Definition: irsense4.h:402
@ IRSENSE4_DRV_SEL_SPI
Definition: irsense4.h:350
err_t irsense4_write_reg(irsense4_t *ctx, uint8_t reg, uint8_t data_in)
IR Sense 4 write register function.
err_t irsense4_get_obj_temperature(irsense4_t *ctx, float *temperature)
IR Sense 4 get the object temperature function.
err_t irsense4_set_int_mask(irsense4_t *ctx, uint8_t int_mask)
IR Sense 4 set interrupt masks for flag function.
err_t irsense4_get_threshold(irsense4_t *ctx, irsense4_ths_sel_t ths_sel, uint16_t *threshold)
IR Sense 4 get the threshold data function.
pin_name_t chip_select
Definition: irsense4.h:373
pin_name_t sck
Definition: irsense4.h:391
void irsense4_cfg_setup(irsense4_cfg_t *cfg)
IR Sense 4 configuration object setup function.
err_t irsense4_set_gain_mode(irsense4_t *ctx, uint8_t gain_mode)
IR Sense 4 set gain mode function.
pin_name_t int_pin
Definition: irsense4.h:393
spi_master_t spi
Definition: irsense4.h:370
irsense4_master_io_t write_f
Definition: irsense4.h:376
err_t irsense4_get_amb_shock_data(irsense4_t *ctx, int16_t *shock)
IR Sense 4 get the ambient shock detection data function.
err_t irsense4_get_comp_temperature(irsense4_t *ctx, float *temperature)
IR Sense 4 get the compensated temperature function.
spi_master_mode_t spi_mode
Definition: irsense4.h:399
i2c_master_t i2c
Definition: irsense4.h:369
err_t irsense4_generic_read(irsense4_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
IR Sense 4 data reading function.
pin_name_t miso
Definition: irsense4.h:389
err_t irsense4_read_word(irsense4_t *ctx, uint8_t reg, int16_t *data_out)
IR Sense 4 read word function.
uint32_t i2c_speed
Definition: irsense4.h:395
uint32_t spi_speed
Definition: irsense4.h:398
err_t irsense4_set_lp_filter_motion(irsense4_t *ctx, uint8_t lpf_m)
IR Sense 4 set low-pass filter for motion function.
err_t irsense4_get_status(irsense4_t *ctx, uint8_t *status)
IR Sense 4 get status function.
err_t irsense4_enable_one_shot(irsense4_t *ctx)
IR Sense 4 enable one-shot mode function.
irsense4_ths_sel_t
IR Sense 4 Click threshold selection data value for detection algorithm.
Definition: irsense4.h:422
err_t(* irsense4_master_io_t)(struct irsense4_s *, uint8_t, uint8_t *, uint8_t)
IR Sense 4 Click driver interface.
Definition: irsense4.h:359
digital_in_t int_pin
Definition: irsense4.h:367
uint8_t slave_address
Definition: irsense4.h:372
err_t irsense4_set_lp_filter_amb_temp(irsense4_t *ctx, uint8_t lpf_at)
IR Sense 4 set low-pass filter for ambient temperature function.
@ IRSENSE4_THS_PRESENCE
Definition: irsense4.h:423
irsense4_return_value_t
IR Sense 4 Click return value data.
Definition: irsense4.h:411
err_t irsense4_get_device_id(irsense4_t *ctx, uint8_t *device_id)
IR Sense 4 get device ID function.
err_t irsense4_read_reg(irsense4_t *ctx, uint8_t reg, uint8_t *data_out)
IR Sense 4 read register function.
void irsense4_drv_interface_selection(irsense4_cfg_t *cfg, irsense4_drv_t drv_sel)
IR Sense 4 driver interface setup function.
@ IRSENSE4_DRV_SEL_I2C
Definition: irsense4.h:351
struct irsense4_s irsense4_t
IR Sense 4 Click context object.
pin_name_t mosi
Definition: irsense4.h:390
pin_name_t cs
Definition: irsense4.h:392
err_t irsense4_set_threshold(irsense4_t *ctx, irsense4_ths_sel_t ths_sel, uint16_t threshold)
IR Sense 4 set threshold data function.
err_t irsense4_write_emb_reg(irsense4_t *ctx, uint8_t reg_emb, uint8_t data_in)
IR Sense 4 write the embedded register function.
@ IRSENSE4_THS_MOTION
Definition: irsense4.h:424
err_t irsense4_config_int_signal(irsense4_t *ctx, uint8_t int_sr)
IR Sense 4 configur interrupt the signal function.