当前位置:网站首页>Mlx90640 infrared thermal imaging sensor temperature measurement module development notes (II)
Mlx90640 infrared thermal imaging sensor temperature measurement module development notes (II)
2022-07-21 08:55:00 【51CTO】
MLX90640 Infrared thermal imager temperature measurement module development notes ( Two )API transplant -I2C And key interface functions
API There are official migration instructions in the documentation , But I think we can focus on MLX90640 Several functions related to specific operation , And with standards I2C The related functions and file structures are still implemented according to their customary routines . This is more in line with the controllable habits of our developers . Steps are as follows :
(1) Establish standards I2C file IIC.h and IIC.c
Use your own method to realize the following functions ( Hardware is good ,GPIO Simulation is good ), The function name is suggested below .
void IIC_Init(void); //I2C Interface initialization
void IIC_Start(void); // Send the start signal
void IIC_Stop(void); // Send end signal
void IIC_SendACK(void); // Send reply signal
void IIC_SendNAK(void); // Send non reply signal unsigned char IIC_RecvACK(void); // Read the reply signal unsigned char IIC_RecvData(void); // Read 1 Bytes void IIC_SendData(char dat); // send out 1 Bytes
(2) Introduce... Into the project MLX90640_API.c
And make the following modifications
first line #include <MLX90640_I2C_Driver.h> Change it to #include <IIC.h>
(3) add to 3 A function
void MLX90640_I2CInit(void)
unsigned char MLX90640_I2CRead (unsigned short startAddress, unsigned short nWordsRead, unsigned short *datas)
unsigned char MLX90640_I2CWrite (unsigned short writeAddress, unsigned short word)
void MLX90640_I2CInit(void)
{
IIC_Stop();
}
// Read from the specified address n A word ( Occupied per word 2 Bytes )
unsigned char MLX90640_I2CRead(unsigned short startAddress, unsigned short nWordsRead, unsigned short *datas)
{
unsigned char c1,c2; unsigned short i; unsigned char Msb,Lsb;
Msb=(unsigned char)(startAddress>>8); Lsb=(unsigned char)(startAddress&0x00FF);
IIC_Start(); // Send start command
IIC_SendData(0x66); // Send device address + Write orders IIC_RecvACK();
IIC_SendData(Msb); // Send the address value to be operated 2 byte
IIC_RecvACK();
IIC_SendData(Lsb);
IIC_RecvACK();
IIC_Start(); // Send start command
IIC_SendData(0x67); // Send device address + Read command IIC_RecvACK();
for (i=0;i<nWordsRead;i++)
{
c1=IIC_RecvData(); IIC_SendACK();
c2=IIC_RecvData();
if (i==(nWordsRead-1)) IIC_SendNAK();
else
IIC_SendACK();
datas[i]=c1; datas[i]<<=8; datas[i]|=c2;
}
IIC_Stop(); // Send stop command
return 0;
}
// Write... To the specified address 1 A word (2 byte )
unsigned char MLX90640_I2CWrite(unsigned int writeAddress, unsigned int word)
{
IIC_Start(); // Send start command
IIC_SendData(0x66); // Send device address + Write orders IIC_RecvACK();
IIC_SendData(writeAddress>>8); // Send the address value to be operated 2 byte
IIC_RecvACK();
IIC_SendData(writeAddress&0x00FF); IIC_RecvACK();
IIC_SendData(word>>8); IIC_RecvACK();
IIC_SendData(word&0x00FF); IIC_RecvACK();
IIC_Stop(); return 0;
(4) modify 2 A function
unsigned char MLX90640_DumpEE(unsigned short *eeData)
{
return MLX90640_I2CRead(0x2400, 832, eeData);
}
unsigned char MLX90640_GetFrameData(unsigned short *frameData)
{
unsigned short statusRegister,controlRegister1;
MLX90640_I2CRead(0x8000, 1, &statusRegister); if (statusRegister&0x0008)// There are measurements completed Frame
{
MLX90640_I2CRead(0x800D, 1, &controlRegister1); MLX90640_I2CWrite(0x8000, statusRegister&(~0x0018)); MLX90640_I2CRead(0x0400, 832, frameData); frameData[832] = controlRegister1;
frameData[833] = statusRegister & 0x0001; return 0;
}
Return -1;
}
So far, the migration is complete
Compiler Engineering , If there is no error prompt, there is basically no problem , The next chapter begins with how to operate MLX90640.
边栏推荐
猜你喜欢
Latex笔记
Scala advanced (VII): collection content summary (Part 1)
去河南投资,VC很犹豫
密码输入框And优惠券And自定义软键盘
Nacos手摸手教学【一】Nacos动态配置
IV Uni app component [view component, basic content (official self-contained, such as form class), UI component library, pit of component library]
三.uni-app配置文件[全局配置、底部导航栏配置、文件配置]
Rsync combined with inotify to realize real-time file synchronization (I)
How to write the docker cleaning cache script
Airbnb的动态kubernetes集群扩缩容
随机推荐
App automated Test-5 Touch screen operation and toast processing
全网追杀“钱包刺客”
斯坦福、Meta AI新研究:实现AGI之路,数据剪枝比我们想象得更重要
How to write the docker cleaning cache script
Window进入别的目录
Fabric.js 居中元素
APP自动化测试-2. Appium录制测试用例
When business goes out to sea, you should "get your hands dirty" before inspiration appears
密码输入框And优惠券And自定义软键盘
六石管理学:流程只是便于推脱责任,对解决问题无帮助
依赖注入
三.uni-app配置文件[全局配置、底部导航栏配置、文件配置]
Practice upgrade! Chuangyu security trusteeship helps you solve the problem of directional blasting defense
openGauss内核分析:查询重写
Scala advanced (VII): collection content summary (Part 1)
App automated test-2 Appium recording test cases
JS determines whether each key in the object has a value
[freeswitch development practice] using ESL to connect freeswitch in C language
如何关闭页面之前清空LocalStorage
MySQL基础(多表查询、事务)