MSS / VCNL4100

Dependents:   test_VCNL4100 testSensor

Embed: (wiki syntax)

« Back to documentation index

VCNL4100 Class Reference

VCNL4100 Class Reference

Vishay VCNL4100 High Sensitivity Long Distance Proximity and Ambient Light Sensor with I2C Interface. More...

#include <VCNL4100.h>

Public Member Functions

 VCNL4100 (PinName sda, PinName scl, int addr)
 VCNL4100 constructor.
 ~VCNL4100 ()
 VCNL4100 destructor.
uint8_t getAlsConf (void)
 get ALS configuration
void setAlsConf (uint8_t conf)
 set ALS configuration
uint16_t getAlsThdh (void)
 Get ALS high interrupt threshold.
void setAlsThdh (uint16_t thdh)
 Set ALS high interrupt threshold.
uint16_t getAlsThdl (void)
 Get ALS low interrupt threshold.
void setAlsThdl (uint16_t thdl)
 Set ALS low interrupt threshold.
uint16_t getPsConf12 (void)
 Get PS CONF1 and PS CONF2.
void setPsConf12 (uint16_t conf12)
 Set PS CONF1 and PS CONF2.
uint8_t getPsConf1 (void)
 get PS CONF1
void setPsConf1 (uint8_t conf1)
 set PS_CONF1
uint8_t getPsConf2 (void)
 get PS_CONF2
void setPsConf2 (uint8_t conf2)
 set PS_CONF2
uint16_t getPsConf3Spo (void)
 get PS_CONF3 and PS_SPO
void setPsConf3Spo (uint16_t conf3spo)
 set PS_CONF3 and PS_SPO
uint8_t getPsConf3 (void)
 get PS_CONF3
void setPsConf3 (uint8_t conf3)
 set PS_CONF3
uint8_t getSpo (void)
 get PS_SPO
void setSpo (uint8_t spo)
 set PS_SPO
uint16_t getPsThd (void)
 get PS_THDL as LSB and PS_THDH as MSB
void setPsThd (uint16_t psthd)
 set PS_THDL as LSB and PS_THDH as MSB
uint8_t getPsThdl (void)
 get PS_THDL
void setPsThdl (uint8_t thdl)
 set PS_THDL
uint8_t getPsThdh (void)
 get PS_THDH
void setPsThdh (uint8_t thdh)
 set PS_THDH
uint8_t getPsData (void)
 get PS_DATA
uint16_t getAlsData (void)
 get ALS output data
uint8_t getIntFlag (void)
 get INT_FLAG

Detailed Description

Vishay VCNL4100 High Sensitivity Long Distance Proximity and Ambient Light Sensor with I2C Interface.

Definition at line 12 of file VCNL4100.h.


Constructor & Destructor Documentation

VCNL4100 ( PinName  sda,
PinName  scl,
int  addr 
)

VCNL4100 constructor.

Parameters:
sdaSDA pin
sdlSCL pin
addraddr of the I2C peripheral

Definition at line 32 of file VCNL4100.cpp.

~VCNL4100 (  )

VCNL4100 destructor.

Definition at line 39 of file VCNL4100.cpp.


Member Function Documentation

uint8_t getAlsConf ( void   )

get ALS configuration

Parameters:
none
Returns:
uint8_t ALS CONF
Note:
bit[7:6] ALS_IT ASL integration time setting,
longer integration time has higher sensitivity
00=80ms, 01=160ms, 10=320ms, 11=640ms
-
bit[5:4] (reserved)
-
bit[3:2] ALS interrupt persistence setting
00=1, 01=2, 10=4, 11=8
-
bit[1] ALS_INT_EN 0=ALS interrupt disable, 1=ALS interrupt enable
-
bit[0] ALS_SD 0=ALS power on, 1=ALS Shut Down

Definition at line 53 of file VCNL4100.cpp.

uint16_t getAlsData ( void   )

get ALS output data

Parameters:
none
Returns:
uint16_t ALS output data

Definition at line 286 of file VCNL4100.cpp.

uint16_t getAlsThdh ( void   )

Get ALS high interrupt threshold.

Parameters:
none
Returns:
uint16_t ALS high interrupt threshold

Definition at line 69 of file VCNL4100.cpp.

uint16_t getAlsThdl ( void   )

Get ALS low interrupt threshold.

Parameters:
none
Returns:
uint16_t ALS low interrupt threshold

Definition at line 87 of file VCNL4100.cpp.

uint8_t getIntFlag ( void   )

get INT_FLAG

Parameters:
none
Returns:
uint8_t INT_FLAG
Note:
bit[7] PS_SPF_LEAVE, PS leaving protection mode
bit[6] PS_SPF_ENTER, PS entering protection mode
bit[5] ALS_IF_L, ALS crossing low THD INT trigger event
bit[4] ALS_IF_H, ALS crossing high THD INT trigger event
bit[3:2] (reserved)
bit[1] PS_IF_CLOSE, PS rise above PS_THDH INT trigger event
bit[0] PS_IF_AWAY, PS drop below PS_THDL INT trigger event

Definition at line 295 of file VCNL4100.cpp.

uint8_t getPsConf1 ( void   )

get PS CONF1

Parameters:
none
Returns:
Register value of PS_CONF1
Note:
bit[7:6] PS_Duty PS IRED on/off duty ratio setting
00=1/5120, 01=1/640, 10=1/80, 11=1/20
-
bit[5:4] PS_IT PS integration time setting
00=1T, 01=1.3T, 10=1.6T, 11=2T
-
bit[3:2] PS_PERS PS interrupt persistence setting
00=1, 01=2, 10=3, 11=4
-
bit[1] (reserved)
-
bit[0] PS_SD 0=PS power on, 1=PS shut down

Definition at line 123 of file VCNL4100.cpp.

uint16_t getPsConf12 ( void   )

Get PS CONF1 and PS CONF2.

Parameters:
none
Returns:
uint16_t PS_CONF2 as MSB, PS_CONF1 as LSB

Definition at line 105 of file VCNL4100.cpp.

uint8_t getPsConf2 ( void   )

get PS_CONF2

Note:
bit[7:6] PS_ITB PS IT bank setting
00=1/2T, 01=1T, 10=2T, 11=4T
-
bit[5:4] PS_GAIN
00=1/4, 01=1/2, 10=1, 11=2
-
bit[3] (reserved)
-
bit[2] PS_SP_INT_EN
0 = disable INT function for PS enter/leave sunlight protection mode
1 = issue INT while PS enter/leave sunlight protection mode.
While PS enter sunlight protection mode, the PS output will keep 0xFF
-
bit[1] (reserved)
-
bit[0] PS_INT_EN
0 = PS INT function disable, 1 = PS INT function enable

Definition at line 143 of file VCNL4100.cpp.

uint8_t getPsConf3 ( void   )

get PS_CONF3

Parameters:
none
Returns:
uint8_t PS_CONF3
Note:
bit[7:6] PS_AV
00=1/2, 01=1/4, 10=1/8, 11=1/16
-
bit[5] PS_AV_EN
0= PS average function disable, 1= PS average function enable
-
bit[4] (reserved)
-
bit[3] PS_AF
0= active force mode disable (normal mode), 1= active force mode enable
-
bit[2] PS_TRIG
0= no PS active force mode trigger, 1= trigger one time cycle
VCNL4100 output once cycle data every time host writes in "1" to sensor.
The state returns to "0" automatically.
-
bit[1] PS_MPULSE 0= disable, 1= enable
PS multi pulse mode setting; PS multi puse number set by PS_AV[1:0]
-
bit[0] (reserved)

Definition at line 181 of file VCNL4100.cpp.

uint16_t getPsConf3Spo ( void   )

get PS_CONF3 and PS_SPO

Parameters:
none
Returns:
uint16_t PS_CONF3 as LSB, PS_SPO as MSB

Definition at line 163 of file VCNL4100.cpp.

uint8_t getPsData ( void   )

get PS_DATA

Parameters:
none
Returns:
uint8_t PS_DATA
Note:
bit[7:0] 0x00 to 0xFF, PS output data

Definition at line 279 of file VCNL4100.cpp.

uint16_t getPsThd ( void   )

get PS_THDL as LSB and PS_THDH as MSB

Parameters:
none
Returns:
uint16_t PS_THDL as LSB, PS_THDH as MSB

Definition at line 221 of file VCNL4100.cpp.

uint8_t getPsThdh ( void   )

get PS_THDH

Parameters:
none
Returns:
uint8_t PS_THDH
Note:
bit[7:0] PS_THDH 0x00 to 0xFF, PS high interrupt threshold setting

Definition at line 259 of file VCNL4100.cpp.

uint8_t getPsThdl ( void   )

get PS_THDL

Parameters:
none
Returns:
uint8_t PS_THDL
Note:
bit[7:0] PS_THDL 0x00 to 0xFF, PS low interrupt threshold setting

Definition at line 239 of file VCNL4100.cpp.

uint8_t getSpo ( void   )

get PS_SPO

Parameters:
none
Returns:
uint8_t PS_SPO
Note:
Set initial value to "0xA0" or "0x20"
bit[7:0] PS_SPO
Set initial value = 0xA0 (PS_OUT = 0xFF while PS into sunlight protection)
Set initial value = 0x20 (PS_OUT = 0x00 while PS into sunlight protection)

Definition at line 201 of file VCNL4100.cpp.

void setAlsConf ( uint8_t  conf )

set ALS configuration

Parameters:
uint8_tconf, value to assign
Returns:
none

Definition at line 60 of file VCNL4100.cpp.

void setAlsThdh ( uint16_t  thdh )

Set ALS high interrupt threshold.

Parameters:
uint16_tthdh, value to assign
Returns:
none

Definition at line 78 of file VCNL4100.cpp.

void setAlsThdl ( uint16_t  thdl )

Set ALS low interrupt threshold.

Parameters:
uint16_tthdl, value to assign
Returns:
none

Definition at line 96 of file VCNL4100.cpp.

void setPsConf1 ( uint8_t  conf1 )

set PS_CONF1

Parameters:
uint8_tconf1 value to set
Returns:
none

Definition at line 132 of file VCNL4100.cpp.

void setPsConf12 ( uint16_t  conf12 )

Set PS CONF1 and PS CONF2.

Parameters:
uint16_tPS_CONF2 as MSB, PS_CONF1 as LSB
Returns:
none

Definition at line 114 of file VCNL4100.cpp.

void setPsConf2 ( uint8_t  conf2 )

set PS_CONF2

Parameters:
uint8_tconf2 value to set
Returns:
none

Definition at line 152 of file VCNL4100.cpp.

void setPsConf3 ( uint8_t  conf3 )

set PS_CONF3

Parameters:
uint8_tconf3 value to set
Returns:
none

Definition at line 190 of file VCNL4100.cpp.

void setPsConf3Spo ( uint16_t  conf3spo )

set PS_CONF3 and PS_SPO

Parameters:
uint16_tcon3spo PS_CONF3 as LSB, PS_SPO as MSB
Returns:
none

Definition at line 172 of file VCNL4100.cpp.

void setPsThd ( uint16_t  psthd )

set PS_THDL as LSB and PS_THDH as MSB

Parameters:
uint16_tPS_THDL as LSB, PS_THDH as MSB
Returns:
none

Definition at line 230 of file VCNL4100.cpp.

void setPsThdh ( uint8_t  thdh )

set PS_THDH

Parameters:
uint8_tthdh value to set
Returns:
none

Definition at line 268 of file VCNL4100.cpp.

void setPsThdl ( uint8_t  thdl )

set PS_THDL

Parameters:
uint8_tthdl value to set
Returns:
none

Definition at line 248 of file VCNL4100.cpp.

void setSpo ( uint8_t  spo )

set PS_SPO

Parameters:
uint8_tspo value to set (0xA0 or 0x20)
Returns:
none

Definition at line 210 of file VCNL4100.cpp.