irsense4 2.1.0.0
irsense4.h File Reference

This file contains API for IR Sense 4 Click Driver. More...

#include "drv_digital_out.h"
#include "drv_digital_in.h"
#include "drv_i2c_master.h"
#include "drv_spi_master.h"
#include "spi_specifics.h"

Go to the source code of this file.

Data Structures

struct  irsense4_s
 IR Sense 4 Click context object. More...
 
struct  irsense4_cfg_t
 IR Sense 4 Click configuration object. More...
 

Macros

#define IRSENSE4_REG_LPF1   0x0C
 IR Sense 4 description register.
 
#define IRSENSE4_REG_LPF2   0x0D
 
#define IRSENSE4_REG_WHO_AM_I   0x0F
 
#define IRSENSE4_REG_AVG_TRIM   0x10
 
#define IRSENSE4_REG_CTRL0   0x17
 
#define IRSENSE4_REG_SENS_DATA   0x1D
 
#define IRSENSE4_REG_CTRL1   0x20
 
#define IRSENSE4_REG_CTRL2   0x21
 
#define IRSENSE4_REG_CTRL3   0x22
 
#define IRSENSE4_REG_STATUS   0x23
 
#define IRSENSE4_REG_FUNC_STATUS   0x25
 
#define IRSENSE4_REG_TOBJECT_L   0x26
 
#define IRSENSE4_REG_TOBJECT_H   0x27
 
#define IRSENSE4_REG_TAMBIENT_L   0x28
 
#define IRSENSE4_REG_TAMBIENT_H   0x29
 
#define IRSENSE4_REG_TOBJ_COMP_L   0x38
 
#define IRSENSE4_REG_TOBJ_COMP_H   0x39
 
#define IRSENSE4_REG_TPRESENCE_L   0x3A
 
#define IRSENSE4_REG_TPRESENCE_H   0x3B
 
#define IRSENSE4_REG_TMOTION_L   0x3C
 
#define IRSENSE4_REG_TMOTION_H   0x3D
 
#define IRSENSE4_REG_TAMB_SHOCK_L   0x3E
 
#define IRSENSE4_REG_TAMB_SHOCK_H   0x3F
 
#define IRSENSE4_REG_EMB_FUNC_CFG_ADDR   0x08
 IR Sense 4 description embedded register.
 
#define IRSENSE4_REG_EMB_FUNC_CFG_DATA   0x09
 
#define IRSENSE4_REG_EMB_PAGE_RW   0x11
 
#define IRSENSE4_REG_EMB_PRESENCE_THS_L   0x20
 
#define IRSENSE4_REG_EMB_PRESENCE_THS_H   0x21
 
#define IRSENSE4_REG_EMB_MOTION_THS_L   0x22
 
#define IRSENSE4_REG_EMB_MOTION_THS_H   0x23
 
#define IRSENSE4_REG_EMB_TAMB_SHOCK_THS_L   0x24
 
#define IRSENSE4_REG_EMB_TAMB_SHOCK_THS_H   0x25
 
#define IRSENSE4_REG_EMB_HYST_MOTION   0x26
 
#define IRSENSE4_REG_EMB_HYST_PRESENCE   0x27
 
#define IRSENSE4_REG_EMB_ALGO_CONFIG   0x28
 
#define IRSENSE4_REG_EMB_HYST_TAMB_SHOCK   0x29
 
#define IRSENSE4_REG_EMB_RESET_ALGO   0x2A
 
#define IRSENSE4_LPF1_M_ODR_9   0x00
 IR Sense 4 description of low-pass filter configuration for motion and presence detection.
 
#define IRSENSE4_LPF1_M_ODR_20   0x01
 
#define IRSENSE4_LPF1_M_ODR_50   0x02
 
#define IRSENSE4_LPF1_M_ODR_100   0x03
 
#define IRSENSE4_LPF1_M_ODR_200   0x04
 
#define IRSENSE4_LPF1_M_ODR_400   0x05
 
#define IRSENSE4_LPF1_M_ODR_800   0x06
 
#define IRSENSE4_LPF1_M_BIT_MASK   0x07
 
#define IRSENSE4_LPF1_P_M_ODR_9   0x00
 
#define IRSENSE4_LPF1_P_M_ODR_20   0x08
 
#define IRSENSE4_LPF1_P_M_ODR_50   0x10
 
#define IRSENSE4_LPF1_P_M_ODR_100   0x18
 
#define IRSENSE4_LPF1_P_M_ODR_200   0x20
 
#define IRSENSE4_LPF1_P_M_ODR_400   0x28
 
#define IRSENSE4_LPF1_P_M_ODR_800   0x30
 
#define IRSENSE4_LPF2_A_T_ODR_9   0x00
 IR Sense 4 description of low-pass filter configuration for ambient temperature and presence detection.
 
#define IRSENSE4_LPF2_A_T_ODR_20   0x01
 
#define IRSENSE4_LPF2_A_T_ODR_50   0x02
 
#define IRSENSE4_LPF2_A_T_ODR_100   0x03
 
#define IRSENSE4_LPF2_A_T_ODR_200   0x04
 
#define IRSENSE4_LPF2_A_T_ODR_400   0x05
 
#define IRSENSE4_LPF2_A_T_ODR_800   0x06
 
#define IRSENSE4_LPF2_A_T_BIT_MASK   0x07
 
#define IRSENSE4_LPF2_P_ODR_9   0x00
 
#define IRSENSE4_LPF2_P_ODR_20   0x08
 
#define IRSENSE4_LPF2_P_ODR_50   0x10
 
#define IRSENSE4_LPF2_P_ODR_100   0x18
 
#define IRSENSE4_LPF2_P_ODR_200   0x20
 
#define IRSENSE4_LPF2_P_ODR_400   0x28
 
#define IRSENSE4_LPF2_P_ODR_800   0x30
 
#define IRSENSE4_LPF2_P_BIT_MASK   0x38
 
#define IRSENSE4_DEVICE_ID   0xD3
 IR Sense 4 description of device identification value.
 
#define IRSENSE4_AVG_TRIM_TMOS_2   0x00
 IR Sense 4 description of selection number of averages for ambient and object temperature.
 
#define IRSENSE4_AVG_TRIM_TMOS_8   0x01
 
#define IRSENSE4_AVG_TRIM_TMOS_32   0x02
 
#define IRSENSE4_AVG_TRIM_TMOS_128   0x03
 
#define IRSENSE4_AVG_TRIM_TMOS_256   0x04
 
#define IRSENSE4_AVG_TRIM_TMOS_512   0x05
 
#define IRSENSE4_AVG_TRIM_TMOS_1024   0x06
 
#define IRSENSE4_AVG_TRIM_TMOS_2048   0x07
 
#define IRSENSE4_AVG_TRIM_TMOS_BIT_MASK   0x07
 
#define IRSENSE4_AVG_TRIM_T_8   0x00
 
#define IRSENSE4_AVG_TRIM_T_4   0x10
 
#define IRSENSE4_AVG_TRIM_T_2   0x20
 
#define IRSENSE4_AVG_TRIM_T_1   0x30
 
#define IRSENSE4_AVG_TRIM_T_BIT_MASK   0x30
 
#define IRSENSE4_CTRL0_GAIN_1   0x00
 IR Sense 4 description of temperature gain mode.
 
#define IRSENSE4_CTRL0_GAIN_2   0x10
 
#define IRSENSE4_CTRL0_GAIN_3   0x20
 
#define IRSENSE4_CTRL0_GAIN_4   0x30
 
#define IRSENSE4_CTRL0_GAIN_5   0x40
 
#define IRSENSE4_CTRL0_GAIN_6   0x50
 
#define IRSENSE4_CTRL0_GAIN_7   0x60
 
#define IRSENSE4_CTRL0_GAIN_8   0x70
 
#define IRSENSE4_CTRL0_DEFAULT   0x81
 
#define IRSENSE4_SENS_DATA_CALC_DEV   16u
 IR Sense 4 description of sensitivity data of the component.
 
#define IRSENSE4_SENS_DATA_MIN   2048u
 
#define IRSENSE4_SENS_DATA_MAX   6128u
 
#define IRSENSE4_CTRL1_ODR_POWER_DOWN   0x00
 IR Sense 4 description of block data update for output and ODR configuration.
 
#define IRSENSE4_CTRL1_ODR_0_25   0x01
 
#define IRSENSE4_CTRL1_ODR_0_5   0x02
 
#define IRSENSE4_CTRL1_ODR_1   0x03
 
#define IRSENSE4_CTRL1_ODR_2   0x04
 
#define IRSENSE4_CTRL1_ODR_4   0x05
 
#define IRSENSE4_CTRL1_ODR_8   0x06
 
#define IRSENSE4_CTRL1_ODR_15   0x07
 
#define IRSENSE4_CTRL1_ODR_30   0x08
 
#define IRSENSE4_CTRL1_ODR_BIT_MASK   0x0F
 
#define IRSENSE4_CTRL1_BDU_DIS   0x00
 
#define IRSENSE4_CTRL1_BDU_EN   0x01
 
#define IRSENSE4_CTRL2_ONE_SHOT_DIS   0x00
 IR Sense 4 description of one shot mode.
 
#define IRSENSE4_CTRL2_ONE_SHOT_EN   0x01
 
#define IRSENSE4_CTRL2_F_CFG_ACCESS_DIS   0x00
 
#define IRSENSE4_CTRL2_F_CFG_ACCESS_EN   0x10
 
#define IRSENSE4_CTRL3_IEN_HIGH_Z   0x00
 IR Sense 4 description of interrupt configuration.
 
#define IRSENSE4_CTRL3_IEN_DRDY   0x01
 
#define IRSENSE4_CTRL3_IEN_INT_OR   0x02
 
#define IRSENSE4_CTRL3_IEN_BIT_MASK   0x03
 
#define IRSENSE4_CTRL3_INT_LATCHED_PLS   0x00
 
#define IRSENSE4_CTRL3_INT_LATCHED_LAT   0x04
 
#define IRSENSE4_CTRL3_INT_MSK_T_SHOCK   0x08
 
#define IRSENSE4_CTRL3_INT_MSK_MOT   0x10
 
#define IRSENSE4_CTRL3_INT_MSK_PRES   0x20
 
#define IRSENSE4_CTRL3_PP_OD_PUSH_PULL   0x00
 
#define IRSENSE4_CTRL3_PP_OD_OPEN_DRAIN   0x04
 
#define IRSENSE4_CTRL3_INT_H_L_HIGH   0x00
 
#define IRSENSE4_CTRL3_INT_H_L_LOW   0x80
 
#define IRSENSE4_CTRL3_BIT_MASK   0x38
 
#define IRSENSE4_STATUS_TAMB_SHOCK_FLAG   0x01
 IR Sense 4 description of status data ready value.
 
#define IRSENSE4_STATUS_MOT_FLAG   0x02
 
#define IRSENSE4_STATUS_PRES_FLAG   0x04
 
#define IRSENSE4_STATUS_DETECT_FLAG   0x07
 
#define IRSENSE4_STATUS_NOT_DRDY   0x00
 
#define IRSENSE4_STATUS_DRDY   0x04
 
#define IRSENSE4_SET_THS_PRESENCE_DEFAULT   5000u
 IR Sense 4 description of threshold default configuration.
 
#define IRSENSE4_SET_THS_MOTION_DEFAULT   3000u
 
#define IRSENSE4_SET_THS_T_SHOCK_DEFAULT   2000u
 
#define IRSENSE4_SET_THS_MAX   0x7FFFu
 
#define IRSENSE4_SENS_TOBJECT   2000.0f
 IR Sense 4 description of object, ambient and compensated temperature sensitivity values.
 
#define IRSENSE4_SENS_TAMBIENT   100.0f
 
#define IRSENSE4_SENS_TOBJ_COMP   2000.0f
 
#define IRSENSE4_EMB_PAGE_RW_READ_DIS   0x00
 IR Sense 4 description of embedded functions data values.
 
#define IRSENSE4_EMB_PAGE_RW_READ_EN   0x20
 
#define IRSENSE4_EMB_PAGE_RW_WRITE_DIS   0x00
 
#define IRSENSE4_EMB_PAGE_RW_WRITE_EN   0x40
 
#define IRSENSE4_DEVICE_ADDRESS   0x5A
 IR Sense 4 device address setting.
 
#define IRSENSE4_SET_DATA_SAMPLE_EDGE   SET_SPI_DATA_SAMPLE_EDGE
 Data sample selection.
 
#define IRSENSE4_SET_DATA_SAMPLE_MIDDLE   SET_SPI_DATA_SAMPLE_MIDDLE
 
#define IRSENSE4_MAP_MIKROBUS(cfg, mikrobus)
 MikroBUS pin mapping.
 

Typedefs

typedef err_t(* irsense4_master_io_t) (struct irsense4_s *, uint8_t, uint8_t *, uint8_t)
 IR Sense 4 Click driver interface.
 
typedef struct irsense4_s irsense4_t
 IR Sense 4 Click context object.
 

Enumerations

enum  irsense4_drv_t { IRSENSE4_DRV_SEL_SPI , IRSENSE4_DRV_SEL_I2C }
 IR Sense 4 Click driver selector. More...
 
enum  irsense4_return_value_t { IRSENSE4_OK = 0 , IRSENSE4_ERROR = -1 }
 IR Sense 4 Click return value data. More...
 
enum  irsense4_ths_sel_t { IRSENSE4_THS_PRESENCE = 0 , IRSENSE4_THS_MOTION = 2 , IRSENSE4_THS_TAMB_SHOCK = 4 }
 IR Sense 4 Click threshold selection data value for detection algorithm. More...
 

Functions

void irsense4_cfg_setup (irsense4_cfg_t *cfg)
 IR Sense 4 configuration object setup function.
 
void irsense4_drv_interface_selection (irsense4_cfg_t *cfg, irsense4_drv_t drv_sel)
 IR Sense 4 driver interface setup function.
 
err_t irsense4_init (irsense4_t *ctx, irsense4_cfg_t *cfg)
 IR Sense 4 initialization function.
 
err_t irsense4_default_cfg (irsense4_t *ctx)
 IR Sense 4 default configuration 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.
 
err_t irsense4_generic_read (irsense4_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
 IR Sense 4 data reading function.
 
err_t irsense4_write_reg (irsense4_t *ctx, uint8_t reg, uint8_t data_in)
 IR Sense 4 write register function.
 
err_t irsense4_read_reg (irsense4_t *ctx, uint8_t reg, uint8_t *data_out)
 IR Sense 4 read register function.
 
err_t irsense4_read_word (irsense4_t *ctx, uint8_t reg, int16_t *data_out)
 IR Sense 4 read word function.
 
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_set_lp_filter_presence (irsense4_t *ctx, uint8_t lpf_p)
 IR Sense 4 set low-pass filter for presence function.
 
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.
 
err_t irsense4_get_device_id (irsense4_t *ctx, uint8_t *device_id)
 IR Sense 4 get device ID function.
 
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_set_gain_mode (irsense4_t *ctx, uint8_t gain_mode)
 IR Sense 4 set gain mode function.
 
err_t irsense4_set_sens_data (irsense4_t *ctx, uint16_t sens)
 IR Sense 4 set sensitivity data function.
 
err_t irsense4_config_odr (irsense4_t *ctx, uint8_t odr)
 IR Sense 4 set output data rate function.
 
err_t irsense4_enable_one_shot (irsense4_t *ctx)
 IR Sense 4 enable one-shot mode 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_config_int_signal (irsense4_t *ctx, uint8_t int_sr)
 IR Sense 4 configur interrupt the signal function.
 
err_t irsense4_wait_new_data_ready (irsense4_t *ctx)
 IR Sense 4 wait new data ready function.
 
err_t irsense4_get_status (irsense4_t *ctx, uint8_t *status)
 IR Sense 4 get status function.
 
err_t irsense4_get_obj_temperature (irsense4_t *ctx, float *temperature)
 IR Sense 4 get the object temperature function.
 
err_t irsense4_get_amb_temperature (irsense4_t *ctx, float *temperature)
 IR Sense 4 get the ambient temperature function.
 
err_t irsense4_get_comp_temperature (irsense4_t *ctx, float *temperature)
 IR Sense 4 get the compensated temperature function.
 
err_t irsense4_get_presence_data (irsense4_t *ctx, int16_t *presence)
 IR Sense 4 get the presence detection data 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_get_amb_shock_data (irsense4_t *ctx, int16_t *shock)
 IR Sense 4 get the ambient shock detection 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.
 
err_t irsense4_read_emb_reg (irsense4_t *ctx, uint8_t reg_emb, uint8_t *data_out)
 IR Sense 4 write register function.
 
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_get_threshold (irsense4_t *ctx, irsense4_ths_sel_t ths_sel, uint16_t *threshold)
 IR Sense 4 get the threshold data function.
 

Detailed Description

This file contains API for IR Sense 4 Click Driver.

Typedef Documentation

◆ irsense4_master_io_t

typedef err_t(* irsense4_master_io_t) (struct irsense4_s *, uint8_t, uint8_t *, uint8_t)

IR Sense 4 Click driver interface.

Definition of driver interface of IR Sense 4 Click driver. Driver serial interface.

◆ irsense4_t

typedef struct irsense4_s irsense4_t

IR Sense 4 Click context object.

Context object definition of IR Sense 4 Click driver.

Enumeration Type Documentation

◆ irsense4_drv_t

IR Sense 4 Click driver selector.

Selects target driver interface of IR Sense 4 Click driver.

Enumerator
IRSENSE4_DRV_SEL_SPI 

SPI driver descriptor.

IRSENSE4_DRV_SEL_I2C 

I2C driver descriptor.

◆ irsense4_return_value_t

IR Sense 4 Click return value data.

Predefined enum values for driver return values.

Enumerator
IRSENSE4_OK 
IRSENSE4_ERROR 

◆ irsense4_ths_sel_t

IR Sense 4 Click threshold selection data value for detection algorithm.

Predefined enum values for driver threshold selection data value.

Enumerator
IRSENSE4_THS_PRESENCE 

Presence threshold selection.

IRSENSE4_THS_MOTION 

Motion threshold selection.

IRSENSE4_THS_TAMB_SHOCK 

Ambient temperature shock threshold selection.