⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sysmon.c

📁 IT projecotr reference design.
💻 C
📖 第 1 页 / 共 3 页
字号:
/****************************************************************************/
/*             TEXAS INSTRUMENTS PROPRIETARY INFORMATION                    */
/*                                                                          */
/*  (c) Copyright, Texas Instruments Incorporated, 2006.                    */
/*      All Rights Reserved.                                                */
/*                                                                          */
/*  Property of Texas Instruments Incorporated. Restricted Rights -         */
/*  Use, duplication, or disclosure is subject to restrictions set          */
/*  forth in TI's program license agreement and associated documentation.   */
/****************************************************************************/

/****************************************************************************/
/* sysmon.c                                                                 */
/*                                                                          */
/* System startup initialization and runtime monitor.                       */
/****************************************************************************/

#include <string.h>

#include "common.h"
#include "ddp2230_rtos_include.h"
#include "flash_table.h"
#include "ddp.h"
#include "gpio.h"
#include "int.h"
#include "tmr.h"
#include "frame.h"
#include "db.h"
#include "pmd.h"
#include "cw.h"
#include "lmp.h"
#include "dmd.h"
#include "seq.h"
#include "tpm.h"
#include "mem.h"
#include "usb.h"
#include "api_ver.h"

#include "main.h"
#include "taskParm.h"
#include "global.h"
#include "sysmon.h"
#include "mailbox.h"
#include "app_Cfg.h"
#include "eeprom.h"
#include "iox.h"
#include "dbmessage.h"
#include "pollTask.h"
#include "usbIO.h"
#include "projectorCtl.h"
#include "rfcControl.h"
#include "irRemote.h"
#include "guiApp.h"
#include "datapath.h"
#include "heartbeat.h"
#include "keypad.h"
#include "illumination.h"
#include "watchdog.h"
#include "environment.h"
#include "audio.h"
#include "version.h"
#include "testpoints.h"
#include "refDdcProc.h"



/****************************************************************************/
/* Local data.                                                              */
/****************************************************************************/

static uint32          sysTaskID;                                /* task ID */
static uint32          sysMbxID;                              /* mailbox ID */
static POWERSTATE_ENUM powerState;                           /* power state */
static const char      sysTaskName[] = "sysmonTask";



/****************************************************************************/
/* Local functions.                                                         */
/****************************************************************************/

static void         _sysASICPowerUp( BOOL state );
static void         _sysCallback( uint16 msgID, uint32 parm, uint32 parm2 );
static void         _sysEvent( SYSEVENT_ENUM event );
static EXEC_CC_ENUM _sysNormalRun( void );
static EXEC_CC_ENUM _sysReset( void );
static EXEC_CC_ENUM _sysStandby( void );
static BOOL         _sysSetCfgAddr( void );

static void _sysException( char *eType, uint08 faultCode );
static void _sysExceptionDataAbort( void );
static void _sysExceptionPrefetchAbort( void );
static void _sysExceptionUndefInstruction( void );

int08 ccLPMode;           /* saved completion code of low-power mode change */
int08 ccMemTest;               /* saved completion code of fast memory test */

MEM_TEST_RESULTS resultMemTest;         /* saved result of fast memory test */



/****************************************************************************/
/* Return task information.                                                 */
/****************************************************************************/

void sysmon_info( TASKINFO_STRUCT *info )
{
    info -> taskID    = sysTaskID;
    info -> stackSize = STACK_SYSMON;
    info -> taskName  = sysTaskName;
}



/****************************************************************************/
/* System startup and monitor task.                                         */
/****************************************************************************/

void sysmonTask( void )
{
    MBM_CC cc;                           /* mailbox message completion code */

                        /****************************************************/
                        /* Complete the low-level startup.                  */
                        /****************************************************/

    sysTaskID = RTA_TaskGetCurrentTaskID();            /* save this task ID */

    INT_EnableARMInterrupts();                     /* Enable ARM interrupts */

    if( PASS != MEM_Init())                  /* initialize memory subsystem */
        llFault( LLFAULT_MAIN_MEMINIT, TRUE );

    if( !_sysSetCfgAddr())            /* set global config address pointers */
        llFault( LLFAULT_SYS_CONFIG, FALSE );

                        /****************************************************/
                        /* Bring ASIC up to full power and initialize XDRAM */
                        /****************************************************/

   _sysASICPowerUp( TRUE );

                        /****************************************************/
                        /* Create task mailbox.                             */
                        /****************************************************/

    if( RTA_SUCCESS != RTA_MbxCreate( &sysMbxID, "sysm", 0, 0, 4, 0 ))
        llFault( LLFAULT_SYS_INIT, FALSE );

                        /****************************************************/
                        /* Application reset/initialization.                */
                        /****************************************************/

   _sysReset();

    if( !watchdog_enable( TRUE ))                         /* start watchdog */
        dbmsg_trace( DBM_ALWAYS, "Can't start watchdog timer\r\n" );

                        /****************************************************/
                        /* Initialization complete, begin monitor.          */
                        /****************************************************/

    powerState = POWERSTATE_RESET;
   _sysEvent( SYSEVENT_START );

    RTA_TaskSetPriority( sysTaskID, PRIORITY_SYSMON );

    for(;;)
    {
        if( MBM_PASS != ( cc = mbRecv( sysMbxID, 0, _sysCallback )))
            dbmsg_ftrace( DBM_ALWAYS, "ccode %d receiving system monitor message\r\n", cc );
    }
}



/****************************************************************************/
/* System event notifications.                                              */
/****************************************************************************/

void sysmon_powerdown( void )                /* inform system of power down */
{
   _sysEvent( SYSEVENT_POWERDOWN );
}

void sysmon_powerkey( void )            /* inform system of power key press */
{
   _sysEvent( SYSEVENT_POWERKEY );
}

void sysmon_fault( void )              /* inform system of a shutdown fault */
{
   _sysEvent( SYSEVENT_FAULT );
}

void sysmon_cooldown( void )        /* inform system of cooldown completion */
{
   _sysEvent( SYSEVENT_COOL );
}

void sysmon_progmode( void )       /* inform system to set programming mode */
{
   _sysEvent( SYSEVENT_PROGMODE );
}




/****************************************************************************/
/* System event posting.                                                    */
/****************************************************************************/

static void _sysEvent( SYSEVENT_ENUM event )
{
    MBM_CC cc;                                           /* completion code */

    if( MBM_PASS != ( cc = mbSend( sysMbxID, (uint16)event, -1, 0, FALSE, 0 )))
        dbmsg_ftrace( DBM_ALWAYS, "ccode %d posting event %d to system monitor\r\n",
            cc, event );
}



/****************************************************************************/
/* System event callback.                                                   */
/*                                                                          */
/* Activity depends on StartupState defined in the app configuration:       */
/*                                                                          */
/*  powerMode = 0 (NORMAL)                                                  */
/*      At reset, initialize the projector transition to normal operating   */
/*      mode (all systems functional).                                      */
/*                                                                          */
/*  powerMode = 1 (STANDBY)                                                 */
/*      At reset,  power up to a point where system are initialized, but no */
/*      source selection is performed and color wheel + lamp remain off.    */
/*      When power key is pressed, transition to normal operating mode.     */
/*                                                                          */
/*  powerMode = 2 (LOWPOWER)                                                */
/*      At reset, power up similar to STANDBY, then reduce power to minimum */
/*      that allows comm and power key detection.                           */
/****************************************************************************/

static void _sysCallback( uint16 msgID, uint32 parm, uint32 parm2 )
{
    BOOL fault = FALSE;   /* assume no error in performing state transition */

    switch( msgID )
    {
                        /****************************************************/
                        /* State machine startup. Called after system reset */
                        /* at which time all modules are in a standby state */
                        /* and the ASIC is in full power mode.              */
                        /*                                                  */
                        /* If the callback is due to a lamp strike reset or */
                        /* if the startup state is STARTUP_NORMAL, set the  */
                        /* projector to the operating mode and the power    */
                        /* state to POWERSTATE_ACTIVE.                      */
                        /*                                                  */
                        /* If the startup state is STARTUP_STANDBY, set the */
                        /* power state to POWERSTATE_STANDBY and wait for   */
                        /* a power key to be pressed.                       */
                        /*                                                  */
                        /* If the startup state is STARTUP_LOWPOWER, power  */
                        /* down as much of the projector as possible, set   */
                        /* the power state to POWERSTATE_RESET and wait for */
                        /* a power key to be pressed.                       */
                        /****************************************************/

        case SYSEVENT_START:

            dbmsg_trace( DBM_SYSTEM, "sysEvent: SYSEVENT_START\r\n" );

            if( POWERSTATE_RESET != powerState )          /* validate state */
            {
                dbmsg_trace( DBM_ALWAYS, "Invalid state for SYSEVENT_START\r\n" );
            }

            else if(( illum_isLampStrikeReset() ) ||
                    ( STARTUP_NORMAL == gpConfiguration -> System.StartupState ))
            {
                if( EXEC_CC_PASS == _sysNormalRun())
                {
                    powerState = POWERSTATE_ACTIVE;
                }

                else
                {
                    dbmsg_trace( DBM_ALWAYS, "Can't start projection\r\n" );
                }
            }

            else if( STARTUP_STANDBY == gpConfiguration -> System.StartupState )
            {
               _sysStandby();
                powerState = POWERSTATE_STANDBY;
            }

            else if( STARTUP_LOWPOWER == gpConfiguration -> System.StartupState )
            {
               _sysASICPowerUp( FALSE );

                powerState = POWERSTATE_RESET;
                dbmsg_ftrace( DBM_SYSTEM, "Lowpower mode enabled\r\n" );
            }

            else

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -