4608
- 收藏
- 点赞
- 分享
- 举报
单片机C语言Zigbee协议栈 下载参考
* DF/KO 01/09/06 Microchip ZigBee Stack v1.0-3.5
********************************************************************/
#include "Compiler.h"
#include "generic.h"
#include "zigbee.def"
#include "ZigbeeTasks.h"
#include "zPHY.h"
#include "zMAC.h"
#include "zNWK.h"
#include "zAPS.h"
#include "zZDO.h"
#include "MSPI.h"
#include "sralloc.h"
#include "SymbolTime.h"
#include "console.h"
//#pragma udata TX_BUFFER=TX_BUFFER_LOCATION
BYTE TxBuffer[TX_BUFFER_SIZE];
//#pragma udata
#pragma udata RX_BUFFER=RX_BUFFER_LOCATION
volatile BYTE RxBuffer[RX_BUFFER_SIZE];
#pragma udata
BYTE * CurrentRxPacket;
PARAMS params;
BYTE RxRead;
volatile BYTE RxWrite;
BYTE TxData;
BYTE TxHeader;
volatile ZIGBEE_STATUS ZigBeeStatus;
void ZigBeeInit(void)
{
MACInit();
NWKInit();
APSInit();
ZDOInit();
TxHeader = 127;
TxData = 0;
RxWrite = 0;
RxRead = 0;
// Set up the interrupt to read in a data packet.
// set to capture on rising edge
CCP2CON = 0b00000101;
// set high priority for RX packet detection
CCP2IP = 1;
CCP2IF = 0;
CCP2IE = 1;
SRAMInitHeap();
InitSymbolTimer();
ZigBeeStatus.nextZigBeeState = NO_PRIMITIVE;
CurrentRxPacket = NULL;
}
BOOL ZigBeeTasks( ZIGBEE_PRIMITIVE *command )
{
ZigBeeStatus.nextZigBeeState = *command;
do /* need to determine/modify the exit conditions */
{
CLRWDT();
if(ZigBeeStatus.nextZigBeeState == NO_PRIMITIVE)
{
ZigBeeStatus.nextZigBeeState = PHYTasks(ZigBeeStatus.nextZigBeeState);
}
if(ZigBeeStatus.nextZigBeeState == NO_PRIMITIVE)
{
ZigBeeStatus.nextZigBeeState = MACTasks(ZigBeeStatus.nextZigBeeState);
}
if(ZigBeeStatus.nextZigBeeState == NO_PRIMITIVE)
{
ZigBeeStatus.nextZigBeeState = NWKTasks(ZigBeeStatus.nextZigBeeState);
}
if(ZigBeeStatus.nextZigBeeState == NO_PRIMITIVE)
{
ZigBeeStatus.nextZigBeeState = APSTasks(ZigBeeStatus.nextZigBeeState);
}
if(ZigBeeStatus.nextZigBeeState == NO_PRIMITIVE)
{
ZigBeeStatus.nextZigBeeState = ZDOTasks(ZigBeeStatus.nextZigBeeState);
}
switch(ZigBeeStatus.nextZigBeeState)
{
// Check for the primitives that are handled by the PHY.
case PD_DATA_request:
case PLME_CCA_request:
case PLME_ED_request:
case PLME_SET_request:
case PLME_GET_request:
case PLME_SET_TRX_STATE_request:
ZigBeeStatus.nextZigBeeState = PHYTasks(ZigBeeStatus.nextZigBeeState);
break;
// Check for the primitives that are handled by the MAC.
case PD_DATA_indication:
case PD_DATA_confirm:
case PLME_ED_confirm:
case PLME_GET_confirm:
case PLME_CCA_confirm:
case PLME_SET_TRX_STATE_confirm:
case PLME_SET_confirm:
case MCPS_DATA_request:
case MCPS_PURGE_request:
case MLME_ASSOCIATE_request:
case MLME_ASSOCIATE_response:
case MLME_DISASSOCIATE_request:
case MLME_GET_request:
case MLME_GTS_request:
case MLME_ORPHAN_response:
case MLME_RESET_request:
case MLME_RX_ENABLE_request:
case MLME_SCAN_request:
case MLME_SET_request:
case MLME_START_request:
case MLME_SYNC_request:
case MLME_POLL_request:
ZigBeeStatus.nextZigBeeState = MACTasks(ZigBeeStatus.nextZigBeeState);
break;
// Check for the primitives that are handled by the NWK.
case MCPS_DATA_confirm:
case MCPS_DATA_indication:
case MCPS_PURGE_confirm:
case MLME_ASSOCIATE_indication:
case MLME_ASSOCIATE_confirm:
case MLME_DISASSOCIATE_indication:
case MLME_DISASSOCIATE_confirm:
case MLME_BEACON_NOTIFY_indication:
case MLME_GET_confirm:
case MLME_GTS_confirm:
case MLME_GTS_indication:
case MLME_ORPHAN_indication:
case MLME_RESET_confirm:
case MLME_RX_ENABLE_confirm:
case MLME_SCAN_confirm:
case MLME_COMM_STATUS_indication:
case MLME_SET_confirm:
case MLME_START_confirm:
case MLME_SYNC_LOSS_indication:
case MLME_POLL_confirm:
case NLDE_DATA_request:
case NLME_NETWORK_DISCOVERY_request:
case NLME_NETWORK_FORMATION_request:
case NLME_PERMIT_JOINING_request:
case NLME_START_ROUTER_request:
case NLME_JOIN_request:
case NLME_DIRECT_JOIN_request:
case NLME_LEAVE_request:
case NLME_RESET_request:
case NLME_SYNC_request:
case NLME_GET_request:
case NLME_SET_request:
ZigBeeStatus.nextZigBeeState = NWKTasks( ZigBeeStatus.nextZigBeeState );
break;
// Check for the primitives that are handled by the APS.
case NLDE_DATA_confirm:
case NLDE_DATA_indication:
case APSDE_DATA_request:
case APSME_BIND_request:
case APSME_UNBIND_request:
ZigBeeStatus.nextZigBeeState = APSTasks( ZigBeeStatus.nextZigBeeState );
break;
case ZDO_DATA_indication:
case ZDO_BIND_req:
case ZDO_UNBIND_req:
case ZDO_END_DEVICE_BIND_req:
ZigBeeStatus.nextZigBeeState = ZDOTasks( ZigBeeStatus.nextZigBeeState );
break;
// Check for the primitives that are returned to the user.
case NLME_NETWORK_DISCOVERY_confirm:
case NLME_NETWORK_FORMATION_confirm:
case NLME_PERMIT_JOINING_confirm:
case NLME_START_ROUTER_confirm:
case NLME_JOIN_confirm:
case NLME_DIRECT_JOIN_confirm:
case NLME_LEAVE_confirm:
case NLME_RESET_confirm:
case NLME_SYNC_confirm:
case NLME_GET_confirm:
case NLME_SET_confirm:
case NLME_JOIN_indication:
case NLME_LEAVE_indication:
case NLME_SYNC_indication:
case APSDE_DATA_confirm:
case APSDE_DATA_indication:
case APSME_BIND_confirm:
case APSME_UNBIND_confirm:
*command = ZigBeeStatus.nextZigBeeState;
if (ZDOHasBackgroundTasks() || APSHasBackgroundTasks() || NWKHasBackgroundTasks() ||
MACHasBackgroundTasks() || PHYHasBackgroundTasks())
{
ZigBeeStatus.flags.bits.bHasBackgroundTasks = 1;
return TRUE;
}
else
{
ZigBeeStatus.flags.bits.bHasBackgroundTasks = 0;
return FALSE;
}
break;
}
} while (ZigBeeStatus.nextZigBeeState != NO_PRIMITIVE);
*command = ZigBeeStatus.nextZigBeeState;
if (ZDOHasBackgroundTasks() || APSHasBackgroundTasks() || NWKHasBackgroundTasks() ||
MACHasBackgroundTasks() || PHYHasBackgroundTasks())
{
ZigBeeStatus.flags.bits.bHasBackgroundTasks = 1;
return TRUE;
}
else
{
//ConsolePutROMString((ROM char*)"Exiting ZigbeeTasks() with tasks remaining\r\n");
ZigBeeStatus.flags.bits.bHasBackgroundTasks = 0;
return FALSE;
}
}
********************************************************************/
#include "Compiler.h"
#include "generic.h"
#include "zigbee.def"
#include "ZigbeeTasks.h"
#include "zPHY.h"
#include "zMAC.h"
#include "zNWK.h"
#include "zAPS.h"
#include "zZDO.h"
#include "MSPI.h"
#include "sralloc.h"
#include "SymbolTime.h"
#include "console.h"
//#pragma udata TX_BUFFER=TX_BUFFER_LOCATION
BYTE TxBuffer[TX_BUFFER_SIZE];
//#pragma udata
#pragma udata RX_BUFFER=RX_BUFFER_LOCATION
volatile BYTE RxBuffer[RX_BUFFER_SIZE];
#pragma udata
BYTE * CurrentRxPacket;
PARAMS params;
BYTE RxRead;
volatile BYTE RxWrite;
BYTE TxData;
BYTE TxHeader;
volatile ZIGBEE_STATUS ZigBeeStatus;
void ZigBeeInit(void)
{
MACInit();
NWKInit();
APSInit();
ZDOInit();
TxHeader = 127;
TxData = 0;
RxWrite = 0;
RxRead = 0;
// Set up the interrupt to read in a data packet.
// set to capture on rising edge
CCP2CON = 0b00000101;
// set high priority for RX packet detection
CCP2IP = 1;
CCP2IF = 0;
CCP2IE = 1;
SRAMInitHeap();
InitSymbolTimer();
ZigBeeStatus.nextZigBeeState = NO_PRIMITIVE;
CurrentRxPacket = NULL;
}
BOOL ZigBeeTasks( ZIGBEE_PRIMITIVE *command )
{
ZigBeeStatus.nextZigBeeState = *command;
do /* need to determine/modify the exit conditions */
{
CLRWDT();
if(ZigBeeStatus.nextZigBeeState == NO_PRIMITIVE)
{
ZigBeeStatus.nextZigBeeState = PHYTasks(ZigBeeStatus.nextZigBeeState);
}
if(ZigBeeStatus.nextZigBeeState == NO_PRIMITIVE)
{
ZigBeeStatus.nextZigBeeState = MACTasks(ZigBeeStatus.nextZigBeeState);
}
if(ZigBeeStatus.nextZigBeeState == NO_PRIMITIVE)
{
ZigBeeStatus.nextZigBeeState = NWKTasks(ZigBeeStatus.nextZigBeeState);
}
if(ZigBeeStatus.nextZigBeeState == NO_PRIMITIVE)
{
ZigBeeStatus.nextZigBeeState = APSTasks(ZigBeeStatus.nextZigBeeState);
}
if(ZigBeeStatus.nextZigBeeState == NO_PRIMITIVE)
{
ZigBeeStatus.nextZigBeeState = ZDOTasks(ZigBeeStatus.nextZigBeeState);
}
switch(ZigBeeStatus.nextZigBeeState)
{
// Check for the primitives that are handled by the PHY.
case PD_DATA_request:
case PLME_CCA_request:
case PLME_ED_request:
case PLME_SET_request:
case PLME_GET_request:
case PLME_SET_TRX_STATE_request:
ZigBeeStatus.nextZigBeeState = PHYTasks(ZigBeeStatus.nextZigBeeState);
break;
// Check for the primitives that are handled by the MAC.
case PD_DATA_indication:
case PD_DATA_confirm:
case PLME_ED_confirm:
case PLME_GET_confirm:
case PLME_CCA_confirm:
case PLME_SET_TRX_STATE_confirm:
case PLME_SET_confirm:
case MCPS_DATA_request:
case MCPS_PURGE_request:
case MLME_ASSOCIATE_request:
case MLME_ASSOCIATE_response:
case MLME_DISASSOCIATE_request:
case MLME_GET_request:
case MLME_GTS_request:
case MLME_ORPHAN_response:
case MLME_RESET_request:
case MLME_RX_ENABLE_request:
case MLME_SCAN_request:
case MLME_SET_request:
case MLME_START_request:
case MLME_SYNC_request:
case MLME_POLL_request:
ZigBeeStatus.nextZigBeeState = MACTasks(ZigBeeStatus.nextZigBeeState);
break;
// Check for the primitives that are handled by the NWK.
case MCPS_DATA_confirm:
case MCPS_DATA_indication:
case MCPS_PURGE_confirm:
case MLME_ASSOCIATE_indication:
case MLME_ASSOCIATE_confirm:
case MLME_DISASSOCIATE_indication:
case MLME_DISASSOCIATE_confirm:
case MLME_BEACON_NOTIFY_indication:
case MLME_GET_confirm:
case MLME_GTS_confirm:
case MLME_GTS_indication:
case MLME_ORPHAN_indication:
case MLME_RESET_confirm:
case MLME_RX_ENABLE_confirm:
case MLME_SCAN_confirm:
case MLME_COMM_STATUS_indication:
case MLME_SET_confirm:
case MLME_START_confirm:
case MLME_SYNC_LOSS_indication:
case MLME_POLL_confirm:
case NLDE_DATA_request:
case NLME_NETWORK_DISCOVERY_request:
case NLME_NETWORK_FORMATION_request:
case NLME_PERMIT_JOINING_request:
case NLME_START_ROUTER_request:
case NLME_JOIN_request:
case NLME_DIRECT_JOIN_request:
case NLME_LEAVE_request:
case NLME_RESET_request:
case NLME_SYNC_request:
case NLME_GET_request:
case NLME_SET_request:
ZigBeeStatus.nextZigBeeState = NWKTasks( ZigBeeStatus.nextZigBeeState );
break;
// Check for the primitives that are handled by the APS.
case NLDE_DATA_confirm:
case NLDE_DATA_indication:
case APSDE_DATA_request:
case APSME_BIND_request:
case APSME_UNBIND_request:
ZigBeeStatus.nextZigBeeState = APSTasks( ZigBeeStatus.nextZigBeeState );
break;
case ZDO_DATA_indication:
case ZDO_BIND_req:
case ZDO_UNBIND_req:
case ZDO_END_DEVICE_BIND_req:
ZigBeeStatus.nextZigBeeState = ZDOTasks( ZigBeeStatus.nextZigBeeState );
break;
// Check for the primitives that are returned to the user.
case NLME_NETWORK_DISCOVERY_confirm:
case NLME_NETWORK_FORMATION_confirm:
case NLME_PERMIT_JOINING_confirm:
case NLME_START_ROUTER_confirm:
case NLME_JOIN_confirm:
case NLME_DIRECT_JOIN_confirm:
case NLME_LEAVE_confirm:
case NLME_RESET_confirm:
case NLME_SYNC_confirm:
case NLME_GET_confirm:
case NLME_SET_confirm:
case NLME_JOIN_indication:
case NLME_LEAVE_indication:
case NLME_SYNC_indication:
case APSDE_DATA_confirm:
case APSDE_DATA_indication:
case APSME_BIND_confirm:
case APSME_UNBIND_confirm:
*command = ZigBeeStatus.nextZigBeeState;
if (ZDOHasBackgroundTasks() || APSHasBackgroundTasks() || NWKHasBackgroundTasks() ||
MACHasBackgroundTasks() || PHYHasBackgroundTasks())
{
ZigBeeStatus.flags.bits.bHasBackgroundTasks = 1;
return TRUE;
}
else
{
ZigBeeStatus.flags.bits.bHasBackgroundTasks = 0;
return FALSE;
}
break;
}
} while (ZigBeeStatus.nextZigBeeState != NO_PRIMITIVE);
*command = ZigBeeStatus.nextZigBeeState;
if (ZDOHasBackgroundTasks() || APSHasBackgroundTasks() || NWKHasBackgroundTasks() ||
MACHasBackgroundTasks() || PHYHasBackgroundTasks())
{
ZigBeeStatus.flags.bits.bHasBackgroundTasks = 1;
return TRUE;
}
else
{
//ConsolePutROMString((ROM char*)"Exiting ZigbeeTasks() with tasks remaining\r\n");
ZigBeeStatus.flags.bits.bHasBackgroundTasks = 0;
return FALSE;
}
}
文件: C语言zigbee协议栈基于PCI单片机.rar
下载
我来回答
回答0个
时间排序
认可量排序
暂无数据
或将文件直接拖到这里
悬赏:
E币
网盘
* 网盘链接:
* 提取码:
悬赏:
E币
Markdown 语法
- 加粗**内容**
- 斜体*内容*
- 删除线~~内容~~
- 引用> 引用内容
- 代码`代码`
- 代码块```编程语言↵代码```
- 链接[链接标题](url)
- 无序列表- 内容
- 有序列表1. 内容
- 缩进内容
- 图片![alt](url)
相关问答
-
2020-10-05 19:15:12
-
2008-07-29 12:56:25
-
2020-10-21 17:27:43
-
2013-08-29 15:07:47
-
2010-04-12 21:52:30
-
62020-11-24 17:44:55
-
12008-07-15 17:26:31
-
02018-12-13 11:21:54
-
2018-12-11 15:52:25
-
2018-12-13 13:49:13
-
2013-11-19 19:09:13
-
2018-12-18 14:32:17
-
02008-07-11 20:58:57
-
2019-08-20 15:37:58
-
2013-08-28 11:45:31
-
2018-12-12 10:56:44
-
2020-11-22 18:55:26
-
2008-07-15 18:45:12
-
2018-12-20 09:07:48
无更多相似问答 去提问
点击登录
-- 积分
-- E币
提问
—
收益
—
被采纳
—
我要提问
切换马甲
上一页
下一页
悬赏问答
-
5Hi3516CV610 如何使用SD卡升级固件
-
5cat /dev/logmpp 报错 <3>[ vi] [func]:vi_send_frame_node [line]:99 [info]:vi pic queue is full!
-
50如何获取vpss chn的图像修改后发送至vo
-
5FPGA通过Bt1120传YUV422数据过来,vi接收不到数据——3516dv500
-
50SS928 运行PQtools 拼接 推到设备里有一半画面会异常
-
53536AV100的sample_vdec输出到CVBS显示
-
10海思板子mpp怎么在vi阶段改变视频数据尺寸
-
10HI3559AV100 多摄像头同步模式
-
9海思ss928单路摄像头vio中加入opencv处理并显示
-
10EB-RV1126-BC-191板子运行自己编码的程序
举报反馈
举报类型
- 内容涉黄/赌/毒
- 内容侵权/抄袭
- 政治相关
- 涉嫌广告
- 侮辱谩骂
- 其他
详细说明
提醒
你的问题还没有最佳答案,是否结题,结题后将扣除20%的悬赏金
取消
确认
提醒
你的问题还没有最佳答案,是否结题,结题后将根据回答情况扣除相应悬赏金(1回答=1E币)
取消
确认