ambient21 2.1.0.0
ambient21.h File Reference

This file contains API for Ambient 21 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  ambient21_t
 Ambient 21 Click context object. More...
 
struct  ambient21_cfg_t
 Ambient 21 Click configuration object. More...
 

Macros

#define AMBIENT21_REG_ENABLE   0x00
 Ambient 21 registers list.
 
#define AMBIENT21_REG_CONFIG   0x01
 
#define AMBIENT21_REG_AILTL   0x04
 
#define AMBIENT21_REG_AILTH   0x05
 
#define AMBIENT21_REG_AIHTL   0x06
 
#define AMBIENT21_REG_AIHTH   0x07
 
#define AMBIENT21_REG_NPAILTL   0x08
 
#define AMBIENT21_REG_NPAILTH   0x09
 
#define AMBIENT21_REG_NPAIHTL   0x0A
 
#define AMBIENT21_REG_NPAIHTH   0x0B
 
#define AMBIENT21_REG_PERSIST   0x0C
 
#define AMBIENT21_REG_PID   0x11
 
#define AMBIENT21_REG_ID   0x12
 
#define AMBIENT21_REG_STATUS   0x13
 
#define AMBIENT21_REG_C0DATAL   0x14
 
#define AMBIENT21_REG_C0DATAH   0x15
 
#define AMBIENT21_REG_C1DATAL   0x16
 
#define AMBIENT21_REG_C1DATAH   0x17
 
#define AMBIENT21_CMD_NORMAL_OP   0xA0
 Ambient 21 command register setting.
 
#define AMBIENT21_CMD_SPEC_FUNC   0xE0
 
#define AMBIENT21_SF_INT_SET   0x04
 
#define AMBIENT21_SF_CLEAR_ALS_INT   0x06
 
#define AMBIENT21_SF_CLEAR_ALS_NOPERS_INT   0x07
 
#define AMBIENT21_SF_CLEAR_NOPERS_INT   0x0A
 
#define AMBIENT21_ADDR_SF_MASK   0x1F
 
#define AMBIENT21_ENABLE_NPIEN   0x80
 Ambient 21 enable register setting.
 
#define AMBIENT21_ENABLE_SAI   0x40
 
#define AMBIENT21_ENABLE_AIEN   0x10
 
#define AMBIENT21_ENABLE_AEN   0x02
 
#define AMBIENT21_ENABLE_PON   0x01
 
#define AMBIENT21_CONFIG_SRESET   0x80
 Ambient 21 config register setting.
 
#define AMBIENT21_CONFIG_AGAIN_LOW   0x00
 
#define AMBIENT21_CONFIG_AGAIN_MID   0x10
 
#define AMBIENT21_CONFIG_AGAIN_HIGH   0x20
 
#define AMBIENT21_CONFIG_AGAIN_MAX   0x30
 
#define AMBIENT21_CONFIG_AGAIN_MASK   0x30
 
#define AMBIENT21_CONFIG_ATIME_100MS   0x00
 
#define AMBIENT21_CONFIG_ATIME_200MS   0x01
 
#define AMBIENT21_CONFIG_ATIME_300MS   0x02
 
#define AMBIENT21_CONFIG_ATIME_400MS   0x03
 
#define AMBIENT21_CONFIG_ATIME_500MS   0x04
 
#define AMBIENT21_CONFIG_ATIME_600MS   0x05
 
#define AMBIENT21_CONFIG_ATIME_MASK   0x07
 
#define AMBIENT21_PERSIST_EVERY   0x00
 Ambient 21 persist register setting.
 
#define AMBIENT21_PERSIST_ANY   0x01
 
#define AMBIENT21_PERSIST_2   0x02
 
#define AMBIENT21_PERSIST_3   0x03
 
#define AMBIENT21_PERSIST_5   0x04
 
#define AMBIENT21_PERSIST_10   0x05
 
#define AMBIENT21_PERSIST_15   0x06
 
#define AMBIENT21_PERSIST_20   0x07
 
#define AMBIENT21_PERSIST_25   0x08
 
#define AMBIENT21_PERSIST_30   0x09
 
#define AMBIENT21_PERSIST_35   0x0A
 
#define AMBIENT21_PERSIST_40   0x0B
 
#define AMBIENT21_PERSIST_45   0x0C
 
#define AMBIENT21_PERSIST_50   0x0D
 
#define AMBIENT21_PERSIST_55   0x0E
 
#define AMBIENT21_PERSIST_60   0x0F
 
#define AMBIENT21_PERSIST_MASK   0x0F
 
#define AMBIENT21_STATUS_NPINTR   0x20
 Ambient 21 status register setting.
 
#define AMBIENT21_STATUS_AINT   0x10
 
#define AMBIENT21_STATUS_AVALID   0x01
 
#define AMBIENT21_DEVICE_ID   0x50
 Ambient 21 ID values.
 
#define AMBIENT21_AGAIN_LOW   0x00
 Ambient 21 again and atime setting.
 
#define AMBIENT21_AGAIN_MID   0x01
 
#define AMBIENT21_AGAIN_HIGH   0x02
 
#define AMBIENT21_AGAIN_MAX   0x03
 
#define AMBIENT21_ATIME_100MS   0x00
 
#define AMBIENT21_ATIME_200MS   0x01
 
#define AMBIENT21_ATIME_300MS   0x02
 
#define AMBIENT21_ATIME_400MS   0x03
 
#define AMBIENT21_ATIME_500MS   0x04
 
#define AMBIENT21_ATIME_600MS   0x05
 
#define AMBIENT21_GAIN_0   1.0f
 Ambient 21 lux calculation values.
 
#define AMBIENT21_GAIN_1   25.0f
 
#define AMBIENT21_GAIN_2   428.0f
 
#define AMBIENT21_GAIN_3   9876.0f
 
#define AMBIENT21_TIME_RES   100.0f
 
#define AMBIENT21_LUX_GDF   900.0f
 
#define AMBIENT21_LUX_COEF   1.0f
 
#define AMBIENT21_DEVICE_ADDRESS   0x29
 Ambient 21 device address setting.
 
#define AMBIENT21_MAP_MIKROBUS(cfg, mikrobus)
 MikroBUS pin mapping.
 

Enumerations

enum  ambient21_return_value_t { AMBIENT21_OK = 0 , AMBIENT21_ERROR = -1 }
 Ambient 21 Click return value data. More...
 

Functions

void ambient21_cfg_setup (ambient21_cfg_t *cfg)
 Ambient 21 configuration object setup function.
 
err_t ambient21_init (ambient21_t *ctx, ambient21_cfg_t *cfg)
 Ambient 21 initialization function.
 
err_t ambient21_default_cfg (ambient21_t *ctx)
 Ambient 21 default configuration function.
 
err_t ambient21_generic_write (ambient21_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
 Ambient 21 I2C writing function.
 
err_t ambient21_generic_read (ambient21_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
 Ambient 21 I2C reading function.
 
err_t ambient21_write_register (ambient21_t *ctx, uint8_t reg, uint8_t data_in)
 Ambient 21 write register function.
 
err_t ambient21_read_register (ambient21_t *ctx, uint8_t reg, uint8_t *data_out)
 Ambient 21 read register function.
 
err_t ambient21_write_spec_func (ambient21_t *ctx, uint8_t spec_func)
 Ambient 21 write spec func function.
 
uint8_t ambient21_get_int_pin (ambient21_t *ctx)
 Ambient 21 get int pin function.
 
err_t ambient21_check_communication (ambient21_t *ctx)
 Ambient 21 check communication function.
 
err_t ambient21_clear_interrupts (ambient21_t *ctx)
 Ambient 21 clear interrupts function.
 
err_t ambient21_set_config (ambient21_t *ctx, uint8_t again, uint8_t atime)
 Ambient 21 set config function.
 
err_t ambient21_read_raw_data (ambient21_t *ctx, uint16_t *ch_0, uint16_t *ch_1)
 Ambient 21 read raw data function.
 
err_t ambient21_measure_light_level (ambient21_t *ctx, uint16_t *lux)
 Ambient 21 measure light level function.
 

Detailed Description

This file contains API for Ambient 21 Click Driver.

Enumeration Type Documentation

◆ ambient21_return_value_t

Ambient 21 Click return value data.

Predefined enum values for driver return values.

Enumerator
AMBIENT21_OK 
AMBIENT21_ERROR