00001
00002
00003
00004
00005
00006
00007
00026
00027
00028 #include "sys_clock.h"
00029 #include "sys_led.h"
00030 #include "sys_main.h"
00031 #include "rtc_inc.h"
00032 #include "../feature.h"
00033 #include "../MESSAGE/message.h"
00034 #include "../fat/fat.h"
00035 #include "../TIMER/timer.h"
00036 #include "../MENU/menu.h"
00037 #include "../basicboot/bootmode.h"
00038 #include "../UI/ui.h"
00039 #include "../USB/usb.h"
00040 #include "sys_hiddenfeature.h"
00041
00042
00043 static BOOL _cpldTest(void);
00044
00045
00046
00047
00051 USHORT softWdt;
00052 USHORT swWdtEnabled;
00053
00054
00055 #pragma CODE_SECTION(SYS_kickoff, ".sram0_resident")
00059 void SYS_kickoff( void )
00060 {
00061 static BOOL sysStarted = FALSE;
00062
00063 SYS_swWdtReset();
00064 SYS_swWdtEnable();
00065
00066 if(sysStarted == TRUE)
00067 {
00068 SYS_clearBusy();
00069 asm( " IDLE 1");
00070 return;
00071 }
00072
00073
00074 if(FALSE == _cpldTest()) SYS_die(0);
00075
00076 sysStarted = TRUE;
00077
00078
00079
00080 SYS_clockSetup(CLOCK_STARTUP);
00081 SYS_createResidentTask();
00082
00083
00084 TSK_setpri(&TSK_sys, 6);
00085
00086 TSK_setpri(TSK_lcd, 3);
00087
00088
00089 TSK_setpri(TSK_uichild, 4);
00090 TSK_setpri(TSK_ui, 4);
00091 TSK_setpri(TSK_uiparent, 4);
00092
00093
00094 TSK_setpri(TSK_kbd, 5);
00095
00096
00097 TSK_disable();
00098
00099
00100 *(int*) 0xFFFE = ~MW_LAUNCH;
00101
00102
00103 if( SYS_gotoDiagnosis() == TRUE )
00104 {
00105
00106 SYS_diagnosisMode();
00107 SYS_notNormalPowerup();
00108
00109 mMSG_send(sysMsgQ, SYS_MSG_ID, SINITSTATUSBAR, DONTCARE, SYS_FOREVER);
00110 UI_menuBrowse(SDIAGNOSIS, DONTCARE, MENU_DIAGNOSIS);
00111 }
00112 else if( (KBD_isKeyDown(KLOCK) == TRUE) && (FALSE == USB_isCablePlugged()) )
00113
00114
00115
00116 {
00117
00118 SYS_batteryAnimation();
00119
00120
00121 mMSG_send(sysMsgQ, SYS_MSG_ID, SFORCEOFF, DONTCARE, SYS_FOREVER);
00122 }
00123 else
00124 {
00125
00126 SYS_notDiagnosisMode();
00127 mMSG_send(sysMsgQ, SYS_MSG_ID, SINITSTATUSBAR, DONTCARE, SYS_FOREVER);
00128 UI_menuBrowse(SENDOFMENU, DONTCARE, MENU_MAIN);
00129
00130
00131
00132
00133
00134
00135 if(*(int *)0xFFFF == PWR_HHISI)
00136 {
00137 SYS_hisiPowerup();
00138 }
00139 else
00140 {
00141 SYS_normalPowerup();
00142 }
00143
00144
00145 mMSG_send(uiMsgQ, SYS_MSG_ID, SPOWERUP, DONTCARE, SYS_FOREVER);
00146 }
00147
00148 SYS_kbdEnabled();
00149 TSK_enable();
00150
00151
00152
00153
00154 if (!(SYS_isPowerPlugged()) ||
00155 ( SYS_isPowerPlugged() && (sysParam.x_backlight == XTRA_OFF)))
00156 SYS_onOffLEDs(HISI_LED, LED_OFF);
00157 SYS_HF_batteryEnable();
00158 }
00159
00160 #pragma CODE_SECTION(_cpldTest, ".sram0_resident")
00161
00162 static BOOL _cpldTest(void)
00163 {
00164 int x, y;
00165
00166 x = *(int *)0xfffe;
00167 y = *(int *)0xffff;
00168 DROM_SWITCH(1);
00169 *(int *)0xfffe = 0x5a5a;
00170 *(int *)0xffff = 0xa5a5;
00171 DROM_SWITCH(0);
00172 *(int *)0xfffe = x;
00173 *(int *)0xffff = y;
00174 DROM_SWITCH(1);
00175 x = ((*(int *)0xfffe==0x5a5a)&&(*(int *)0xffff==0xa5a5))? TRUE:FALSE;
00176 DROM_SWITCH(0);
00177 return x;
00178 }
00179
00180
00181
00182