资源简介
mlx90640是一款红外热像仪模块32×24 像素, I2C 接口通信,兼容 3.3V/5V 电平。采用 MLX90640 远红外热传感器阵列,可精确检测特定区域和温度范围内的目标物体,尺寸小巧,可方便集成到各种工业或智能控制应用中。本驱动跟测试案例是在rk3288 7.1平台上面验证过可行,可以正常获取温度的参考代码
代码片段和文件信息
#include
#include
#include
#include
#include
#include
#include
#include
#ifdef CONFIG_OF_GPIO
#include
#endif
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define DRIVER_NAME “mlx90640“
#define MLX90640_IOCTL_MAGIC ‘m‘
#define MLX90640_GET_DATA _IOR(MLX90640_IOCTL_MAGIC 1 int *)
#define MLX90640_SET_DATA _IOR(MLX90640_IOCTL_MAGIC 2 int *)
struct mlx90640_chip {
struct mutex i2c_lock;
struct i2c_client *client;
const char *const *names;
};
struct MLX90640_R_DATA{
uint16_t reg;
uint16_t size;
uint16_t buff[1664];
};
struct MLX90640_W_DATA{
uint16_t reg;
uint16_t size;
uint16_t data;
};
struct mlx90640_chip *gchip = NULL;
static int mlx90640_open(struct inode *inode struct file *filp)
{
return 0;
}
int mlx90640_release(struct inode *inode struct file *filp)
{
return 0;
}
static int i2c_master_recv_(struct i2c_client *clientchar *msgbufuint16_t *datauint16_t nMemAdddressRead)
{
struct i2c_msg msgs[2];
struct i2c_adapter *adap = client->adapter;
int ret;
uint16_t bytesRemaining = nMemAdddressRead * 2;
int cnt = 0;
int i = 0;
uint16_t *p = data;
char i2cData[1664];
msgs[0].addr = client->addr;
msgs[0].flags = I2C_M_TEN; /* write */
msgs[0].len = 2;
msgs[0].buf = msgbuf;
msgs[1].addr = client->addr;
msgs[1].flags = I2C_M_RD | I2C_M_NOSTART;
msgs[1].len = bytesRemaining;
msgs[1].buf = i2cData;
memset(i2cData0bytesRemaining);
ret = i2c_transfer(adap&msgs2);
for(cnt = 0;cnt < nMemAdddressRead;cnt++){
i = cnt << 1;
*p++ = ((uint16_t)i2cData[i] << 8) | i2cData[i+1];
}
return 0;
}
static int mlx90640_write_data(struct i2c_client *clientuint16_t reguint16_t buf)
{
int ret = 0;
u8 abuf[4];
abuf[0] = reg >> 8;
abuf[1] = reg;
abuf[2] = buf >> 8;
abuf[3] = buf;
ret = i2c_master_send(clientabuf4);
return ret;
}
static int mlx90640_read_data(struct i2c_client *clientuint16_t reguint16_t *datauint16_t nMemAdddressRead)
{
int rc;
u8 msgbuf[2];
msgbuf[0] = reg >> 8;
msgbuf[1] = reg;
rc = i2c_master_recv_(clientmsgbufdatanMemAdddressRead);
return 0;
}
static long mlx90640_ioctl(struct file *file unsigned int cmdunsigned long arg)
{
struct MLX90640_R_DATA data;
struct MLX90640_W_DATA w_data;
mutex_lock(&gchip->i2c_lock);
switch(cmd){
case MLX90640_GET_DATA:
if(copy_from_user((void*)&da
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 6296 2020-02-22 17:28 mlx90640_code\mlx90640-i2c.c
文件 8845 2020-02-22 17:28 mlx90640_code\mlx90640.zip
文件 344 2020-02-22 17:31 mlx90640_code\readme.txt
目录 0 2020-02-22 17:29 mlx90640_code\
- 上一篇:ADS第八讲功分器的设计
- 下一篇:蓝牙BLE调试助手软件源码
相关资源
- 红外测温程序
- mlx90614红外无接触测温测试通过.rar
- MLX90614红外测温 STM32完整工程文件
- 基于红外测温仪的输送带防撕裂装置
- 基于51单片机的MLX90614红外测温仪实验
- TN901红外测温仪 非接触红外测温仪 设
- 单片机和LCD实现红外测温仪设计
- MLX90640.zip
- MLX90640综合读写测试程序(STC单片机)
- STM8红外温度传感器MLX90614源代码
- 红外非接触式电子体温计枪设计提供
- SampleCode32x32dR2.rar
- MLX90640中文数据手册中文-稳控科技译
- MLX90640开发笔记完整十章20191012.pdf
- 基于STM8L方案:额温枪、红外测温仪设
- BH67F2752_红外测温方案额温枪额温枪原
- TN905/TN901红外测温模块STM32程序
评论
共有 条评论