power.c
上传用户:shyuanyi
上传日期:2008-05-24
资源大小:69k
文件大小:2k
- #include "my_head.h"
- /*******************************************/
- #define POWER_CK1 P2_3
- #define POWER_CK2 P2_4
- #define CELL_CHARGE_STATUS 0x00
- #define EXTERN_POWER_STATUS 0x01
- #define CELL_ALARM_STATUS 0x02
- #define CELL_POWRER_STATUS 0x03
- static BYTE idata save_power_status=0xFF;
- void Check_Power_Event(void)
- {
- BYTE power=0;
- power |= POWER_CK1;
- power<<=1;
- power |= POWER_CK2;
- if(save_power_status==power)return;
- save_power_status=power;
- switch(power)
- {
- case CELL_CHARGE_STATUS:
- Equip_CurStatus=CELL_CHARGE_CODE;
- break;
- case EXTERN_POWER_STATUS:
- Dis_Cellpower_Led(FALSE); //0-close;1--open.
- do_buzzer(BUZZER_SUCCESS);
- Equip_CurStatus=EXTERN_POWER_CODE;
- break;
- case CELL_ALARM_STATUS:
- Save_My_All_Data(); //must!!!!!
- Equip_CurStatus=CELL_ALARM_CODE;
- Dis_Err(Equip_CurStatus);
- //PostMessage(CELL_ALARM_Event);//for uart...
- //SetCurState(ALARM_STATUS);
- while(TRUE)
- {
- do_buzzer(BUZZER_BUSY);
- delay_ms(1000);
- power = 0;
- power |= POWER_CK1;
- power<<= 1;
- power |= POWER_CK2;
- if(power != CELL_ALARM_STATUS)break;
- }
- break;
- case CELL_POWRER_STATUS:
- Equip_CurStatus=CELL_POWRER_CODE;
- Dis_Cellpower_Led(TRUE); //0-close;1--open.
- break;
- default: break;
- }
- Dis_Err(Equip_CurStatus);
- Stop_Timer(DISPLAY_DELAYEVENT_Tevent);//msut!!
- Set_TimerEvent(DISPLAY_DELAYEVENT_Tevent,DISPLAY_DELAYEVENT_TIME);
- //Do_DisLed_Flash(0x00,0x00,200);
- //Set_TimerEvent(WAIT_CARD_Tevent,WAIT_CARDCONSUME_TIME);//(1)
- //SetCurState(IDEL_STATUS);//ActiveState(INIT_STATUS);
- do_buzzer(BUZZER_SUCCESS);
- }