📄 init.c
字号:
//-----------------------------------------------------------------------------
// init.c
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
// Includes
//-----------------------------------------------------------------------------
#include <reg52.h>
#include <string.h>
#include "cpu/cpu.h"
#include "main/main.h"
#include "ext/x5045.h"
#include "ext/ds1307.h"
#include "ext/bc7281.h"
#include "rfid/card.h"
#include "misc/misc.h"
#include "misc/general.h"
#include "config/config.h"
//------------------------------------------------------------------------------------
// Initial Routine
//------------------------------------------------------------------------------------
void Initial (void)
{
cpu_LED_On;
Relay_CLK = HIGH;
LowLimit_LED = OFF;
Door_Check = OFF;
spi_CS = HIGH;
spi_SO = HIGH;
spi_CLK = LOW;
spi_SI = LOW;
i2c_SDA = HIGH;
i2c_SCL = HIGH;
Uart0_Rxd = HIGH;
Uart0_Txd = HIGH;
Uart1_Rxd = HIGH;
Uart1_Txd = HIGH;
bc7281_CLK = HIGH;
bc7281_DATA = HIGH;
Speaker_OUT = QUIET;
bFlag = CLEAR;
bFlagB = CLEAR;
f.Disp_nShift = CLEAR;
#if INITIAL_DELAY
Delay ( INITIAL_DELAY );
#endif
if (!( bMem = x5045_Is_Busy ()))
{
x5045_Write_Enable ();
x5045_Write_Status ();
#if INITIAL_REMAIN
r.Remain = INITIAL_REMAIN;
x5045_Write ( stRemain_memAddr + sizeof( r.Total ), (char*) &r.Remain, sizeof( r.Remain ));
#endif
}
x5045_Read ( stRemain_memAddr, (char *) &r, sizeof( STRemain ));
bFlag = r.Flag;
if ( r.Remain & isDUE ) bDue = TRUE;
r.Factor = ( 0xFF000000 & r.LowLimit ) >> 24;
r.Total = BCD_Hex ( r.Total, 7 );
r.Remain = BCD_Hex ( r.Remain & PAY, 7 );
r.LowLimit = BCD_Hex ( 0x00ffffff & r.LowLimit, 7 );
f.Flow1 = (int) r.Total;
f.Flow = 0;
f.tFee = TFAULT_DEALY;
f.tCheck = 0;
f.tDisp = 0;
x5045_Read ( stFlow_memAddr, (char *) &f, sizeof( STFlow ));
memcpy ( f.City, City_Well, sizeof( City_Well ));
bc7281_Set ();
bc7281_Flash_Digital ( FLASH_OFF );
bc7281_Column1_OnOff ( OFF );
bc7281_Column1_OnOff ( ON );
Delay ( 0x03FFF );
bc7281_Column1_OnOff ( OFF );
#if Display_City_No
bc7281_Display_Dig ( CodeG | Array_Long ( f.City, 3 ), DISP_DELAY1 );
#endif
bRtc = ds1307_Initial ();
#if ds1307_Warn
if ( bRtc == I2C_NACK ) ds1307_Warn_i2c;
#endif
#if Display_YMD
Display_Clock ( 0x04FFF );
#endif
cpu_LED_Off;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -