main.c
上传用户:shyuanyi
上传日期:2008-05-24
资源大小:69k
文件大小:4k
- /*************************************************/
- #include "My_head.h"
- /*************************************************/
- extern char RfModule_Init();
- BYTE idata Equip_CurStatus=0;//正常状态。
- void My_All_Init(void)
- {
- Init_Sound();
- Uart_Init();
- Init_Timer0();
- Init_spi(); //(1)
- Init_LockBell();
- Init_KeyLed();//(2)//init_led();init_key();
- Init_DateIC();//init_IIC();DS1302
- Init_Memory();
- //Init_Rfic(); //rf500init.
- RfModule_Init();
- }
- void Renew_To_AllInit(void) // (内容重置,恢复为初态)
- {
- //my_test_status_flag = TRUE;
- if(GetCurState()!=IDEL_STATUS)//add for discard,by 2004-07-22
- {
- //Init_Rfic(); //rf500init.
- //Init_Sound(); ???
- //UartBuf_Clear();--mustn't.
- }
- Message_Clear();//Init_Message();
- KeyBuf_Clear(0);
- Init_Timer0(); //Stop_All_Timer();enable_timer0();
- Init_Led_Save();
- // Dis_ConMode();
- DisplayClock();
- Dis_Err_Led(FALSE);
- Dis_Con_Led(FALSE);
- Do_DisLed_Flash(0x00,0x00,200);
- Set_TimerEvent(DIS_CLOCKEVENT_Tevent,DIS_CLOCKEVENT_TIME);
- Set_TimerEvent(WAIT_CARD_Tevent,WAIT_CARDCONSUME_TIME);
- SetCurState(IDEL_STATUS);//ActiveState(INIT_STATUS);
- }
- void My_Next_Init(void)
- {
- BYTE ii;
- //Do_Inspect_HardWare();
- ii=Memory_Check();
- Renew_To_AllInit();
- if(ii!=SUCCESS)
- {
- Equip_CurStatus=ii;
- Dis_Err(ii);
- do_buzzer(BUZZER_ALARM);
- Stop_Timer(DIS_CLOCKEVENT_Tevent);//must!
- Set_TimerEvent(DISPLAY_DELAYEVENT_Tevent,DISPLAY_DELAYEVENT_TIME);
- return;
- }
- if((!equip_addr.ntype) ||(!seedcard_info.unit_code[0] && !seedcard_info.unit_code[1] && !seedcard_info.unit_code[2]))
- {
- Equip_CurStatus=NO_INI_EQUIP;
- Dis_Err(Equip_CurStatus);
- do_buzzer(BUZZER_ALARM);
- Stop_Timer(DIS_CLOCKEVENT_Tevent);//must!
- Set_TimerEvent(DISPLAY_DELAYEVENT_Tevent,DISPLAY_DELAYEVENT_TIME);
- return;
- }
- do_buzzer(BUZZER_SUCCESS);
- Sound_Play(SOUND_MAX_INDEX);//WELCOME_INDEX);
- //SendStr("initedr",7);//for test!
- }
- void NoKey_Into_SeedCardInit(void)
- {
- Do_DisLed_Flash(0xff,0x00,25);
- Stop_Timer(WAIT_CARD_Tevent);
- Set_TimerEvent(WAIT_CARD_Tevent,WAIT_CARDCONSUME_TIME);
- Stop_Timer(WAIT_EXIT_Tevent);
- Set_TimerEvent(WAIT_EXIT_Tevent,WAIT_SeedCardInit_TIME);
- SetCurState(MY_TEST_STATUS);
- }
- void main(void)
- {
- MESSAGE message;
- delay_ms(1450);
- My_All_Init();
- /**************************************/
- //for other test...
- /**************************************/
- My_Next_Init();
- Dis_Equip_Code();//Dis_EquipAddr();
- delay_ms(1000);
- NoKey_Into_SeedCardInit();//for test!没有键盘直接进入子卡初始化!
- while(TRUE)
- {
- while(TRUE)
- {
- /*------------------------------------------------*/
- Check_Key_Event(); // (1)
- /*------------------------------------------------*/
- Check_Uart_Event(); // (2)
- /*------------------------------------------------*
- Check_Card_Event(0); // (3)
- /*------------------------------------------------*/
- Check_Timer_Event(); // (4)
- /*------------------------------------------------*/
- while(GetMessage(&message))Do_Process(message);
- /*------------------------------------------------*/
- Check_Power_Event();
- /*------------------------------------------------*
- if(Check_Err_Event())break; // (5)
- /*------------------------------------------------*/
- //My_Test_Event(); // (6)
- /*------------------------------------------------*/
- }
- //for other test...
- My_Next_Init();
- }
- }