smoke 2.0.0.0
smoke.h File Reference

This file contains API for Smoke Click driver. More...

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

Go to the source code of this file.

Data Structures

struct  smoke_t
 Click ctx object definition. More...
 
struct  smoke_cfg_t
 Click configuration structure definition. More...
 
struct  smoke_set_registers_t
 Click registers object definition. More...
 
struct  smoke_set_new_value_t
 New value object definition. More...
 

Macros

#define SMOKE_MAP_MIKROBUS(cfg, mikrobus)
 
#define SMOKE_RETVAL   uint8_t
 
#define SMOKE_OK   0x00
 
#define SMOKE_INIT_ERROR   0xFF
 
#define SMOKE_PARAMETER_ERROR   0xFE
 
#define SMOKE_I2C_ADDRESS   0x57
 
#define SMOKE_INT_STAT1   0x00
 
#define SMOKE_INT_STAT2   0x01
 
#define SMOKE_INT_ENABLE1   0x02
 
#define SMOKE_INT_ENABLE2   0x03
 
#define SMOKE_INT_FLAG_GET_MAIN   1
 
#define SMOKE_INT_FLAG_GET_TEMP_DATA   2
 
#define SMOKE_INT_FLAG_SET_AFULL   0
 
#define SMOKE_INT_FLAG_SET_DATA_RDY   1
 
#define SMOKE_INT_FLAG_SET_ALS_OVF   2
 
#define SMOKE_INT_FLAG_SET_PROXY_THRESH   3
 
#define SMOKE_INT_FLAG_SET_TEMP   4
 
#define SMOKE_INT_FLAG_SET_ENABLE   1
 
#define SMOKE_INT_FLAG_SET_DISABLE   0
 
#define SMOKE_FIFO_WRITE_PTR   0x04
 
#define SMOKE_FIFO_OVERFLOW   0x05
 
#define SMOKE_FIFO_READ_PTR   0x06
 
#define SMOKE_FIFO_DATA   0x07
 
#define SMOKE_BUFFER_LENGTH   32
 
#define SMOKE_REG_FIFO_CONFIG   0x08
 
#define SMOKE_REG_MODE_CONFIG   0x09
 
#define SMOKE_REG_PARTICLE_CONFIG   0x0A
 
#define SMOKE_REG_LED_RED_PULSE_AMP   0x0C
 
#define SMOKE_REG_LED_IR_PULSE_AMP   0x0D
 
#define SMOKE_REG_LED_GREEN_PULSE_AMP   0x0E
 
#define SMOKE_REG_LED_PROX_AMP   0x10
 
#define SMOKE_REG_LED_PROX_THRESH   0x30
 
#define SMOKE_REG_MULTI_LED_CONFIG1   0x11
 
#define SMOKE_REG_MULTI_LED_CONFIG2   0x12
 
#define SMOKE_REG_MIN_POWER_LEVEL   0x01
 
#define SMOKE_REG_AVG_POWER_LEVEL   0x1F
 
#define SMOKE_REG_MAX_POWER_LEVEL   0xFF
 
#define SMOKE_DIE_TEMP_INT   0x1F
 
#define SMOKE_DIE_TEMP_FRAC   0x20
 
#define SMOKE_DIE_TEMP_CONFIG   0x21
 
#define SMOKE_PROX_INT_THRESH   0x30
 
#define SMOKE_REVISION_ID   0xFE
 
#define SMOKE_PART_ID   0xFF
 
#define SMOKE_INT_A_FULL_MASK   (uint8_t)~0b10000000
 
#define SMOKE_INT_A_FULL_ENABLE   0x80
 
#define SMOKE_INT_A_FULL_DISABLE   0x00
 
#define SMOKE_INT_DATA_RDY_MASK   (uint8_t)~0b01000000
 
#define SMOKE_INT_DATA_RDY_ENABLE   0x40
 
#define SMOKE_INT_DATA_RDY_DISABLE   0x00
 
#define SMOKE_INT_ALC_OVF_MASK   (uint8_t)~0b00100000
 
#define SMOKE_INT_ALC_OVF_ENABLE   0x20
 
#define SMOKE_INT_ALC_OVF_DISABLE   0x00
 
#define SMOKE_INT_PROX_INT_MASK   (uint8_t)~0b00010000
 
#define SMOKE_INT_PROX_INT_ENABLE   0x10
 
#define SMOKE_INT_PROX_INT_DISABLE   0x00
 
#define SMOKE_INT_DIE_TEMP_RDY_MASK   (uint8_t)~0b00000010
 
#define SMOKE_INT_DIE_TEMP_RDY_ENABLE   0x02
 
#define SMOKE_INT_DIE_TEMP_RDY_DISABLE   0x00
 
#define SMOKE_SAMPLEAVG_MASK   (uint8_t)~0b11100000
 
#define SMOKE_SAMPLEAVG_1   0x00
 
#define SMOKE_SAMPLEAVG_2   0x20
 
#define SMOKE_SAMPLEAVG_4   0x40
 
#define SMOKE_SAMPLEAVG_8   0x60
 
#define SMOKE_SAMPLEAVG_16   0x80
 
#define SMOKE_SAMPLEAVG_32   0xA0
 
#define SMOKE_ROLLOVER_MASK   0xEF
 
#define SMOKE_ROLLOVER_ENABLE   0x10
 
#define SMOKE_ROLLOVER_DISABLE   0x00
 
#define SMOKE_A_FULL_MASK   0xF0
 
#define SMOKE_SHUTDOWN_MASK   0x7F
 
#define SMOKE_SHUTDOWN   0x80
 
#define SMOKE_WAKEUP   0x00
 
#define SMOKE_RESET_MASK   0xBF
 
#define SMOKE_RESET   0x40
 
#define SMOKE_MODE_MASK   0xF8
 
#define SMOKE_MODE_REDONLY   0x02
 
#define SMOKE_MODE_REDIRONLY   0x03
 
#define SMOKE_MODE_MULTILED   0x07
 
#define SMOKE_ADCRANGE_MASK   0x9F
 
#define SMOKE_ADCRANGE_2048   0x00
 
#define SMOKE_ADCRANGE_4096   0x20
 
#define SMOKE_ADCRANGE_8192   0x40
 
#define SMOKE_ADCRANGE_16384   0x60
 
#define SMOKE_SAMPLERATE_MASK   0xE3
 
#define SMOKE_SAMPLERATE_50   0x00
 
#define SMOKE_SAMPLERATE_100   0x04
 
#define SMOKE_SAMPLERATE_200   0x08
 
#define SMOKE_SAMPLERATE_400   0x0C
 
#define SMOKE_SAMPLERATE_800   0x10
 
#define SMOKE_SAMPLERATE_1000   0x14
 
#define SMOKE_SAMPLERATE_1600   0x18
 
#define SMOKE_SAMPLERATE_3200   0x1C
 
#define SMOKE_PULSEWIDTH_MASK   0xFC
 
#define SMOKE_PULSEWIDTH_69   0x00
 
#define SMOKE_PULSEWIDTH_118   0x01
 
#define SMOKE_PULSEWIDTH_215   0x02
 
#define SMOKE_PULSEWIDTH_411   0x03
 
#define SMOKE_SLOT1_MASK   0xF8
 
#define SMOKE_SLOT2_MASK   0x8F
 
#define SMOKE_SLOT3_MASK   0xF8
 
#define SMOKE_SLOT4_MASK   0x8F
 
#define SMOKE_SLOT_NONE   0x00
 
#define SMOKE_SLOT_RED_LED   0x01
 
#define SMOKE_SLOT_IR_LED   0x02
 
#define SMOKE_SLOT_GREEN_LED   0x03
 
#define SMOKE_SLOT_NONE_PILOT   0x04
 
#define SMOKE_SLOT_RED_PILOT   0x05
 
#define SMOKE_SLOT_IR_PILOT   0x06
 
#define SMOKE_SLOT_GREEN_PILOT   0x07
 

Functions

void smoke_cfg_setup (smoke_cfg_t *cfg)
 Config Object Initialization function.
 
SMOKE_RETVAL smoke_init (smoke_t *ctx, smoke_cfg_t *cfg)
 Initialization function.
 
void smoke_default_cfg (smoke_t *ctx)
 Click Default Configuration function.
 
void smoke_write_data (smoke_t *ctx, uint8_t wr_addr, uint8_t wr_data)
 Generic write function.
 
uint8_t smoke_read_data (smoke_t *ctx, uint8_t rd_addr)
 Generic read function.
 
void smoke_generic_read (smoke_t *ctx, uint8_t rd_addr, uint8_t *buffer, uint8_t cnt)
 Generic read function.
 
void smoke_set_new_value (smoke_t *ctx, smoke_set_new_value_t *new_value_data)
 Set new value function.
 
uint8_t smoke_get_intrrupt (smoke_t *ctx, uint8_t flag)
 Get desired interrupt function.
 
uint8_t smoke_enable_disable_interrupts (smoke_t *ctx, uint8_t interrupt_flag, uint8_t enable_flag)
 Enable or disable interrupt function.
 
uint8_t smoke_read_device_id (smoke_t *ctx)
 Read device ID function.
 
void smoke_reset (smoke_t *ctx)
 Reset device function.
 
float smoke_read_temp (smoke_t *ctx)
 Read temperature in Centigrade function.
 
uint8_t smoke_set_power (smoke_t *ctx, uint8_t state)
 I2C power setter.
 
uint8_t smoke_set_led_mode (smoke_t *ctx, uint8_t mode)
 Enable leds.
 
uint8_t smoke_set_adc_range (smoke_t *ctx, uint8_t adc_range)
 Set ADC range.
 
uint8_t smoke_set_sample_rate (smoke_t *ctx, uint8_t sample_rate)
 Set sample rate.
 
uint8_t smoke_set_pulse_width (smoke_t *ctx, uint8_t pulse_width)
 Set pulse width.
 
uint8_t smoke_set_led_amplitude (smoke_t *ctx, uint8_t led, uint8_t amplitude)
 Set led amplitude.
 
uint8_t smoke_set_proximity_amplitude_threshold (smoke_t *ctx, uint8_t threshold)
 Set proximity threshold.
 
uint8_t smoke_enable_slot (smoke_t *ctx, uint8_t slot_num, uint8_t dev)
 Define slots in MultiLED mode function.
 
void smoke_disable_slots (smoke_t *ctx)
 Disable slots in MultiLED mode function.
 
void smoke_clear_fifo (smoke_t *ctx)
 Clearing FIFO pointers function.
 
uint8_t smoke_get_write_ptr (smoke_t *ctx)
 Read the FIFO Write Pointer function.
 
uint8_t smoke_get_read_ptr (smoke_t *ctx)
 Read the FIFO Read Pointer function.
 
uint8_t smoke_set_rollover_state (smoke_t *ctx, uint8_t state)
 Set rollover state.
 
uint8_t smoke_set_almost_full_trigger (smoke_t *ctx, uint8_t trigger_range)
 Set almost full trigger.
 
uint8_t smoke_set_sample_avarage (smoke_t *ctx, uint8_t samples)
 Set avarage samples.
 
uint8_t smoke_set_registers (smoke_t *ctx, smoke_set_registers_t *registers)
 Set registers values function.
 
uint8_t smoke_read_leds (smoke_t *ctx)
 Function for reading enabled leds.
 
uint8_t smoke_check_int (smoke_t *ctx)
 Get Interrupt state function.
 

Detailed Description

This file contains API for Smoke Click driver.