第一范文网 - 专业文章范例文档资料分享平台

无线传感网络课程设计

来源:用户分享 时间:2025/6/25 13:40:09 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

uint8 Saddr[2]; //网络地址 uint8 DataBuf[16]; //数据缓冲区 uint8 CRC; //校验位 uint8 LastByte;//帧尾 }TXDATA;

}UartTxBuf;//从串口发送数据帧

union h{

uint8 RxBuf[32]; struct RFRXBUF {

uint8 Head; //头

uint8 HeadCom[3]; //命令头 uint8 Laddr[8]; uint8 Saddr[2];

uint8 DataBuf[16]; //数据缓冲区 uint8 CRC; //校验位 uint8 LastByte;//帧尾 }RXDATA;

}RfRx;//无线接收缓冲区

union j{

uint8 TxBuf[32]; struct RFTXBUF {

uint8 Head; //头 uint8 HeadCom[3]; //命令头 uint8 Laddr[8]; uint8 Saddr[2];

uint8 DataBuf[16]; //数据缓冲区 uint8 CRC; //校验位 uint8 LastByte;//帧尾 }TXDATA;

}RfTx;//无线发送缓冲区

uint16 Ultrasonic_Count;//超声波计数

/***************************************************************************** void WaitUs(uint16 microSecs)

延时uS函数.

*****************************************************************************/

void WaitUs(uint16 microSecs) {

while(microSecs--) {

/* 32 NOPs == 1 usecs */

asm(\ asm(\ asm(\ asm(\ asm(\ asm(\ asm(\ } }

/***************************************************************************** uint8 SendData( uint16 addr, uint8 *buf, uint8 Leng)

发送一组数据.

*****************************************************************************/ uint8 SendData( uint16 addr, uint8 *buf, uint8 Leng) {

afAddrType_t SendDataAddr;

SendDataAddr.addrMode = (afAddrMode_t)Addr16Bit; SendDataAddr.endPoint = SAMPLEAPP_ENDPOINT; SendDataAddr.addr.shortAddr = addr;

if ( AF_DataRequest( &SendDataAddr, &SampleApp_epDesc, 2,//SAMPLEAPP_PERIODIC_CLUSTERID, Leng, buf, &SampleApp_TransID,

AF_DISCV_ROUTE, // AF_ACK_REQUEST,

AF_DEFAULT_RADIUS ) == afStatus_SUCCESS ) {

return 1; } else {

return 0;// Error occurred in request to send. } }

case 1://DAC 输出

if(DispState == 0) {

DAC_OUT_CON(0x07ff, 0x07ff);

LcdPutString16_8(0, 0, (void*)\ }

else if(DispState == 1) {

DAC_OUT_CON(0x03ff, 0x03ff);

sprintf(msg,\

LcdPutString16_8(0, 0, (void*)msg, 12 , 1); }

else if(DispState == 2) {

DAC_OUT_CON(0x0Bff, 0x0Bff);

sprintf(msg,\

LcdPutString16_8(0, 0, (void*)msg, 12 , 1); }

break; case 2://高亮LED控制 if(DispState == 0) { ChangT3Cmp0Val(0xff); P1_6 = 0; LcdPutString16_8(0, 0, (void*)\ } else if(DispState == 1) { ChangT3Cmp0Val(230); LcdPutString16_8(0, 0, (void*)\ } else if(DispState == 2) { ChangT3Cmp0Val(25); LcdPutString16_8(0, 0, (void*)\ } break; }

void SampleApp_Init( uint8 task_id ) {

SampleApp_TaskID = task_id;

SampleApp_NwkState = DEV_INIT; SampleApp_TransID = 0;

// Device hardware initialization can be added here or in main() (Zmain.c). // If the hardware is application specific - add it here.

// If the hardware is other parts of the device add it in main().

#if defined ( HOLD_AUTO_START )

// HOLD_AUTO_START is a compile option that will surpress ZDApp // from starting the device and wait for the application to // start the device. ZDOInitDevice(0); #endif

// Fill out the endpoint description.

SampleApp_epDesc.endPoint = SAMPLEAPP_ENDPOINT; SampleApp_epDesc.task_id = &SampleApp_TaskID; SampleApp_epDesc.simpleDesc

= (SimpleDescriptionFormat_t *)&SampleApp_SimpleDesc; SampleApp_epDesc.latencyReq = noLatencyReqs;

// Register the endpoint description with the AF afRegister( &SampleApp_epDesc );

// Register for all key events - This app will handle all key events RegisterForKeys( SampleApp_TaskID );

#ifdef WXL_COORD

MT_UartRegisterTaskID(SampleApp_TaskID); #endif }

void SampleApp_Init( uint8 task_id ) {

SampleApp_TaskID = task_id; SampleApp_NwkState = DEV_INIT; SampleApp_TransID = 0;

// Device hardware initialization can be added here or in main() (Zmain.c). // If the hardware is application specific - add it here.

// If the hardware is other parts of the device add it in main().

搜索更多关于: 无线传感网络课程设计 的文档
无线传感网络课程设计.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c64ulu9mwat7yogl1itk20zdc523xwm00i3k_7.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top