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

📄 detect.c

📁 M37546产品群智能水表的解决方案,请需要的朋友下载
💻 C
字号:
/************************************************************************/
/* Renesas System Solutions (Beijing) Co., LTD.							*/
/* All rights reserved.													*/
/*																		*/
/* File Name		: Detect.c											*/
/* Description		: 													*/
/*																		*/
/* Current Version	: 1.0												*/
/* Designer			: Feng Jun											*/
/* Start Date		: 2006-11-3											*/
/* Complete Date	: 2006-11-22										*/
/*																		*/
/* Lastest Version	:													*/
/* Designer			:													*/
/* Start Date		: 													*/
/* Complete Date	: 													*/
/************************************************************************/
#include "Detect.h"
#include "main.h"




/*************************************************************************
Name: 			CheckTypePower
Parameters: 	None
Returns: 		None
Description: 	Check the type of power on
*************************************************************************/
void CheckTypePower(void)
{
	io_fluxcontrol = 1;				/* Allow detecting flow sensors and card */
	nop_instruction();
	nop_instruction();
	nop_instruction();
	nop_instruction();
	
	if (io_cardinside == 1)
	{								/* IC card inside */
		g_statusA = 1;				/* Process card */
	}
	else if (io_flow1==1 || io_flow2==1)
		{							/* Flow sensor acts */
			g_statusA = 4;			/* Process flux */
		}
		else 
		{							/* Accident */
			g_statusA = 5;
		}
	
	io_fluxcontrol = 0;				/* Forbid detecting flow sensors and card */
}

/*************************************************************************
Name: 			DetectFlux
Parameters: 	None
Returns: 		None
Description: 	Wait for 3s, detect flux and control the valve
*************************************************************************/
void DetectFlux(void)
{

	io_fluxcontrol = 1;				/* Allow detecting flow sensors and card */
/* Is there the instruction of closing the valve ? */	
	if (B_closevalve == 1)	
	{								/* To close the valve */
		if (io_valveclosed != 0)	
		{							/* Close the valve */
			io_closevalve = 1;
			io_openvalve = 0;

			TimerAStart();
			B_timerA10s = 1;
			B_timerA3s  = 0;
		}
		else
			{						/* The valve is open */
				B_closevalve = 0;	/* Finish operation of valve */
				B_openvalve = 0;
				io_closevalve = 0;
				io_openvalve = 0;

				TimerAStart();		/* TimerA start */
				B_timerA3s  = 1;
				B_timerA10s = 0;
			}
	}
	
/* Is there the instruction of opening the valve ? */	
	if (B_openvalve == 1)	
	{								/* To open the valve */
		if (io_valveopen != 0)	
		{							/* Open the valve */
			io_openvalve = 1;
			io_closevalve = 0;

			TimerAStart();
			B_timerA10s = 1;
			B_timerA3s  = 0;
		}
		else
			{						/* The valve is closed */
				B_openvalve = 0;	/* Finish operation of valve */
				B_closevalve = 0;
				io_openvalve = 0;
				io_closevalve = 0;

				TimerAStart();		/* TimerA start */
				B_timerA3s  = 1;
				B_timerA10s = 0;
			}
	}
	
/* TimerA start */
//	if (B_openvalve==0 && B_openvalve==0 & B_timerAstart==0)
//	{
//			TimerAStart();		/* TimerA start */
//			B_timerAstart = 1;
//	}
	
/* Detect flow */		
	if (io_flow1 == 1)
	{
		if (B_ioflow1 == 0)
		{
			B_ioflow1 = 1;			/* There is signal of flow1 */
			g_statusA = 2;			/* Goto process flux */
		}
	}
	else
	{
		B_ioflow1 = 0;
	}
	
	if (io_flow2 == 1)
	{								/* There is signal of flow2 */
		if (B_ioflow2 == 0)
		{
			B_ioflow2 = 1;
			g_statusA = 2;			/* Goto process flux */
		}
	}
	else
	{
		B_ioflow2 = 0;
	}
	
	if (io_flow1==1 && io_flow2==1)
	{
		/* Magnet disturb */
		 
	}
	
	if (g_statusA==4 && TASTP==1 && B_openvalve==0 && B_closevalve==0)
	{	
		g_statusA = 5;				/* Power down */
	}

	io_fluxcontrol = 0;				/* Forbid detecting flow sensors and card */
}

⌨️ 快捷键说明

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