距离传感器vcnl4010驱动总结

Vcnl4010是集距离和光度探测的传感器,配置接口是I2C总线。对于以i2c为接口的外围设备(vcnl4010、lm3560等),其驱动编写过程如下:

1.      DATASHEET的阅读:通过阅读DATASHEET弄清楚设备的工作原理,然后从设备寄存器出发,弄清楚设备的工作模式,尽可能的将每一种模式进行独立编写,驱动程序只提供机制。例如vcnl4010驱动,每一个函数代表一种机制,包括感光/距离探测模式的选择,是单次检测还是周期性检测的模型选择,每种模式的中断使能,以及中断阈值的设定等等分别以单个函数进行实现。

2.      对于中断:vcnl4010比vcnl4000添加了中断模式,vcnl4010提供一个中断引脚与CPU的GPIO进行连接,外接的GPIO会配置上拉电阻,通过设定中断阈值(主要使用在距离探测方面)和中断条件(探测到几次发生中断),完成中断触发。中断发生后,外接的GPIO电平会拉低,并保持不变,此时中断状态寄存器值发生改变,对应的不同模式中断触发位(低阈值/高阈值/光度/)会自动置1,当对vcnl寄存器相应位写1,中断电平变高,中断寄存器为0.

I2C设备中断配置总结:

1)  对应的GPIO配置成中断模式(armA5的方式是首先配置成输入模式,然后是触发方式,一般是边缘触发,最后中断使能)

2)  设置好设备中断触发模式,在中断发生后要清除中断,需注意在中断处理函数中不能做耗时的操作,比如说对vcnl中断位的复位(I2C设备是外围设备&

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
VCNL4040 integrates a proximity sensor (PS), ambient light sensor (ALS), and a high power IRED into one small package. It incorporates photodiodes, amplifiers, and analog to digital converting circuits into a single chip by CMOS process. The 16-bit high resolution ALS offers excellent sensing capabilities with sufficient selections to fulfill most applications whether dark or high transparency lens design. High and low interrupt thresholds can be programmed for both ALS and PS, allowing the component to use a minimal amount of the microcontrollers resources. The proximity sensor features an intelligent cancellation scheme, so that cross talk phenomenon is eliminated effectively. To accelerate the PS response time, smart persistence prevents the misjudgment of proximity sensing but also keeps a fast response time. In active force mode, a single measurement can be requested, allowing another good approach for more design flexibility to fulfill different kinds of applications with more power saving. The patented Filtron TM technology achieves ambient light spectral sensitivity closest to real human eye response and offers the best background light cancellation capability (including sunlight) without utilizing the microcontrollers’ resources. VCNL4040 provides an excellent temperature compensation capability for keeping output stable under various temperature configurations. ALS and PS functions are easily set via the simple command format of I 2 C (SMBus compatible) interface protocol. Operating voltage ranges from 2.5 V to 3.6 V. VCNL4040 is packaged in a lead (Pb)-free 8-pin molding package, which offers the best market-proven reliability quality.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值