1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-11-26 17:46:14 +01:00

Add VCNL4040 code

This commit is contained in:
FrightRisk 2023-06-23 11:50:51 -04:00
parent 354cc0cbcb
commit 56bcb57d83

View File

@ -29,41 +29,43 @@
* led drive current: 200 (Affects led brightness, therefore distance and sensitivity) * led drive current: 200 (Affects led brightness, therefore distance and sensitivity)
* persistence: (higher values reduce false triggers) * persistence: (higher values reduce false triggers)
* *
* The basic PS function settings, such as duty ratio, integration time, * The basic PS function settings, such as duty ratio, integration time,interrupt,
interrupt, and PS enable / disable, and persistence, are handled by the register: PS_CONF1. Duty ratio controls the PS response * and PS enable / disable, and persistence, are handled by the register: PS_CONF1.
time. Integration time represents the duration of the energy being received. The interrupt is triggered when the PS detection * Duty ratio controls the PS response time. Integration time represents the duration
levels over the high threshold level setting (register: PS_THDH) or lower than low threshold (register: PS_THDL). If the interrupt * of the energy being received. The interrupt is triggered when the PS detection
function is enabled, the host can react to the interrupt pin, instead of polling the PS data registers. The INT flag (register: * levels over the high threshold level setting (register: PS_THDH) or lower than
INT_Flag) indicates the type of interrupt that has been triggered, depending on the interrupt settings in the configuration * low threshold (register: PS_THDL). If the interrupt function is enabled, the host
registers. PS persistence (PS_PERS) sets up the PS INT trigger conditions, defining the amount of consecutive hits required * can react to the interrupt pin, instead of polling the PS data registers. The INT
before an interrupt event occurs. The intelligent cancellation level can be set on register: PS_CANC to reduce the cross talk * flag (register:INT_Flag) indicates the type of interrupt that has been triggered,
phenomenon. * depending on the interrupt settings in the configuration registers. PS persistence
VCNL4040 also supports an easy to use proximity detection logic mode, that triggers when the PS high threshold is exceeded * (PS_PERS) sets up the PS INT trigger conditions, defining the amount of consecutive
and automatically resets the interrupt pin when the proximity reading falls beneath the PS low threshold. This functionality can * hits required before an interrupt event occurs. The intelligent cancellation level
be set in the register: PS_MS. A smart persistence is provided to be able to prevent false PS interrupt trigger events. * can be set on register: PS_CANC to reduce the cross talk phenomenon.
Descriptions of each of these parameters are shown in table 1. * VCNL4040 also supports an easy to use proximity detection logic mode, that triggers
* when the PS high threshold is exceeded and automatically resets the interrupt pin
REGISTER: PS_CONF1 COMMAND CODE: 0x03_L (0x03 DATA BYTE LOW) * when the proximity reading falls beneath the PS low threshold. This functionality
Command Bit Description * can be set in the register: PS_MS. A smart persistence is provided to be able to
PS_Duty 7 : 6 (0 : 0) = 1/40, (0 : 1) = 1/80, (1 : 0) = 1/160, (1 : 1) = 1/320 * prevent false PS interrupt trigger events. Descriptions of each of these parameters
PS IRED on / off duty ratio setting * are shown in table 1.
PS_PERS 5 : 4 (0 : 0) = 1, (0 : 1) = 2, (1 : 0) = 3, (1 : 1) = 4 *
PS interrupt persistence setting * REGISTER: PS_CONF1 COMMAND CODE: 0x03_L (0x03 DATA BYTE LOW)
PS_ IT 3 : 1 (0 : 0 : 0) = 1T, (0 : 0 : 1) = 1.5T, (0 : 1 : 0) = 2T, (0 : 1 : 1) = 2.5T * Command Bit Description
(1 : 0 : 0) = 3T, (1 : 0 : 1) = 3.5T, (1 : 1 : 0) = 4T, (1 : 1 : 1) = 8T * PS_Duty 7 : 6 (0 : 0) = 1/40, (0 : 1) = 1/80, (1 : 0) = 1/160, (1 : 1) = 1/320
PS integration time setting * PS IRED on / off duty ratio setting
PS_SD 0 0 = PS power on, 1 = PS shut down, default = 1 * PS_PERS 5 : 4 (0 : 0) = 1, (0 : 1) = 2, (1 : 0) = 3, (1 : 1) = 4
* PS interrupt persistence setting
REGISTER: PS_CONF2 COMMAND CODE: 0x03_H (0x03 DATA BYTE HIGH) * PS_ IT 3 : 1 (0 : 0 : 0) = 1T, (0 : 0 : 1) = 1.5T, (0 : 1 : 0) = 2T, (0 : 1 : 1) = 2.5T
PS_HD 3 0 = PS output is 12 bits; 1 = PS output is 16 bits * (1 : 0 : 0) = 3T, (1 : 0 : 1) = 3.5T, (1 : 1 : 0) = 4T, (1 : 1 : 1) = 8T
Reserved 2 Default = 0 * PS integration time setting
PS_INT 1 : 0 (0 : 0) = interrupt disable, (0 : 1) = trigger when close, * PS_SD 0 0 = PS power on, 1 = PS shut down, default = 1
(1 : 0)= trigger when away, (1 : 1)= trigger when close or away *
* REGISTER: PS_CONF2 COMMAND CODE: 0x03_H (0x03 DATA BYTE HIGH)
fred gave up here. too many options to cover * PS_HD 3 0 = PS output is 12 bits; 1 = PS output is 16 bits
* Reserved 2 Default = 0
* PS_INT 1 : 0 (0 : 0) = interrupt disable, (0 : 1) = trigger when close,
* (1 : 0)= trigger when away, (1 : 1)= trigger when close or away
* *
* * NOTE: fnd stopped here
fnd stopped here
* the reflection of the pulse. The time between the pulse and the receipt of reflections * the reflection of the pulse. The time between the pulse and the receipt of reflections
* is measured and used to determine the distance to the reflecting object. * is measured and used to determine the distance to the reflecting object.
* *