Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
VCNL4010 Class Reference
VCNL4010 Fully Integrated Proximity and Ambient Light Sensor with Infrared Emitter, I2C Interface, and Interrupt Function. More...
#include <VCNL4010.h>
Public Member Functions | |
VCNL4010 (PinName sda, PinName scl, int addr) | |
VCNL4010 constructor. | |
~VCNL4010 () | |
VCNL4010 destructor. | |
uint8_t | getCommandReg (void) |
Get Command Register. | |
void | setCommandReg (uint8_t cmd) |
Set Command Register. | |
uint8_t | getProductID (void) |
Get Prodcut ID (and Revision) | |
uint8_t | getProxRate (void) |
Get Rate of Proximity Measurement. | |
void | setProxRate (uint8_t rate) |
Set Rate of Proximity Measurement. | |
uint8_t | getIrLedCurrent (void) |
Get IR LED Current Setting for Proximity Mode. | |
void | setIrLedCurrent (uint8_t IrLedCur) |
Set IR LED Current Setting for Proximity Mode. | |
uint8_t | getAlsParam (void) |
Get Ambient Light Parameter. | |
void | setAlsParam (uint8_t param) |
Set Ambient Light Parameter. | |
uint16_t | getAls (void) |
Get Ambient Light Result. | |
uint16_t | getProx (void) |
Get Proximity Measurement Result. | |
uint8_t | getIntCtrl (void) |
Get Interrupt Control Register value. | |
void | setIntCtrl (uint8_t ctrl) |
Set Interrupt Control Register. | |
uint16_t | getLowThreshold (void) |
Get Low Threshold. | |
void | setLowThreshold (uint16_t thr) |
Set Low Threshold. | |
uint16_t | getHighThreshold (void) |
Get High Threshold. | |
void | setHighThreshold (uint16_t thr) |
Set High Threshold. | |
uint8_t | getIntStatus (void) |
Get Interrupt Status. | |
void | setIntStatus (uint8_t status) |
Set Interrupt Status. | |
uint8_t | getProxModTiming (void) |
Get Proximity Modulator Timing Adjustment. | |
void | setProxModTiming (uint8_t timing) |
Set Proximity Modulator Timing Adjustment. |
Detailed Description
VCNL4010 Fully Integrated Proximity and Ambient Light Sensor with Infrared Emitter, I2C Interface, and Interrupt Function.
Definition at line 8 of file VCNL4010.h.
Constructor & Destructor Documentation
VCNL4010 | ( | PinName | sda, |
PinName | scl, | ||
int | addr | ||
) |
VCNL4010 constructor.
- Parameters:
-
sda SDA pin sdl SCL pin addr addr of the I2C peripheral
Definition at line 27 of file VCNL4010.cpp.
~VCNL4010 | ( | ) |
VCNL4010 destructor.
Definition at line 31 of file VCNL4010.cpp.
Member Function Documentation
uint16_t getAls | ( | void | ) |
Get Ambient Light Result.
- Parameters:
-
none
- Returns:
- uint16_t the value of Ambient Light Result (Register #5, #6)
- Note:
- Register #5 and #6 Ambient Light Result Register (0x85, 0x86)
- bit[15:8] MSB (address 0x85)
- bit[7:0] LSB (address 0x86)
Definition at line 113 of file VCNL4010.cpp.
uint8_t getAlsParam | ( | void | ) |
Get Ambient Light Parameter.
- Parameters:
-
none
- Returns:
- Ambient Light Parameter (Register #4)
- Note:
- Register #4 Ambient Light Parameter Register (0x84)
- bit[7] Continuous conversion mode 0: Disable = DEFAULT 1: Enable
- bit[6:4] als_rate
- bit[3] Auto offset compensation 0: Disable 1: Enable = DEFAULT
- bit[2:0] Averaging function (number of measurements per run)
- als_rate Ambient light measurement rate
- 000 - 1 samples/s
- 001 - 2 samples/s = DEFUAULT
- 010 - 3 samples/s
- 011 - 4 samples/s
- 100 - 5 samples/s
- 101 - 6 samples/s
- 110 - 8 samples/s
- 111 - 10 samples/s
- Averaging function
- Number of conversions = 2^decimal_value
- 0 = 1 conv, 1 = 2 conv, 2 = 4 conv, .. t = 32 conv (DEFAULT) .. 7 = 128 conv
Definition at line 98 of file VCNL4010.cpp.
uint8_t getCommandReg | ( | void | ) |
Get Command Register.
- Parameters:
-
none
- Returns:
- uint8_t command register value (Register #0)
- Note:
- Register #0 Command Register (0x80)
- bit[7] config_lock
- bit[6] als_data_rdy
- bit[5] prox_data_rdy
- bit[4] als_od
- bit[3] prox_od
- bit[2] als_en
- bit[1] prox_en
- bit[0] selftimed_en
Definition at line 46 of file VCNL4010.cpp.
uint16_t getHighThreshold | ( | void | ) |
Get High Threshold.
- Parameters:
-
none
- Returns:
- uint16_t High Threshold (Register #12, #13)
- Note:
- Register #12 and #13 High Threshold (0x8C, 0x8D)
- bit[15:8] MSB (address 0x8C)
- bit[7:0] LSB (address 0x8D)
Definition at line 164 of file VCNL4010.cpp.
uint8_t getIntCtrl | ( | void | ) |
Get Interrupt Control Register value.
- Parameters:
-
none
- Returns:
- uint8_t the value of Interraupt Control (Register #9)
- Note:
- Register #9 Interrupt Control Register (0x89)
- bit[7:5] Interrupt Count Exceed
- bit[4] (n/a)
- bit[3] INT_PROX_ready_EN Eneables interrupt generation at proximity data ready
- bit[2] INT_ALS_ready_EN Enables interrupt generation at ambient data ready
- bit[1] INT_THRES_EN Enables interrupt generation when high or low threshold is exceeded
- bit[0] INT_THRES_SEL Thresholds are applied to 0:proximity 1:als measurement
- Interrupt Count Exceed
- 000 - 1 count = DEFAULT
- 001 - 2 count
- 010 - 4 count
- 011 - 8 count
- 100 - 16 count
- 101 - 32 count
- 110 - 64 count
- 111 - 128 count
Definition at line 131 of file VCNL4010.cpp.
uint8_t getIntStatus | ( | void | ) |
Get Interrupt Status.
- Parameters:
-
none
- Returns:
- uint8_t Interrupt Status (Register #14)
- Note:
- Register #14 Interrupt Status (0x8E)
- bit[7:4] (n/a)
- bit[3] int_prox_ready
- bit[2] int_als_ready
- bit[1] int_th_low
- bit[0] int_th_hi
- Once an interrupt is generated the corresponding status bit
- goes to 1 and stays there unless it is cleared by writing a 1
- in the corresponding bit.
Definition at line 182 of file VCNL4010.cpp.
uint8_t getIrLedCurrent | ( | void | ) |
Get IR LED Current Setting for Proximity Mode.
- Parameters:
-
none
- Returns:
- IR LED Current Settings (Register #3)
- Note:
- bit[7:6] Fuse prog ID
- bit[5:0] IR LED current value
- IR LED current = value(dec.) x 10mA
- Valid Range = 0 to 20d.
- 0 = 0mA, 1 = 10mA .. 20 = 200mA ((DEFAULT: 2 = 20mA)
Definition at line 83 of file VCNL4010.cpp.
uint16_t getLowThreshold | ( | void | ) |
Get Low Threshold.
- Parameters:
-
none
- Returns:
- uint16_t Low Threshold (Register #10, #11)
- Note:
- Register #10 and #11 Low Threshold (0x8A, 0x8B)
- bit[15:8] MSB (address 0x8A)
- bit[7:0] LSB (address 0x8B)
Definition at line 146 of file VCNL4010.cpp.
uint8_t getProductID | ( | void | ) |
Get Prodcut ID (and Revision)
- Parameters:
-
none
- Returns:
- Product ID and Revision Register (Register #1)
- Note:
- Register #1 Product ID Revision Register (0x81)
- bit[7:4] Product ID
- bit[3:0] Revision ID
Definition at line 61 of file VCNL4010.cpp.
uint16_t getProx | ( | void | ) |
Get Proximity Measurement Result.
- Parameters:
-
none
- Returns:
- uint16_t the value of Proximity Measurement Result (Register #7, #8)
- Note:
- Register #7 and #8 Proximity Measurement Result Register (0x87, 0x88)
- bit[15:8] MSB (address 0x87)
- bit[7:0] LSB (address 0x88)
Definition at line 122 of file VCNL4010.cpp.
uint8_t getProxModTiming | ( | void | ) |
Get Proximity Modulator Timing Adjustment.
- Parameters:
-
none
- Returns:
- Proximity Modulator Timing Adjustment (Register #15)
- Note:
- Register #15 Proximity Modulator Timing Adjustment (0x8F)
- bit[7:5] Modulation delay time
- bit[4:3] Proximity frequency
- bit[2:0] Modulation deat time
- The settings for best performance will be provided by Vishay.
- With first samples this is evaluated to:
- delay time = 0
- frequency = 0
- deat time = 1
- With that Register #15 should be programmed with 1 (= default value).
Definition at line 197 of file VCNL4010.cpp.
uint8_t getProxRate | ( | void | ) |
Get Rate of Proximity Measurement.
- Parameters:
-
none
- Returns:
- Rate of Proximity Measurement (Register #2)
- Note:
- Register #2 Rate of Proximity Measurement (0x82)
- bit[7:3] (n/a)
- bit[2:0] Rate of Proximity Measurement
- 000 - 1.95 measurements/s (DEFAULT)
- 001 - 3.960625 measurements/s
- 010 - 7.8125 measurements/s
- 011 - 16.625 measurements/s
- 100 - 31.25 measurements/s
- 101 - 62.5 measurements/s
- 110 - 125 measurements/s
- 111 - 250 measurements/s
Definition at line 68 of file VCNL4010.cpp.
void setAlsParam | ( | uint8_t | param ) |
Set Ambient Light Parameter.
- Parameters:
-
uint8_t value to set
- Returns:
- none
Definition at line 105 of file VCNL4010.cpp.
void setCommandReg | ( | uint8_t | cmd ) |
Set Command Register.
- Parameters:
-
uint8_t value to set
- Returns:
- none
Definition at line 53 of file VCNL4010.cpp.
void setHighThreshold | ( | uint16_t | thr ) |
Set High Threshold.
- Parameters:
-
uint16_t value to set
- Returns:
- none
Definition at line 173 of file VCNL4010.cpp.
void setIntCtrl | ( | uint8_t | ctrl ) |
Set Interrupt Control Register.
- Parameters:
-
uint8_t the value to set
- Returns:
- none
Definition at line 138 of file VCNL4010.cpp.
void setIntStatus | ( | uint8_t | status ) |
Set Interrupt Status.
- Parameters:
-
uint8_t value to set
- Returns:
- none
Definition at line 189 of file VCNL4010.cpp.
void setIrLedCurrent | ( | uint8_t | IrLedCur ) |
Set IR LED Current Setting for Proximity Mode.
- Parameters:
-
value to set
- Returns:
- none
Definition at line 90 of file VCNL4010.cpp.
void setLowThreshold | ( | uint16_t | thr ) |
Set Low Threshold.
- Parameters:
-
uint16_t value to set
- Returns:
- none
Definition at line 155 of file VCNL4010.cpp.
void setProxModTiming | ( | uint8_t | timing ) |
Set Proximity Modulator Timing Adjustment.
- Parameters:
-
uint8_t value to set
- Returns:
- none
Definition at line 204 of file VCNL4010.cpp.
void setProxRate | ( | uint8_t | rate ) |
Set Rate of Proximity Measurement.
- Parameters:
-
Rate of Proximity Measurement
- Returns:
- none
Definition at line 75 of file VCNL4010.cpp.
Generated on Fri Jul 15 2022 22:38:25 by
