📄 saver.c
字号:
#define SAVER_GLOBALS
#include "include.h"
#include <string.h>
#define NORMAL 0x01
//普通模式
#define SAVER 0x02
//搜救模式
#define REST 0x03
//空闲状态
UINT8 StatusOfSaver;
void main(void)
{
MCUInit();
MACInit();
Zigbee_PIB.MAC_PIB.aExtendedAddress.u16Val = 0xFF00;//PDA的地址
//SCIInitGeneric((UINT32)BUS_CLK, (UINT32)(38400), (UINT8)SCI_PORT2);
CLRWDT(); //喂狗
StatusOfSaver = REST;
// AskForEntironment = 0;
MLMEPAValueSet(21);//发射功率最大
// MLMESetChannelRequest(15);
// pTxBuffer[0] = Zigbee_PIB.MAC_PIB.macDstAddress.v[0];
// pTxBuffer[1] = Zigbee_PIB.MAC_PIB.macDstAddress.v[1];
// pTxBuffer[2] = Zigbee_PIB.MAC_PIB.macSrcAddress.v[0];
// pTxBuffer[3] = Zigbee_PIB.MAC_PIB.macSrcAddress.v[1];
// MLMERXEnableRequest((UINT32)0);//打开接收模块
EnableInterrupts; // 允许中断
while(1)
{
PHYTasks();
if(Zigbee_Flags.bits.PDDataIndication == 1)
{
//射频接收到数据
Zigbee_Flags.bits.PDDataIndication = 0;
Zigbee_Flags.bits.RxBufferIsUsed = 0;
if(StatusOfSaver = NORMAL)
{
//正常模式下,为透明传输
UINT8 i;
UINT8 length;
length = params.PD_DATA_indication.psduLength;
for(i = 0; i < length; i ++)
{
SCIStartTransmit(RxBuffer[i],SCI_PORT2);
}
}
else if(StatusOfSaver = SAVER)
{
//搜救模式下,接收卡号
if( (RxBuffer[0] == 0x03) && \
(RxBuffer[1] == 0x88) && \
(RxBuffer[2] == 0x99) && \
(RxBuffer[3] == 0x99) && \
(RxBuffer[4] == 0x99) && \
(RxBuffer[5] == 0xff) && \
(RxBuffer[6] == 0xfe) && \
(RxBuffer[7] == 0x99) && \
(RxBuffer[8] == 0x99) && \
(RxBuffer[11] == 0x07) )
}// end else if(StatusOfSaver = SAVER)
}// end if(Zigbee_Flags.bits.PDDataIndication == 1)
}// end while(1)
}// end main()
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -