/**
* @copyright (C) 2017 Melexis N.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#include <MLX90640_I2C_Driver.h>
#include <MLX90640_API.h>
#include <math.h>
void ExtractVDDParameters(uint16_t *eeData, paramsMLX90640 *mlx90640);
void ExtractPTATParameters(uint16_t *eeData, paramsMLX90640 *mlx90640);
void ExtractGainParameters(uint16_t *eeData, paramsMLX90640 *mlx90640);
void ExtractTgcParameters(uint16_t *eeData, paramsMLX90640 *mlx90640);
void ExtractResolutionParameters(uint16_t *eeData, paramsMLX90640 *mlx90640);
void ExtractKsTaParameters(uint16_t *eeData, paramsMLX90640 *mlx90640);
void ExtractKsToParameters(uint16_t *eeData, paramsMLX90640 *mlx90640);
void ExtractAlphaParameters(uint16_t *eeData, paramsMLX90640 *mlx90640);
void ExtractOffsetParameters(uint16_t *eeData, paramsMLX90640 *mlx90640);
void ExtractKtaPixelParameters(uint16_t *eeData, paramsMLX90640 *mlx90640);
void ExtractKvPixelParameters(uint16_t *eeData, paramsMLX90640 *mlx90640);
void ExtractCPParameters(uint16_t *eeData, paramsMLX90640 *mlx90640);
void ExtractCILCParameters(uint16_t *eeData, paramsMLX90640 *mlx90640);
int ExtractDeviatingPixels(uint16_t *eeData, paramsMLX90640 *mlx90640);
int CheckAdjacentPixels(uint16_t pix1, uint16_t pix2);
int CheckEEPROMValid(uint16_t *eeData);
int MLX90640_DumpEE(uint8_t slaveAddr, uint16_t *eeData)
{
return MLX90640_I2CRead(slaveAddr, 0x2400, 832, eeData);
}
int MLX90640_GetFrameData(uint8_t slaveAddr, uint16_t *frameData)
{
uint16_t dataReady = 1;
uint16_t controlRegister1;
uint16_t statusRegister;
int error = 1;
uint8_t cnt = 0;
dataReady = 0;
while(dataReady == 0)
{
error = MLX90640_I2CRead(slaveAddr, 0x8000, 1, &statusRegister);
if(error != 0)
{
return error;
}
dataReady = statusRegister & 0x0008;
}
while(dataReady != 0 && cnt < 5)
{
error = MLX90640_I2CWrite(slaveAddr, 0x8000, 0x0030);
if(error == -1)
{
return error;
}
error = MLX90640_I2CRead(slaveAddr, 0x0400, 832, frameData);
if(error != 0)
{
return error;
}
error = MLX90640_I2CRead(slaveAddr, 0x8000, 1, &statusRegister);
if(error != 0)
{
return error;
}
dataReady = statusRegister & 0x0008;
cnt = cnt + 1;
}
if(cnt > 4)
{
return -8;
}
error = MLX90640_I2CRead(slaveAddr, 0x800D, 1, &controlRegister1);
frameData[832] = controlRegister1;
frameData[833] = statusRegister & 0x0001;
if(error != 0)
{
return error;
}
return frameData[833];
}
int MLX90640_ExtractParameters(uint16_t *eeData, paramsMLX90640 *mlx90640)
{
int error = CheckEEPROMValid(eeData);
if(error == 0)
{
ExtractVDDParameters(eeData, mlx90640);
ExtractPTATParameters(eeData, mlx90640);
ExtractGainParameters(eeData, mlx90640);
ExtractTgcParameters(eeData, mlx90640);
ExtractResolutionParameters(eeData, mlx90640);
ExtractKsTaParameters(eeData, mlx90640);
ExtractKsToParameters(eeData, mlx90640);
ExtractAlphaParameters(eeData, mlx90640);
ExtractOffsetParameters(eeData, mlx90640);
ExtractKtaPixelParameters(eeData, mlx90640);
ExtractKvPixelParameters(eeData, mlx90640);
ExtractCPParameters(eeData, mlx90640);
ExtractCILCParameters(eeData, mlx90640);
error = ExtractDeviatingPixels(eeData, mlx90640);
}
return error;
}
//------------------------------------------------------------------------------
int MLX90640_SetResolution(uint8_t slaveAddr, uint8_t resolution)
{
uint16_t controlRegister1;
int value;
int error;
value = (resolution & 0x03) << 10;
error = MLX90640_I2CRead(slaveAddr, 0x800D, 1, &controlRegister1);
if(error == 0)
{
value = (controlRegister1 & 0xF3FF) | value;
error = MLX90640_I2CWrite(slaveAddr, 0x800D, value);
}
return error;
}
//------------------------------------------------------------------------------
int MLX90640_GetCurResolution(uint8_t slaveAddr)
{
uint16_t controlRegister1;
int resolutionRAM;
int error;
error = MLX90640_I2CRead(slaveAddr, 0x800D, 1, &controlRegister1);
if(error != 0)
{
return error;
}
resolutionRAM = (controlRegister1 & 0x0C00) >> 10;
return resolutionRAM;
}
//------------------------------------------------------------------------------
int MLX90640_SetRefreshRate(uint8_t slaveAddr, uint8_t refreshRate)
{
uint16_t controlRegister1;
int value;
int error;
value = (refreshRate & 0x07)<<7;
error = MLX90640_I2CRead(slaveAddr, 0x800D, 1, &controlRegister1);
if(error == 0)
{
value = (controlRegister1 & 0xFC7F) | value;
error = MLX90640_I2CWrite(slaveAddr, 0x800D, value);
}
return error;
}
//------------------------------------------------------------------------------
int MLX90640_GetRefreshRate(uint8_t slaveAddr)
{
uint16_t controlRegister1;
int refreshRate;
int error;
error = MLX90640_I2CRead(slaveAddr, 0x800D, 1, &controlRegister1);
if(error != 0)
{
return error;
}
refreshRate = (controlRegister1 & 0x0380) >> 7;
return refreshRate;
}
//------------------------------------------------------------------------------
int MLX90640_SetInterleavedMode(uint8_t slaveAddr)
{
uint16_t controlRegister1;
int value;
int error;
error = MLX90640_I2CRead(slaveAddr, 0x800D, 1, &controlRegister1);
if(error == 0)
{
value = (controlRegister1 & 0xEFFF);
error = MLX90640_I2CWrite(slaveAddr, 0x800D, value);
}
return error;
}
//------------------------------------------------------------------------------
int MLX90640_SetChessMode(uint8_t slaveAddr)
{
uint16_t controlRegister1;
int value;
int error;
error = MLX90640_I2CRead(slaveAddr, 0x800D, 1, &controlRegister1);
if(error == 0)
{
value = (controlRegister1 | 0x1000);
error = MLX90640_I2CWrite(slaveAddr, 0x800D, value);
}
return error;
}
//------------------------------------------------------------------------------
int MLX90640_GetCurMode(uint8_t slaveAddr)
{
uint16_t controlRegister1;
int modeRAM;
int error;
error = MLX90640_I2CRead(slaveAddr, 0x800D, 1, &controlRegister1);
if(error != 0)
{
return error;
}
modeRAM = (controlRegister1 & 0x1000) >> 12;
return modeRAM;
}
//------------------------------------------------------------------------------
void MLX90640_CalculateTo(uint16_t *frameData, const paramsMLX90640 *params, float emissivity, float tr, float *result)
{
float vdd;
float ta;
float ta4;
float tr4;
float taTr;
float gain;
float irDataCP[2];
float irData;
float alphaCompensated;
uint8_t mode;
int8_t
可乐渴了吗
- 粉丝: 13
- 资源: 56
最新资源
- 基于STM32为电子香味项目,通过蓝牙模块传输数据,嵌入式硬件平台,RFID使用的是RC522.整个项目包括软硬件以及android程序详细文档+全部资料+高分项目+源码.zip
- 基于发布-订阅模型的多线程消息框架,用于嵌入式平台,纯C实现,性能和灵活性极高详细文档+全部资料+高分项目+源码.zip
- 基于嵌入式Linux的一套可视对讲设备代码,比较底层,写的比较好,里面的lib库是一些图像处理库详细文档+全部资料+高分项目+源码.zip
- php 实现各种排序和查找算法源代码.zip
- 基于嵌入式qt的车载系统详细文档+全部资料+高分项目+源码.zip
- 基于嵌入式的基础图形库详细文档+全部资料+高分项目+源码.zip
- 基于嵌入式平台ARM Linux的新冠肺炎疫情监控平台详细文档+全部资料+高分项目+源码.zip
- 基于嵌入式的视觉运动控制详细文档+全部资料+高分项目+源码.zip
- 基于嵌入式综合项目:STM32F407基于ARM Cortex-M4处理器,云服务器Linux操作系统,MySQL数据存储转发详细文档+全部资料+高分项目+源码
- 基于热风控制系统嵌入式项目,基于STM32F1芯片和RT-Thread实时系统开发出温度闭环控制和风速控制详细文档+全部资料+高分项目+源码.zip
- 基于全志V3S的嵌入式开发者打怪升级项目详细文档+全部资料+高分项目+源码.zip
- 基于事件型嵌入式驱动框架。详细文档+全部资料+高分项目+源码.zip
- 基于使用B-Tree作为索引,基于MMap的嵌入式键值数据库详细文档+全部资料+高分项目+源码.zip
- 基于三个嵌入式的小项目:一个是基于科大讯飞的语音识别系统,一个是智能音乐相册,一个是别踩白块小游戏详细文档+全部资料+高分项目+源码.zip
- 基于物联网模式开发的嵌入式程序详细文档+全部资料+高分项目+源码.zip
- 基于以太网通信的电力电子设备运行状态的远程监控嵌入式系统设计详细文档+全部资料+高分项目+源码.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈