port.c

来自「MCS51的实现无线接收发送(315M或433M)源程序代码。」· C语言 代码 · 共 79 行

C
79
字号
/**********************************************************
*                  Port.c                                 *
**********************************************************/
#define PORT_GLOBALS 
//=========================================================
#include "Os\Sm5964.h"
#include "Os\Struct.h"
#include "Os\Hardware.h"
#include "Os\Uart.h"
#include "Os\Tools.h"
#include "Os\Error.h"
#include "Os\OS.h"
#include "Os\TmrTsk.h"
#include "Os\TskMan.h"
#include "Os\Tmr2.h"
#include "Config.h"
#include "ApplyStruct.h"
#include "Port.h"
//=========================================================
#define DEBUG_PORT   0
//=========================================================
static INT16UX KeyCount;
//=========================================================
static void ScanKey(void)
{
	  if(KEY==0) KeyCount++;
	  else
	    {
	    	if(KeyCount)
	    	  {
	    	  	SendTskMsg(PORTTSKID,MSG_PORTKEY,KeyCount);
	    	  	KeyCount=0;
	    	  }
	    }
}
//=========================================================
void PortTmrProc(void)
{
	  #if DEBUG_PORT
	  //DebugStrLF((INT8UC *)"PortTmrProc()");
	  #endif
	  LED=!LED;
	  ScanKey();
	  StartTmr(PORTTMRID,1);
}
//=========================================================
void InitPortTsk(void)
{
	  #if DEBUG_PORT
	  MDebugStrLF((INT8UC *)"InitPortTsk()");
	  #endif
	  P0=0XFF;
	  P2=0XFF;
	 
   KeyCount=0;

	  InstallTmr(PORTTMRID,PortTmrProc);
	  StartTmr(PORTTMRID,1);
}
//=========================================================
void HdlKey(INT16U KeyValue)
{
	  #if DEBUG_PORT
	  MDebugWordPara((INT8UC *)"HdlKey:",KeyValue);
	  #endif
	  if(KeyValue<SECOND) GotoIsp();
}
//=========================================================
void PortTskEntry(void)
{
	  #if DEBUG_PORT
	  MDebugStrLF((INT8UC *)"PortTskEntry()");
	  #endif
	  
	  if(TskMsg.MsgId==MSG_PORTKEY) HdlKey(TskMsg.Para);
}
//=========================================================

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?