TI中文支持网
TI专业的中文技术问题搜集分享网站

cc2530,求在这个程序中加个温度采集值判断的程序,详细进帖,急求!!!!!!

#include "ZComDef.h"
#include "Onboard.h"
#include "hal_uart.h"
#include "MT_UART.h"
#include "AF.h"
#include "hal_led.h"
#include "GenericApp.h"
#include "WSN.h"
#include "hal_adc.h"
#include "string.h"
#include "hal_lcd.h"
#include "sht1x.h"
#include "lcd_5110.h"

/*网络启动*/
void WSN_on_start()
{
#if defined(LCD_SUPPORTED)
lcd5110_init();
#endif
sht10_init();
}

/*定时器事件*/
void WSN_on_timer()
{
uint32 value;
byte *ext_addr;
uint16 vdd;
uint8 buff[5] ={0x00, 0x00,0x00,0x00,0x00};

buff[0]= 2;//亮度1,温度2,湿度3
ext_addr = NLME_GetExtAddr();
buff[1] = ext_addr[1];
buff[2] = ext_addr[0];
//温度
value = (unsigned short int)sht10_tempture();//单位0.1度
buff[3] = (value >>8)&0xFF;
buff[4] = value&0xFF;
WSN_SendData(0,(uint8 *)buff,5);

HalLedSet(HAL_LED_1,HAL_LED_MODE_BLINK);
}
extern endPointDesc_t GenericApp_epDesc;
extern byte GenericApp_TransID; // This is the unique message ID (counter)
/*发送数据*/
unsigned char WSN_SendData(UINT16 addr, uint8 *buf, uint8 Length)
{
afAddrType_t DestAddr;
DestAddr.addrMode = (afAddrMode_t)Addr16Bit;
DestAddr.endPoint = GENERICAPP_ENDPOINT;
DestAddr.addr.shortAddr = addr;
if ( AF_DataRequest( &DestAddr, &GenericApp_epDesc,
GENERICAPP_CLUSTERID,
Length,
buf,
&GenericApp_TransID,
AF_DISCV_ROUTE,
AF_DEFAULT_RADIUS ) == afStatus_SUCCESS )
{
return 1;
}
else
{
return 0;
}
}

void WSN_IncomingMSG( afIncomingMSGPacket_t *pkt )
{

}
void WSN_UART_ProcessData( uint8 port, uint8 event )
{
}

主要是比较温度采集值与固定值大小,并输出高低电平的程序,比如固定值为200(单位是0.1°),如果采集值大于200则输出高电平,小于等于则输出低电平,表现方式随意,只要能显示判断出来就行,程序如上!

Junyan Zhu:

自己先占个沙发,嘎嘎,这么多人看,怎么没人回答~~~~~

赞(0)
未经允许不得转载:TI中文支持网 » cc2530,求在这个程序中加个温度采集值判断的程序,详细进帖,急求!!!!!!
分享到: 更多 (0)