smoke2 2.0.0.0
smoke2.h File Reference

This file contains API for Smoke 2 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  smoke2_s
 Smoke 2 Click context object. More...
 
struct  smoke2_cfg_t
 Smoke 2 Click configuration object. More...
 

Macros

#define SMOKE2_REG_STATUS   0x00
 Smoke 2 description register.
 
#define SMOKE2_REG_INT_MASK   0x01
 
#define SMOKE2_REG_GPIO_DRV   0x02
 
#define SMOKE2_REG_BG_STATUS   0x04
 
#define SMOKE2_REG_FIFO_THR   0x06
 
#define SMOKE2_REG_DEVID   0x08
 
#define SMOKE2_REG_I2CS_ID   0x09
 
#define SMOKE2_REG_CLK_RATIO   0x0A
 
#define SMOKE2_REG_GPIO_CTRL   0x0B
 
#define SMOKE2_REG_SLAVE_ADDR_KEY   0x0D
 
#define SMOKE2_REG_SW_RESET   0x0F
 
#define SMOKE2_REG_MODE   0x10
 
#define SMOKE2_REG_SLOT_EN   0x11
 
#define SMOKE2_REG_FSAMPLE   0x12
 
#define SMOKE2_REG_PD_LED_SELECT   0x14
 
#define SMOKE2_REG_NUM_AVG   0x15
 
#define SMOKE2_REG_BIG_MEAS_A   0x16
 
#define SMOKE2_REG_INT_SEQ_A   0x17
 
#define SMOKE2_REG_SLOTA_CH1_OFFSET   0x18
 
#define SMOKE2_REG_SLOTA_CH2_OFFSET   0x19
 
#define SMOKE2_REG_SLOTA_CH3_OFFSET   0x1A
 
#define SMOKE2_REG_SLOTA_CH4_OFFSET   0x1B
 
#define SMOKE2_REG_BIG_MEAS_B   0x1C
 
#define SMOKE2_REG_INT_SEQ_B   0x1D
 
#define SMOKE2_REG_SLOTB_CH1_OFFSET   0x1E
 
#define SMOKE2_REG_SLOTB_CH2_OFFSET   0x1F
 
#define SMOKE2_REG_SLOTB_CH3_OFFSET   0x20
 
#define SMOKE2_REG_SLOTB_CH4_OFFSET   0x21
 
#define SMOKE2_REG_ILED3_COARSE   0x22
 
#define SMOKE2_REG_ILED1_COARSE   0x23
 
#define SMOKE2_REG_ILED2_COARSE   0x24
 
#define SMOKE2_REG_ILED_FINE   0x25
 
#define SMOKE2_REG_SLOTA_LED_PULSE   0x30
 
#define SMOKE2_REG_SLOTA_NUM_PULSES   0x31
 
#define SMOKE2_REG_LED_DISABLE   0x34
 
#define SMOKE2_REG_SLOTB_LED_PULSE   0x35
 
#define SMOKE2_REG_SLOTB_NUM_PULSES   0x36
 
#define SMOKE2_REG_ALT_PWR_DN   0x37
 
#define SMOKE2_REG_EXT_SYNC_STARTUP   0x38
 
#define SMOKE2_REG_SLOTA_AFE_WINDOW   0x39
 
#define SMOKE2_REG_SLOTB_AFE_WINDOW   0x3B
 
#define SMOKE2_REG_AFE_PWR_CFG1   0x3C
 
#define SMOKE2_REG_SLOTA_FLOAT_LED   0x3E
 
#define SMOKE2_REG_SLOTB_FLOAT_LED   0x3F
 
#define SMOKE2_REG_SLOTA_TIA_CFG   0x42
 
#define SMOKE2_REG_SLOTA_AFE_CFG   0x43
 
#define SMOKE2_REG_SLOTB_TIA_CFG   0x44
 
#define SMOKE2_REG_SLOTB_AFE_CFG   0x45
 
#define SMOKE2_REG_SAMPLE_CLK   0x4B
 
#define SMOKE2_REG_CLK32M_ADJUST   0x4D
 
#define SMOKE2_REG_EXT_SYNC_SEL   0x4F
 
#define SMOKE2_REG_CLK32M_CAL_EN   0x50
 
#define SMOKE2_REG_AFE_PWR_CFG2   0x54
 
#define SMOKE2_REG_TIA_INDEP_GAIN   0x55
 
#define SMOKE2_REG_MATH   0x58
 
#define SMOKE2_REG_FLT_CONFIG_B   0x59
 
#define SMOKE2_REG_FLT_LED_FIRE   0x5A
 
#define SMOKE2_REG_FLT_CONFIG_A   0x5E
 
#define SMOKE2_REG_DATA_ACCESS_CTL   0x5F
 
#define SMOKE2_REG_FIFO_ACCESS   0x60
 
#define SMOKE2_REG_SLOTA_CH1   0x64
 
#define SMOKE2_REG_SLOTA_CH2   0x65
 
#define SMOKE2_REG_SLOTA_CH3   0x66
 
#define SMOKE2_REG_SLOTA_CH4   0x67
 
#define SMOKE2_REG_SLOTB_CH1   0x68
 
#define SMOKE2_REG_SLOTB_CH2   0x69
 
#define SMOKE2_REG_SLOTB_CH3   0x6A
 
#define SMOKE2_REG_SLOTB_CH4   0x6B
 
#define SMOKE2_REG_A_CH1_LOW   0x70
 
#define SMOKE2_REG_A_CH2_LOW   0x71
 
#define SMOKE2_REG_A_CH3_LOW   0x72
 
#define SMOKE2_REG_A_CH4_LOW   0x73
 
#define SMOKE2_REG_A_CH1_HIGH   0x74
 
#define SMOKE2_REG_A_CH2_HIGH   0x75
 
#define SMOKE2_REG_A_CH3_HIGH   0x76
 
#define SMOKE2_REG_A_CH4_HIGH   0x77
 
#define SMOKE2_REG_B_CH1_LOW   0x78
 
#define SMOKE2_REG_B_CH2_LOW   0x79
 
#define SMOKE2_REG_B_CH3_LOW   0x7A
 
#define SMOKE2_REG_B_CH4_LOW   0x7B
 
#define SMOKE2_REG_B_CH1_HIGH   0x7C
 
#define SMOKE2_REG_B_CH2_HIGH   0x7D
 
#define SMOKE2_REG_B_CH3_HIGH   0x7E
 
#define SMOKE2_REG_B_CH4_HIGH   0x7F
 
#define SMOKE2_SLOT_A   0
 Smoke 2 description setting.
 
#define SMOKE2_SLOT_B   4
 
#define SMOKE2_CHN_1   0
 Smoke 2 description setting to select channel.
 
#define SMOKE2_CHN_2   1
 
#define SMOKE2_CHN_3   2
 
#define SMOKE2_CHN_4   3
 
#define SMOKE2_MODE_IDLE   0
 Smoke 2 description setting to select mode.
 
#define SMOKE2_MODE_PROGRAM   1
 
#define SMOKE2_MODE_NORMAL   2
 
#define SMOKE2_SMOKE_DETECTED   0xCC
 Smoke 2 description setting for detection smoke.
 
#define SMOKE2_SMOKE_NOT_DETECTED   0xDD
 
#define SMOKE2_READ_CMD   0
 Smoke 2 description setting for read and write.
 
#define SMOKE2_WRITE_CMD   1
 
#define SMOKE2_SET_DEV_ADDR   0x64
 Smoke 2 device address setting.
 
#define SMOKE2_SET_DATA_SAMPLE_EDGE   SET_SPI_DATA_SAMPLE_EDGE
 Data sample selection.
 
#define SMOKE2_SET_DATA_SAMPLE_MIDDLE   SET_SPI_DATA_SAMPLE_MIDDLE
 
#define SMOKE2_MAP_MIKROBUS(cfg, mikrobus)
 MikroBUS pin mapping.
 

Typedefs

typedef err_t(* smoke2_master_io_t) (struct smoke2_s *, uint8_t, uint8_t *, uint8_t)
 Smoke 2 Click driver interface.
 
typedef struct smoke2_s smoke2_t
 Smoke 2 Click context object.
 

Enumerations

enum  smoke2_drv_t { SMOKE2_DRV_SEL_SPI , SMOKE2_DRV_SEL_I2C }
 Smoke 2 Click driver selector. More...
 
enum  smoke2_return_value_t { SMOKE2_OK = 0 , SMOKE2_ERROR = -1 }
 Smoke 2 Click return value data. More...
 

Functions

void smoke2_cfg_setup (smoke2_cfg_t *cfg)
 Smoke 2 configuration object setup function.
 
void smoke2_drv_interface_selection (smoke2_cfg_t *cfg, smoke2_drv_t drv_sel)
 Smoke 2 driver interface setup function.
 
err_t smoke2_init (smoke2_t *ctx, smoke2_cfg_t *cfg)
 Smoke 2 initialization function.
 
void smoke2_default_cfg (smoke2_t *ctx)
 Smoke 2 default configuration function.
 
err_t smoke2_generic_write (smoke2_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
 Smoke 2 data writing function.
 
err_t smoke2_generic_read (smoke2_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
 Smoke 2 data reading function.
 
uint8_t smoke2_get_int_pin (smoke2_t *ctx)
 Smoke 2 get state of int pin function.
 
void smoke2_write_data (smoke2_t *ctx, uint8_t reg, uint16_t tx_data)
 Smoke 2 generic function for writing data to register function.
 
uint16_t smoke2_read_data (smoke2_t *ctx, uint8_t reg)
 Smoke 2 generic function for reading data from registar.
 
void smoke2_set_bit (smoke2_t *ctx, uint8_t reg, uint8_t bit_num, uint8_t val)
 Smoke 2 generic function for writing bit state.
 
uint8_t smoke2_get_bit (smoke2_t *ctx, uint8_t reg, uint8_t bit_num)
 Smoke 2 generic function for reading bit state.
 
void smoke2_set_mode (smoke2_t *ctx, uint8_t mode)
 Smoke 2 setting mode function.
 
void smoke2_get_int (smoke2_t *ctx, uint8_t *fifo, uint8_t *slot_a, uint8_t *slot_b)
 Smoke 2 get mode function.
 
uint16_t smoke2_read_sens_data (smoke2_t *ctx, uint8_t slot, uint8_t chn)
 Smoke 2 reading bit state function.
 
void smoke2_soft_reset (smoke2_t *ctx)
 Smoke 2 reseting device function.
 
uint16_t smoke2_smoke_calibration (smoke2_t *ctx, uint16_t threshold)
 Smoke 2 calibrating data and setting threshold function.
 
uint8_t smoke2_check_smoke (smoke2_t *ctx)
 Smoke 2 checking smoke detection function.
 

Detailed Description

This file contains API for Smoke 2 Click Driver.

Typedef Documentation

◆ smoke2_master_io_t

typedef err_t(* smoke2_master_io_t) (struct smoke2_s *, uint8_t, uint8_t *, uint8_t)

Smoke 2 Click driver interface.

Definition of driver interface of Smoke 2 Click driver. Driver serial interface.

◆ smoke2_t

typedef struct smoke2_s smoke2_t

Smoke 2 Click context object.

Context object definition of Smoke 2 Click driver.

Enumeration Type Documentation

◆ smoke2_drv_t

Smoke 2 Click driver selector.

Selects target driver interface of Smoke 2 Click driver.

Enumerator
SMOKE2_DRV_SEL_SPI 

SPI driver descriptor.

SMOKE2_DRV_SEL_I2C 

I2C driver descriptor.

◆ smoke2_return_value_t

Smoke 2 Click return value data.

Predefined enum values for driver return values.

Enumerator
SMOKE2_OK 
SMOKE2_ERROR