⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 admini.c

📁 使用Microchip公司16F648实现4*6键盘程序. 在PICC环境下编译通过,包含RS485通讯. 代码完整,可供参考.
💻 C
字号:
 
//任务调度管理
#include  "pic16f62xa.h"
#include  "pic.h"
#include  "typedefine.h"
#include  "extern.h"


void Modbus_Scan(void);

void Key_Scall(void)           //  500us once.
{
	if(MissionFlag.bits.scankey)    //2ms once.
	{
		KeyValueAffFun();	        //键盘扫描
	}

	if(MissionFlag.bits.keybitmanage)  //8ms once.
	{
		Keybit_Manage();     //键盘位值处理
	}

	if(MissionFlag.bits.keymanage)      //9ms once.
	{
		Key_Manage();		//键值处理
	}

	if(MissionFlag.bits.ledshow)
	{
 		subled();
	}

	if(MissionFlag.bits.ledshowdigitcou)
	{
		 sub2();
	}
}


void Admini(void)
{
	Key_Scall(); 
	Modbus_Scan();
}


void Modbus_Scan(void)
{
//	test
#ifdef testSim
	static int yatoTag = -1;
	if (yatoTag < 0)
	{
		UartStruct.bits.singleKeyTag = 1;
		yatoTag = 0;
	}
#endif testSim
//-------------------

	if(UartStruct.bits.singleKeyTag)
	{
		UartStruct.bits.singleKeyTag = 0;
		if(UartStruct.bits.HostStatus==0)
		{	
			singleKeyTranmit();
		}
	}

	if(UartStruct.bits.frameSendEndTag)
	{
		UartStruct.bits.frameSendEndTag = 0;
		receTimeOut = FrameOverCou;
		En_Receive();
	}
	
//帧处理.
 	checkComm0Modbus();
//从站回复处理.
}



/*
void UartScan(void)
{
//	//if have one new key vlaue tag.1 yes,0 no.
//	//如果有键值处理标记置位,调用发送函数.
//	if(UartSlaveStruct.bits.UartSendTag)   //每间隔1s被置位一次
//	{
//		UartSlaveStruct.bits.UartSendTag = 0;
////		Transmit();
//	}
//	
//	if(UartSlaveDelayStruct.SendLastStatus.bits.LastByteCountTag)
//	{
//		if(UartSlaveDelayStruct.SendLastStatus.bits.SendCountEndTag)
//		{
//			UartSlaveDelayStruct.SendLastStatus.allbits = 0x00;     
//			UartSlaveStruct.bits.UartSendEndTag = 1;        //发送一帧结束(包括20ms延迟)  
//		}
//	}
//	
////这里需要修改.
//	if(UartSlaveStruct.bits.UartSendEndTag) 		
//	{
//		UartSlaveStruct.bits.UartSendEndTag = 0;    
//		while(0 == TRMT);    	
//		ClearBus(GetDataBus,5);        //----清数组		
//	    En_Receive();    	
//		UartSlaveDelayStruct.ReceiveCountStatus.bits.ReceiveCountTag = 1;    
//	}	
//		
////  接受计时溢出有三种情况:  
////	1,接受正常结束. 2,时间到了而未接受到数据. 
////  3.时间到了而只接受到了部分数据. 
//	if(UartSlaveDelayStruct.ReceiveCountStatus.bits.ReceiveCountOverflowTag)
//	{
//		En_Idlesse();             //调用第三层
////        ReceiveFrameDisFun();     //receive data will dispose function.
//	    UartSlaveDelayStruct.ReceiveCountStatus.bits.ReceiveCountOverflowTag = 0;
//	}
	
 	if(UartSlaveDelayStruct.ReceiveCountStatus.bits.ReceiveCountOverflowTag)
 	{	
 		En_Idlesse();             //调用第三层  $$$$$$$$$$$$$$$$$$$
        ReceiveFrameDisFun();     //receive data will dispose function.
 	    UartSlaveDelayStruct.ReceiveCountStatus.bits.ReceiveCountOverflowTag = 0;
 	}	
	
	//发送模块标记位扫描. 
 	if(UartSlaveStruct.bits.RespondReadyTag) 
	{ 
	    En_Transmit(); 
		UartSlaveStruct.bits.RespondReadyTag=0; 
	} 
	
	if(UartSlaveDelayStruct.SendLastStatus.bits.LastByteCountTag) 
	{	
		if(UartSlaveDelayStruct.SendLastStatus.bits.SendCountEndTag) 
		{ 
			UartSlaveDelayStruct.SendLastStatus.allbits = 0; 
			UartSlaveDelayStruct.SendLastCou = 0; 
			En_Receive();  
		}
	}
}	
*/
	
		
			
		

⌨️ 快捷键说明

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