4663
- 收藏
- 点赞
- 分享
- 举报
单片机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
-
2018-12-13 13:49:13
-
2013-11-19 19:09:13
-
02018-12-13 11:21:54
-
12008-07-15 17:26:31
-
2018-12-11 15:52:25
-
2013-08-28 11:45:31
-
2018-12-18 14:32:17
-
02008-07-11 20:58:57
-
2019-08-20 15:37:58
-
2018-12-12 10:56:44
-
2020-11-22 18:55:26
-
2008-07-15 18:45:12
-
2019-01-04 17:06:13
无更多相似问答 去提问
点击登录
-- 积分
-- E币
提问
—
收益
—
被采纳
—
我要提问
切换马甲
上一页
下一页
悬赏问答
-
5SS928的emmc有32GB,bootargs设置使用16GB,但是为啥能用的只有rootfs的大小
-
33SS928怎样烧写ubuntu系统
-
10ToolPlatform下载rootfs提示网络失败
-
10谁有GK7205V500的SDK
-
5Hi3516CV610 烧录不进去
-
10Hi3559AV100 芯片硬解码h265编码格式的视频时出现视频播放错误,解码错误信息 s32PackErr:码流有错
-
5海思SS928 / SD3403的sample_venc.c摄像头编码Demo中,采集到的摄像头的YUV数据在哪个相关的函数中?
-
5海鸥派openEuler无法启动网卡,连接WIFI存在问题
-
66有没有ISP相关的巨佬帮忙看看SS928对接IMX347的图像问题
-
50求助hi3559与FPGA通过SLVS-EC接口对接问题
举报反馈
举报类型
- 内容涉黄/赌/毒
- 内容侵权/抄袭
- 政治相关
- 涉嫌广告
- 侮辱谩骂
- 其他
详细说明
提醒
你的问题还没有最佳答案,是否结题,结题后将扣除20%的悬赏金
取消
确认
提醒
你的问题还没有最佳答案,是否结题,结题后将根据回答情况扣除相应悬赏金(1回答=1E币)
取消
确认