⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tmp100.c

📁 详细介绍了arm7-at91r40008,的开发全过程
💻 C
字号:
#include "../ucos_ii/includes.h"
extern I2Cdesc     I2C_line ;

//*---------------------------------------------------------------------------------------
//* Function Name       : Clock_Read( INT16U address, INT8U *data_array, INT32U num_bytes )
//* Object              : Reading the serial EEPROM  note: the data outout buffer are full
//*                       when I2C_line.state != OK
//* Input Parameters    :
//*         address   : devive assress to Read
//*         pointer   : data to read
//*         num_bytes : nbbyte
//* Output Parameters   : none
//*---------------------------------------------------------------------------------------
void  TMP100_Read(INT16U address, INT8U *data_array, INT32U num_bytes )
{//* Begin
    
    I2C_line.deviceAddress = TMP100ADDRESS;
     
     //* Set the recivied buffer
    I2C_line.RxEnd = I2C_line.RxPtr  = data_array;

    //* Trig the timer
    I2C_line.timerBase->TC_CCR = TC_SWTRG;
   // at91_I2CTransfertEnd(&I2C_line);  //    new
    at91_I2CRead(&I2C_line,address,num_bytes,FALSE);
    
     
    
    at91_I2CTransfertEnd(&I2C_line);


}//* End
short ReadTemperature(void)
{ 
    INT8U TMPBuffer[2];
    short tem;
    
    IIC_TransfertEnd();
    
    Timer2SwitchToI2C();
    
   // at91_irq_close ( WDI_ID );
    
    TMP100_Read(0,TMPBuffer, 2);
    /*at91_irq_open ( WDI_ID ,
                         INTWATCHDOG ,
                         AIC_SRCTYPE_INT_EDGE_TRIGGERED ,
                         OSTickISR ) ; */                        
    
    
    Timer2SwitchToFreq();   
    
    IIC_TransfertEnd();
    
	//dingding051209
	tem = TMPBuffer[0]*2 + ((TMPBuffer[1]&0x80)>>7);
	if (!(TMPBuffer[0]&0x80))	 //温度为正值
	{
 		tem = tem * 5;
	}
	else
	{   
		tem = (tem | 0xFE00) * 5;
	}
     
	return tem;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -