//--------------------------------------------------------------------------------------------------
//複撇痢徹
//複撇痢徹
//複撇痢徹
//--------------------------------------------------------------------------------------------------
//**************************************************************************************************
// 枴裳�� include: 頌綁� 頡溺億闐��� 頑廈餃隆顏灘 糟瘧� 撇頡鼻僮粳贖 憐溴雒�
//**************************************************************************************************
#include "Peripherals\Temperature\lm75ad\lm75ad.h"
//**************************************************************************************************
// 枴裳�� 複擇滇雒璃� 影蜥褓蝴
//**************************************************************************************************
//**************************************************************************************************
// 枴裳�� 複擇滇雒璃� 幌螂畫贛贖 閱擇慮瘩贖
//**************************************************************************************************
signed int CurrentTemp_LM75AD[2]={0,0};
signed int CurrentType_LM75AD[2]={NORM,NORM};
//**************************************************************************************************
// 娘璀甕� 菊萄慘鋼蒐
//**************************************************************************************************
//------------------------------------------------------------------------------
//PT_THREAD(Send_data_T(struct pt *pt,unsigned char data1,unsigned char data2)){
//unsigned char mode234=0;
//unsigned char TestDelayI2c;
// //---------------------------------------------------------------------------
// if(pt->lc!=0){ //押 閱撼癮 頑餓縈
// if(GetTimers(I2C_TimeOut)>TIMEOUT_I2C){
// Send_MSG(MSG_I2C_REBOOT);
// ResetTimers(I2C_TimeOut);
// }
// }
// //---------------------------------------------------------------------------
// PT_BEGIN(pt);
// TestDelayI2c=100;
// ResetTimers(I2C_TimeOut);
// /* initiate start sequence */
// //---------------------------------------------------------------------------
// while(TakeMutex(I2C_MUTEX)){PT_YIELD(pt);}
// I2C_LM75AD->CR1|=I2C_CR1_PE;// peripheral enable
// I2C_GenerateSTART(I2C_LM75AD, ENABLE);
// /* check start bit flag */
// while(!I2C_GetFlagStatus(I2C_LM75AD, I2C_FLAG_SB)){PT_YIELD(pt);};
// /*send write command to chip*/
// I2C_Send7bitAddress(I2C_LM75AD, I2C_ADDR_LCD_KEY_LED, I2C_Direction_Transmitter);
// /*check master is now in Tx mode*/
// //--------------------------------------------------------------------------
// while(!I2C_CheckEvent(I2C_LM75AD, I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED)){PT_YIELD(pt);}; //Spead=400KHz delay=1000 clock Spead=1KHz delay=65000 clock
// /*mode register address*/
// I2C_SendData(I2C_LM75AD, data1);
// //--------------------------------------------------------------------------
// /*wait for byte send to complete*/
// while(!I2C_CheckEvent(I2C_LM75AD, I2C_EVENT_MASTER_BYTE_TRANSMITTED)){PT_YIELD(pt);}; //3600 Speed=100Khz
// /*clear bits*/
// I2C_SendData(I2C_LM75AD, data2);
// //--------------------------------------------------------------------------
// /*wait for byte send to complete*/
// while(!I2C_CheckEvent(I2C_LM75AD, I2C_EVENT_MASTER_BYTE_TRANSMITTED)){PT_YIELD(pt);};
// //--------------------------------------------------------------------------
// /*generate stop*/
// I2C_GenerateSTOP(I2C_LM75AD, ENABLE);
//while(I2C_GetFlagStatus(I2C_LM75AD, I2C_FLAG_BUSY)){PT_YIELD(pt);};
// I2C_LM75AD->CR1&=~I2C_CR1_PE;// peripheral disable
// while(TestDelayI2c--);
// GiveMutex(I2C_MUTEX);
//
// PT_END(pt);
//}
unsigned short int ReadData[2];
unsigned int ConvertT;
struct pt Im75adMain;
PT_THREAD(RunIm75ad(struct pt *pt,unsigned char id)){
static struct pt Pt_im75ad;
//------------------------------------------------
PT_BEGIN(pt);
PT_INIT(&Pt_im75ad);
//------------------------------------------------
DEBUGER("==============================",id,0,0);
DEBUGER("======RunIm75ad_START=========",id,0,0);
DEBUGER("==============================",id,0,0);
while(1){
//======================================================================================
DEBUGER("------------------------------",id,0,0);
DEBUGER("---------�1-------------------",id,0,0);
DEBUGER("------------------------------",id,0,0);
PT_WAIT_THREAD_NO_EXIT(pt,im75ad_Read(&Pt_im75ad,&ReadData[0],I2C_LM75AD_ADDR_T1,id));
//--------------------------------------------------------------------------------------
if(pt->flag!=PT_ERROR){
ConvertT=ReadData[0];
ConvertT=ConvertT*1000;
ConvertT=(ConvertT>>8);
asm("nop");
//ConvertT=(ConvertT>>5);
//ConvertT=ConvertT*100;
//ConvertT=ConvertT/8;
CurrentTemp_LM75AD[LM75AD_T1]=ConvertT;
DEBUGER("T1=",id,ConvertT,0);
CurrentType_LM75AD[LM75AD_T1]=NORM;
}else{
CurrentType_LM75AD[LM75AD_T1]=ERROR;
}
//======================================================================================
DEBUGER("------------------------------",id,0,0);
DEBUGER("---------�2-------------------",id,0,0);
DEBUGER("------------------------------",id,0,0);
PT_WAIT_THREAD_NO_EXIT(pt,im75ad_Read(&Pt_im75ad,&ReadData[1],I2C_LM75AD_ADDR_T2,id));
//--------------------------------------------------------------------------------------
if(pt->flag!=PT_ERROR){ //枰褕撿� 蒙� 頑閑橘慣痘� 縯璀甕� im75ad_Read
ConvertT=ReadData[1];
ConvertT=(ConvertT>>5);
ConvertT=ConvertT*1000;
ConvertT=ConvertT/8;
CurrentTemp_LM75AD[LM75AD_T2]=ConvertT;
DEBUGER("T2=",id,ConvertT,0);
CurrentType_LM75AD[LM75AD_T2]=NORM;
}else{
CurrentType_LM75AD[LM75AD_T2]=ERROR;
}
//======================================================================================
PT_END_YIELD(pt);
}
PT_END(pt);
}
//==============================================================================
/*
* @狙撇痢徹: 丑瘩�� 縯璀甕� 膳摘權琯� 鳩皓粵徹 鋼憫綑痞曖� 愿 LM75AD.
* @Return: �頊擋麴綏 膳摘痢磋� 菴瞄� ([P0...P7]<<8)|[P10...P17]
*/
PT_THREAD(im75ad_Read(struct pt *pt,short unsigned int* dataout,const unsigned char addr_in,unsigned char id)){
static short unsigned int tmp[2];
static unsigned char addr;
static short unsigned int* dataout_temp;
static unsigned char CounterWaitSendAddr;
PT_BEGIN(pt);
DEBUGER("==============================",id,0,0);
DEBUGER("=======L75AD_Read_START=======",id,0,0);
DEBUGER("==============================",id,0,0);
while(1){
//------------------------------------------------------------------------------------
addr=addr_in;
dataout_temp=dataout;
//------------------------------------------------------------------------------------
I2C_GenerateSTART(I2C_LM75AD, ENABLE);
/* check start bit flag */
DEBUGER("==============================",id,0,0);
DEBUGER("LM75AD_I2C_SET_START",id,0,0);
CounterWaitSendAddr=0;
do{
if(CounterWaitSendAddr>200){
DEBUGER("*****LM75AD_ReStart_ADDR****",ID_ERROR,addr,0);
CounterWaitSendAddr=0;
goto BreakError;
}
CounterWaitSendAddr++;
PT_YIELD(pt);
}
while(!I2C_CheckEvent(I2C_LM75AD, I2C_EVENT_MASTER_MODE_SELECT));
/*send write command to chip*/
//----------------------SEND_ADDR_Write-------------------------------------------------------
I2C_Send7bitAddress(I2C_LM75AD,(addr), I2C_Direction_Transmitter);
DEBUGER("LM75AD_I2C_SET_ADDR=",id,addr,0);
CounterWaitSendAddr=0;
do{
if(CounterWaitSendAddr>200){
DEBUGER("*****LM75AD_ReStart_ADDR****",ID_ERROR,addr,0);
CounterWaitSendAddr=0;
goto BreakError;
}
Co
没有合适的资源?快使用搜索试试~ 我知道了~
lm75ad.rar_LM75AD_endl5v_stm32
![preview](https://csdnimg.cn/release/downloadcmsfe/public/img/white-bg.ca8570fa.png)
共4个文件
h:2个
c:2个
![preview-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/scale.ab9e0183.png)
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 138 浏览量
2022-09-21
22:32:12
上传
评论
收藏 6KB RAR 举报
温馨提示
Init lm75ad on stm32
资源推荐
资源详情
资源评论
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![application/msword](https://img-home.csdnimg.cn/images/20210720083327.png)
![ppt](https://img-home.csdnimg.cn/images/20210720083527.png)
![text/x-c](https://img-home.csdnimg.cn/images/20210720083646.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![application/x-zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![application/msword](https://img-home.csdnimg.cn/images/20210720083327.png)
![cpp](https://img-home.csdnimg.cn/images/20210720083646.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
收起资源包目录
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
共 4 条
- 1
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/36163497263541e6b6d5b627b1692a97_weixin_42653691.jpg!1)
朱moyimi
- 粉丝: 65
- 资源: 1万+
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)