?? main.c
字號:
/****************************************Copyright (c)**************************************************
** Guangzou ZLG-MCU Development Co.,LTD.
** graduate school
** http://www.zlgmcu.com
**
**--------------File Info-------------------------------------------------------------------------------
** File name: main.c
** Last modified Date: 2004-09-16
** Last Version: 1.0
** Descriptions: The main() function example template
**
**------------------------------------------------------------------------------------------------------
** Created by: Chenmingji
** Created date: 2004-09-16
** Version: 1.0
** Descriptions: The original version
**
**------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
** Version:
** Descriptions:
**
********************************************************************************************************/
#include "config.h"
#define __SRC
#include"main.h"
#undef __SRC
#include "UART0.h"
#include "I2CINT.h"
#include "PCF8563.h"
#include "KEY.h"
#include "LCM.h"
#include "zlg500S_test.h"
#include "zlg500s.h"
#include "zlg500s_comm.h"
#include "delay.h"
#include "gprs.h"
#include "SUM1356.h"
//uint8 yyy;
///////////////////////系統(tǒng)用到的內(nèi)部RAM的全局變量///////////////////////////
////////////////////SUM1356讀卡器的數(shù)據(jù)初始化////////////////////////////////////////
extern uint8 ReadOut_SUM1356_DataBuf[16];
extern uint8 WriteIn_SUM1356_DataBuf[16];
////////////////讀卡器的數(shù)據(jù)////////////////////////////////
extern INT8U DataBfr[16];
extern INT8U Card_Snr[4];
extern INT8U TxMode;
extern INT8U Atq[2];
extern INT8U Sak;
uint8 MI_ProCard_Block4[16]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
uint8 MI_ProCard_Block5[16]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
uint8 MI_ProCard_Block6[16]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
uint8 MI_ProCard_Block8[16]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
uint8 MI_ProCard_Block9[16]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
uint8 MI_ProCard_Block10[16]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
uint8 MI_ProCard_Block12[16]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
uint8 MI_ProCard_Block62[16]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
uint8 DataCardKey[6];//這里是我自己定義的,所以不要加extern
uint32 ui32_testval; //在調(diào)試過程中用來調(diào)試用
////////////////////Main函數(shù)里用到的全局標志量/////////////////////////////
uint8 volatile ui8_FLG_TransMode;
//數(shù)據(jù)傳輸?shù)臉酥疚弧.敒?時表示進入數(shù)據(jù)傳輸模式
/////////////////////
uint8 PIN_TEST_BUF[PINWEISHU]={0,0,0,0,0,0};//用來存放密碼值
struct BaoZhiTimeOut BaoZhiTimeOutListVAL[LNMAX];//
//////////////////////以下為外部NVRAM的地址空間分配'///////////////////
#define ADDR_Termilog 0x82000000 //實際使用的地址范圍:0x82000000-0x82000653
#define ADDR_GuiGeListVAL 0x82000700 //實際使用的地址范圍:0x82000700-0x82000713
#define ADDR_RecvIndexListVAL 0x82000720 //實際使用的地址范圍:0x82000720-0x82000977
#define ADDR_AdminHisVAL 0x82000980 //實際使用的地址范圍:0x82000980-0x82000a1f
#define ADDR_MachHisVAL 0x82000a30 //實際使用的地址范圍:0x82000a30-0x82000acf
#define ADDR_DeliHisVAL 0x82000b00 //實際使用的地址范圍:0x82000b00-0x82003fbb
#define ADDR_ui16_Count_AdmiHis 0x82004000 //實際使用的地址范圍:0x82004000-0x82004001
#define ADDR_ui16_Count_DeliHis 0x82004002 //實際使用的地址范圍:0x82004002-0x82004003
#define ADDR_ui16_Count_MachHis 0x82004004 //實際使用的地址范圍:0x82004004-0x82004005
#define ADDR_FLG_AdmiHis_OVERFLOW 0x82004006 //實際使用的地址范圍:0x82004006-0x82004007
#define ADDR_FLG_DeliHis_OVERFLOW 0x82004008 //實際使用的地址范圍:0x82004008-0x82004009
#define ADDR_FLG_MachHis_OVERFLOW 0x8200400a //實際使用的地址范圍:0x8200400a-0x8200400b
struct StructTermilog * pTermilogVAL = (struct StructTermilog *) ADDR_Termilog;
struct GuiGeList * pGuiGeListVAL = (struct GuiGeList *) ADDR_GuiGeListVAL;
struct RecvIndexList * pRecvIndexListVAL = (struct RecvIndexList *) ADDR_RecvIndexListVAL;
struct tagAdminHistoryFormat * pAdminHisVAL = (struct tagAdminHistoryFormat *) ADDR_AdminHisVAL;
struct tagMachineHistoryFormat * pMachHisVAL = (struct tagMachineHistoryFormat *) ADDR_MachHisVAL;
struct tagDeliveryHistoryFormat *pDeliHisVAL = (struct tagDeliveryHistoryFormat *)ADDR_DeliHisVAL;
uint16 * pui16_Count_AdmiHis=(uint16 *)ADDR_ui16_Count_AdmiHis;
uint16 * pui16_Count_DeliHis=(uint16 *)ADDR_ui16_Count_DeliHis;
uint16 * pui16_Count_MachHis=(uint16 *)ADDR_ui16_Count_MachHis;
uint8 * pFLG_AdmiHis_OVERFLOW=(uint8 *)ADDR_FLG_AdmiHis_OVERFLOW;
uint8 * pFLG_DeliHis_OVERFLOW=(uint8 *)ADDR_FLG_DeliHis_OVERFLOW;
uint8 * pFLG_MachHis_OVERFLOW=(uint8 *)ADDR_FLG_MachHis_OVERFLOW;
void system_init(void)
{
int i;
Lcdinit(); //液晶屏初試化
Lcdclear(); //清屏
beep_init(); //蜂鳴器初試花
Init_Flash(); //初始化FLASH
print_init(); //打印機初始化
I2C_Init(400000); //I2C初始化
Init_SUM1356_CheckPIN(); //射頻卡初始化
Time0Init(); //定時器初試化
IRQEnable();
//////////////////////////歡迎詞///////////////////////////////////
wrzw16x16_string(0,1,"上海速致電子科技",8);
for(i = 9; i > 0; i--)
{
delay_500ms();
wryw16x8s(14,3,i);
}
return;
}
#define GPRS_DEBUG
int main (void)
{
//系統(tǒng)初始化
uint32 m_i,m_k,m_j;
Delay_n100MS(20);
#ifdef LCD_DEBUG
lcd_debug();
#endif
#ifdef BEEP_DEBUG
beep_debug();
#endif
#ifdef KEY_DEBUG
key_debug();
#endif
#ifdef FLASH_DEBUG
flash_debug();
#endif
#ifdef TIME_DEBUG
time_debug();
#endif
#ifdef UART0_DEBUG
uart0_debug();
#endif
#ifdef PRINT_DEBUG
print_debug();
#endif
#ifdef SUM1356_DEBUG
sum1356_debug();
#endif
#ifdef GPRS_DEBUG
gprs_debug();
#endif
system_init();
///////////////程序測試////////////////////
// PlaySound_2wei(88);
PCF8563_WrIn_databuf[2] = 0x09; //PCF8583_WrIn_databuf[3]:秒,BIT7為1時數(shù)據(jù)無效,為0時數(shù)據(jù)有效
PCF8563_WrIn_databuf[3] = 0x00; //PCF8583_WrIn_databuf[4]:分
PCF8563_WrIn_databuf[4] = 0x00; //PCF8583_WrIn_databuf[5]:時
PCF8563_WrIn_databuf[5] = 0x01; //PCF8583_WrIn_databuf[6]:日
PCF8563_WrIn_databuf[6] = 0x01; //PCF8583_WrIn_databuf[7]:周
PCF8563_WrIn_databuf[7] = 0x01; //PCF8583_WrIn_databuf[8]:月
PCF8563_WrIn_databuf[8] = 0x00; //PCF8583_WrIn_databuf[9]:年
///////////////////程序全局變量的初始化/////////////////////////////
for(m_i=0;m_i<16;m_i++)
{
MI_ProCard_Block4[m_i]=0;
MI_ProCard_Block5[m_i]=0;
MI_ProCard_Block6[m_i]=0;
MI_ProCard_Block8[m_i]=0;
MI_ProCard_Block9[m_i]=0;
MI_ProCard_Block10[m_i]=0;
MI_ProCard_Block12[m_i]=0;
MI_ProCard_Block62[m_i]=0;
}
for(m_i=0;m_i<LNMAX;m_i++)
{
BaoZhiTimeOutListVAL[m_i].FLG_TimeOut=0;
BaoZhiTimeOutListVAL[m_i].FLG_record=0;
}
for(m_i=0;m_i<PINWEISHU;m_i++)
{
PIN_TEST_BUF[m_i]=0;
}
//主程序的主循環(huán)
/////////////////////////讀卡模塊初始化/////////////////////////////////
/* DisablePCF8563_IIC_INT();//禁止PCF8563的數(shù)據(jù)讀取
ZLG500S_COMM_Init();
Time0Init();
DataCardKey[0] = 0xff;
DataCardKey[1] = 0xff;
DataCardKey[2] = 0xff;
DataCardKey[3] = 0xff;
DataCardKey[4] = 0xff;
DataCardKey[5] = 0xff;
PCDLoadKey(KEYA,0,DataCardKey);
EnablePCF8563_IIC_INT();//使能PCF8563的數(shù)據(jù)讀取
*/
/*
WriteIn_SUM1356_DataBuf[0]='1';
WriteIn_SUM1356_DataBuf[1]='2';
WriteIn_SUM1356_DataBuf[2]='3';
WriteIn_SUM1356_DataBuf[3]='4';
while(1)
{
if(Check_SUM1356_IN_ATAN()==0)//當
{
Search_SUM1356();
Write_SUM1356_Block(WriteIn_SUM1356_DataBuf,4);
if(Read_SUM1356_Block(ReadOut_SUM1356_DataBuf,4))
{
while(1);
}
}
}
*/
while(1)
{
ScanKey();
// if(yyy==KEY_0)
//{
// ScanKey();
// ScanKey();
//}
}
while(1) //主程序循環(huán)體
{
ShowMainPic(); //顯示主界面
ReadAndDisplayTime(); //讀取時間并且顯示
CheckAndDisplayOutTimeIfo(); //檢查超時信息,并進行顯示
DealWithMifareCard();
} //while(1)
return 0;//main
}
void ReadAndDisplayTime(void)
{
ReadTimeFromPCF8563(PCF8563_RdOut_databuf);
Delay_n10MS(1);//延時40毫秒
ChangePCF8563_BCD_to_HEX(PCF8563_RdOut_databuf);
wryw16x8_2wei(0,2,20);
wryw16x8_2wei(2,2,PCF8563_RdOut_databuf[6]);//年
wryw16x8(4,2,"-");
wryw16x8_2wei(5,2,PCF8563_RdOut_databuf[5]);//月
wryw16x8(7,2,"-");
wryw16x8_2wei(8,2,PCF8563_RdOut_databuf[3]);//日
wryw16x8_2wei(0,3,PCF8563_RdOut_databuf[2]);//時
wryw16x8(2,3,":");
wryw16x8_2wei(3,3,PCF8563_RdOut_databuf[1]);//分
wryw16x8(5,3,":");
wryw16x8_2wei(6,3,PCF8563_RdOut_databuf[0]);//秒
}
void CheckAndDisplayOutTimeIfo(void)
{
}
void ShowMainPic(void)
{
wrzw16x16_string(4,0,"已用",2);
wrzw16x16_string(0,0,"過期",2);
//wryw16x8_2wei(12,0,TermilogVAL.StoreProductNum);
wrzw16x16_string(1,1,"請刷卡。。。",6);
}
void DealWithMifareCard(void)
{
while(Check_SUM1356_IN_ATAN()==0)//當檢測到有卡的時候
{//當數(shù)據(jù)傳輸模式為正常工作模式的時候,進行讀卡操作
Search_SUM1356();
Read_SUM1356_Block(DataBfr,1);
if((DataBfr[0]=='W')&&(DataBfr[1]=='L')&&(DataBfr[2]=='Z')&&(DataBfr[3]=='Z'))
{//如果這個卡是有效卡,則進入卡型號的判別模式。
Read_SUM1356_Block(DataBfr,4); //讀塊4
//讀取這個卡的類型是否為管理員,送貨,發(fā)貨卡,標簽卡
if(DataBfr[0]==DELI_CARD)//如果是送貨員卡
{//////////////////送貨員的情況處理////////////////////
uint32 ui32_ID;
uint32 ui32_SXdate; //失效的日期
uint32 ui32_XTdate; //系統(tǒng)當前日期
ui32_ID=
(((uint32)DataBfr[1])*256*256*256)+(DataBfr[2]*256*256)+(DataBfr[3]*256)+DataBfr[4];
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -