SYS_kickoff.c

Go to the documentation of this file.
00001 /*****************************************************************************
00002                            C   M O D U L E   F I L E
00003 
00004     Copyright (c) 2003 Neuros Audio LLC, All rights reserved.
00005 
00006 ******************************************************************************/
00007 
00026 
00027 /*-- HEADER FILE INCLUDES ---------------------------------------------------*/
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 /*-- LOCAL DEFINITIONS ------------------------------------------------------*/
00043 static BOOL _cpldTest(void);
00044 
00045 /*-- STATIC DATA ------------------------------------------------------------*/
00046 
00047 /*-- GLOBAL DATA ------------------------------------------------------------*/
00051 USHORT softWdt;
00052 USHORT swWdtEnabled;
00053 
00054 /*-- FUNCTIONS --------------------------------------------------------------*/
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     // Test hardware compatibility.
00074     if(FALSE == _cpldTest()) SYS_die(0);
00075     
00076     sysStarted = TRUE;
00077 
00078     // Kicks off the system, run system at full speed to minimize the
00079     // startup time. 
00080     SYS_clockSetup(CLOCK_STARTUP);
00081     SYS_createResidentTask();
00082         
00083     // Run task to initialize message system.
00084     TSK_setpri(&TSK_sys, 6);
00085     // Run task to initialize LCD.
00086     TSK_setpri(TSK_lcd, 3);
00087     
00088     // Initiate UI.
00089     TSK_setpri(TSK_uichild, 4);
00090     TSK_setpri(TSK_ui, 4);      
00091     TSK_setpri(TSK_uiparent, 4);
00092     
00093     // Enable keyboard.
00094     TSK_setpri(TSK_kbd, 5);
00095 
00096     // Wait till system setup is done.
00097     TSK_disable(); 
00098     
00099     // Break the magic work auto-launch.
00100     *(int*) 0xFFFE = ~MW_LAUNCH;    
00101     
00102     // Diagnosis mode detection.
00103     if( SYS_gotoDiagnosis() == TRUE )
00104     {
00105         // Power system up to diagnosis mode. 
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 //DeepB
00114 // Disable USB Cable detection
00115 //    else if( (KBD_isKeyDown(KLOCK) == TRUE) )   
00116     {
00117         // Tell system to do the charge animation.
00118         SYS_batteryAnimation();
00119             
00120         // Power system down immediately.
00121         mMSG_send(sysMsgQ, SYS_MSG_ID, SFORCEOFF, DONTCARE, SYS_FOREVER);
00122     }
00123     else
00124     {        
00125         // Power system up normally. 
00126         SYS_notDiagnosisMode();
00127         mMSG_send(sysMsgQ, SYS_MSG_ID, SINITSTATUSBAR, DONTCARE, SYS_FOREVER);
00128         UI_menuBrowse(SENDOFMENU, DONTCARE, MENU_MAIN);
00129 
00130         // Enable battery monitor.
00131         //TSK_setpri(TSK_battery, 4);
00132     
00133         // Check flag that is set by bootloader to start
00134         // HiSi or alarm recording.
00135         if(*(int *)0xFFFF == PWR_HHISI) 
00136         {
00137             SYS_hisiPowerup();
00138         }
00139         else
00140         {
00141             SYS_normalPowerup();
00142         }   
00143         
00144         // Power up the disk system.
00145         mMSG_send(uiMsgQ, SYS_MSG_ID, SPOWERUP, DONTCARE, SYS_FOREVER); 
00146     }     
00147       
00148     SYS_kbdEnabled();
00149     TSK_enable();
00150 //DeepB
00151 // Apagar luces cuando:
00152 // El transformador no está conectado o
00153 // El transformador está conectado y no queremos luces
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 // Function tests to see if Neuros has latest CPLD code.
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                 Neuros Audio LLC. Confidential Proprietary
00182  *****************************************************************************/

Generated on Wed Jan 19 01:12:44 2005 for neuros-firmware by  doxygen 1.3.9.1