📄 flux.c
字号:
/************************************************************************/
/* Renesas System Solutions (Beijing) Co., LTD. */
/* All rights reserved. */
/* */
/* File Name : Flux.c */
/* Description : */
/* */
/* Current Version : 1.0 */
/* Designer : Feng Jun */
/* Start Date : 2006-11-6 */
/* Complete Date : 2006-11-22 */
/* */
/* Lastest Version : */
/* Designer : */
/* Start Date : */
/* Complete Date : */
/************************************************************************/
#include "Flux.h"
#include "main.h"
/*************************************************************************
Name: ProcessWholeFlux
Parameters: None
Returns: None
Description: Process a whole flux
*************************************************************************/
void ProcessWholeFlux(void)
{
char readtemp[4];
char fluxtemp;
union byte_2 intdataaddr;
#define intdata intdataaddr.word
#define intlow intdataaddr.byte.low
#define inthigh intdataaddr.byte.high
union byte_2 warndataaddr;
#define warndata warndataaddr.word
#define warnlow warndataaddr.byte.low
#define warnhigh warndataaddr.byte.high
g_statusA = 4; /* Go to DetectFlux */
EEPROMReadNBytes(readtemp, 2, 0x14); /* Read surplus */
inthigh = readtemp[0];
intlow = readtemp[1];
EEPROMReadNBytes(&fluxtemp, 1, 0x01); /* Read status */
fluxtemp &= 0xfc; /* Clear flag of flow */
EEPROMWriteNBytes(0x01, 1, &fluxtemp);
if (intdata == 0)
{ /* Negative */
EEPROMReadNBytes(readtemp, 2, 0x1a);
inthigh = readtemp[0];
intlow = readtemp[1];
intdata++;
readtemp[0] = inthigh;
readtemp[1] = intlow;
EEPROMWriteNBytes(0x1a, 2, readtemp); /* Write overdraft to EEPROM */
if (TASTP==1 && B_openvalve==0 && B_closevalve==0)
{
g_statusA = 5; /* Power down */
}
}
else
{
intdata--;
readtemp[0] = inthigh;
readtemp[1] = intlow;
EEPROMWriteNBytes(0x14, 2, readtemp);
/* Compare with warning data (display) */
EEPROMReadNBytes(readtemp, 4, 0x07); /* Read the value to warning */
warnhigh = readtemp[2]; /* Threshold of colsing valve to warn */
warnlow = readtemp[3];
if (intdata == warndata)
{
B_closevalve = 1; /* To close the valve */
B_dispvalve = 1;
B_timerA3s = 1;
TimerAStart(); /* 3s timer start */
g_statusA = 3;
}
warnhigh = readtemp[0]; /* Threshold of display warning */
warnlow = readtemp[1];
if (intdata <= warndata)
{
B_timerA3s = 1;
B_warning = 1; /* To display '关阀' */
TimerAStart(); /* 3s timer start */
g_statusA = 3;
}
else
{
if (TASTP==1 && B_openvalve==0 && B_closevalve==0)
{
g_statusA = 5; /* Power down */
}
}
if (intdata == 0)
{
B_warning = 1; /* To display '交费' */
B_dispvalve = 1; /* To display '关阀' */
B_closevalve = 1; /* To close the valve */
g_statusA = 3;
}
}
}
/*************************************************************************
Name: ProcessFlux
Parameters: None
Returns: None
Description: Process flux
*************************************************************************/
void ProcessFlux(void)
{
char fluxtemp;
EEPROMReadNBytes(&fluxstatus, 1, 0x01); /* Read status */
fluxstatus = fluxstatus & 0x03;
if (iofluxstatus != fluxstatus)
{ /* Not same */
fluxstatus |= iofluxstatus;
if (fluxstatus == 3 )
{ /* A whole flux */
ProcessWholeFlux();
}
else
{
EEPROMReadNBytes(&fluxtemp, 1, 0x01); /* Read status */
fluxstatus |= fluxtemp;
EEPROMWriteNBytes(0x01, 1, &fluxstatus);
if (TASTP == 0 || B_openvalve==1 || B_closevalve==1)
{ /* 3s timer started */
g_statusA = 4;
}
else
{
g_statusA = 5; /* Power down */
}
}
}
else
{
if (TASTP==0 || B_openvalve==1 || B_closevalve==1)
{ /* 3s timer started */
g_statusA = 4;
}
else
{ /* Power down */
g_statusA = 5;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -