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

📄 sysmon.c

📁 IT projecotr reference design.
💻 C
📖 第 1 页 / 共 3 页
字号:
            {
                dbmsg_ftrace( DBM_ALWAYS, "Unknown startup state %d\r\n",
                    gpConfiguration -> System.StartupState );
            }

            break;

                        /****************************************************/
                        /* Power keypress detected. Passed to sysmon by GUI */
                        /* when the projector is not in operating mode.     */
                        /*                                                  */
                        /* Initiates a power mode transition dependent on   */
                        /* projector modality.                              */
                        /****************************************************/

        case SYSEVENT_POWERKEY:

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

            switch( powerState )
            {
                case POWERSTATE_RESET:
                   _sysASICPowerUp( TRUE );
                    dbmsg_ftrace( DBM_SYSTEM, "Lowpower mode disabled\r\n" );
                
                    dbmsg_ftrace( DBM_SYSTEM, "Low-power mode change cc = %d\r\n", ccLPMode );
                    dbmsg_ftrace( DBM_SYSTEM, "Memory test cc = %d\r\n", ccMemTest );
                    
                    if( 0 != DDP_Init( DDP_FN_ASIC ))
                    {
                        dbmsg_trace( DBM_ALWAYS, "Can't DDP_Init( DDP_FN_ASIC ) in SYSEVENT_POWERKEY\r\n" );
                        llFault( LLFAULT_SYS_ASIC, FALSE );
                    }

                    fault |= ( EXEC_CC_PASS != _sysStandby());
                    fault |= ( EXEC_CC_PASS != _sysNormalRun());
                    break;

                case POWERSTATE_STANDBY:
                    fault |= ( EXEC_CC_PASS != _sysNormalRun());
                    break;

                case POWERSTATE_ACTIVE:
                    dbmsg_trace( DBM_ALWAYS, "Unexpected power keypress in POWERSTATE_ACTIVE\r\n" );
                    break;

                case POWERSTATE_COOLING:
                    dbmsg_trace( DBM_SYSTEM, "Can't power up until cooldown is complete\r\n" );
                    fault = TRUE;             /* disallows state transition */
                    break;
            }

            if( !fault )
                powerState = POWERSTATE_ACTIVE;

            break;

                        /****************************************************/
                        /* Power-down indication received from GUI.         */
                        /*                                                  */
                        /* Initiates the power-down sequence.               */
                        /****************************************************/

        case SYSEVENT_POWERDOWN:

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

            if( POWERSTATE_ACTIVE == powerState )
            {
               _sysStandby();
                powerState = POWERSTATE_COOLING;
            }

            else
            {
                dbmsg_trace( DBM_ALWAYS, "Power-down unexpected: Not in POWERSTATE_ACTIVE\r\n" );
            }

            break;

                        /****************************************************/
                        /* Indication from an environmental monitor that a  */
                        /* fault requiring a shutdown has occurred.         */
                        /*                                                  */
                        /* Performs the shutdown sequence.                  */
                        /****************************************************/

        case SYSEVENT_FAULT:

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

            if( POWERSTATE_ACTIVE == powerState )
            {
               _sysStandby();
                powerState = POWERSTATE_COOLING;
            }
            
            break;

                        /****************************************************/
                        /* Indication from an environmental monitor that    */
                        /* the projector has cooled down during a normal    */
                        /* power-down sequence.                             */
                        /****************************************************/

        case SYSEVENT_COOL:

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

            if( POWERSTATE_COOLING != powerState )
            {
                dbmsg_trace( DBM_ALWAYS, "Cooldown unexpected: Not in POWERSTATE_COOLING\r\n" );
            }

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

            else if( STARTUP_LOWPOWER == gpConfiguration -> System.StartupState )
            {
                dbmsg_ftrace( DBM_SYSTEM, "Lowpower mode enabled\r\n" );
               _sysASICPowerUp( FALSE );
                powerState = POWERSTATE_RESET;
            }

            break;

                        /****************************************************/
                        /* Indication from the projector control interface  */
                        /* that flash reprogramming is to occur.            */
                        /*                                                  */
                        /* The system monitor task is higher priority than  */
                        /* the projector control task; operation is delayed */
                        /* to allow time for projector control to return    */
                        /* the response for the programming request.        */
                        /*                                                  */
                        /* Performs the power-down sequence if the prjector */
                        /* is operating, then transitions to flash progam   */
                        /* mode.                            .               */
                        /****************************************************/

        case SYSEVENT_PROGMODE:

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

            RTA_TaskDelay( TMR_ConvertMSToTicks( 1000 ));

            if( POWERSTATE_ACTIVE == powerState )
               _sysStandby();

            TMR_SetWatchdog( 0 );            /* ensure watchdog is disabled */
            USB_InitHostConnection();                     /* disconnect USB */
            INT_DisableIRQ( 0xfffffffful );    /* disable system interrupts */
            DDP_SetSoftwareFlag( DDP_SW_FLAG0, TRUE );  /* programming flag */
            INT_DisableARMInterrupts();          /* disable core interrupts */
            DDP_SoftwareReset();                    /* reset to boot loader */

            break;

                        /****************************************************/
                        /* Unknown system event.                            */
                        /****************************************************/

        default:

            dbmsg_trace( DBM_SYSTEM, "sysEvent: Unknown\r\n" );
            break;
    }
}



/****************************************************************************/
/* Return current state.                                                    */
/****************************************************************************/

POWERSTATE_ENUM sysmon_state( void )
{
    return powerState;
}



/****************************************************************************/
/* Set ASIC power.                                                          */
/*  parm:                                                                   */
/*    TRUE; ASIC and related components to full power.                      */
/*   FALSE: ASIC and related components to low power.                       */
/*                                                                          */
/* The result of making the mode transition and memory test is saved to be  */
/* shown in debug output, after debug output has been initialized.          */
/****************************************************************************/

static void _sysASICPowerUp( BOOL state )
{
    if( state )                                              /* if power-up */
    {
                        /****************************************************/
                        /* Initialize test point to show lowpower transition*/
                        /****************************************************/
                        
        TPM_ConfigureSWTestMux(TPM_TP7, TP_XDRAMINIT);
        TPM_SendSWTestMuxSignal(TP_XDRAMINIT, 0);
    
                        /****************************************************/
                        /* The following statement is required for the AXD  */
                        /* target. A transition from low power to normal    */
                        /* power is required to cause the memory controller */
                        /* initialization needed for the fast memory test   */
                        /* to be successfully executed.                     */
                        /****************************************************/

        if( !DDP_IsLowPowerEnabled())        /* if not in low-power mode... */
            DDP_EnableLowPowerMode( TRUE );        /* ...set low-power mode */

                        /****************************************************/
                        /* ASIC to normal power mode.                       */
                        /****************************************************/

        TPM_SendSWTestMuxSignal(TP_XDRAMINIT, 1);
        
        ccLPMode  = DDP_EnableLowPowerMode( FALSE );
        
        DDP_CLKGEN_SetSSCforDMD( DDP_CLKGEN_DMD_SSC_1_5_PER );
        DDP_CLKGEN_EnableSSCforDMD( gpConfiguration -> System.SSEnable ); 
        DDP_CLKGEN_EnableSSCforXDRAM( gpConfiguration -> System.SSEnable ); 
        
        TPM_SendSWTestMuxSignal(TP_XDRAMINIT, 0);
        
                        /****************************************************/
                        /* Run the fast memory test.                        */
                        /****************************************************/

        ccMemTest = MEM_RunFastMemoryTest( &resultMemTest );
    }
    
    else                                                   /* if power-down */
    {
        DDP_EnableLowPowerMode( TRUE );
    }
}



/****************************************************************************/
/* Execute application power reset or lamp strike reset functions.          */
/*                                                                          */
/* Behavior and completion codes ARE NOT SYMMETRICAL for reset functions,   */
/* thus changes in the functions may require change here.                   */
/*                                                                          */
/* Continue reset operations and application execution on all errors other  */
/* than fatal.                                                              */
/****************************************************************************/

static EXEC_CC_ENUM _sysReset( void )
{
    API_VERSION apiver;

    static I2CINIT eeConfig =              /* EEPROM i2c port configuration */
    {
        I2C_7BIT,                                      /* MasterAddressMode */
        I2C_7BIT,                                       /* SlaveAddressMode */
        15,                                                  /* FilterValue */
        100000,                                            /*  SCLClockRate */
        TRUE                                                   /* IntEnable */

    };

    DDP_GetRevInfo revInfo;                           /* ASIC revision info */

                        /****************************************************/
                        /* Install ARM exception callback functions.        */
                        /****************************************************/

    INT_InstallExceptionCallback( _sysExceptionUndefInstruction, 0 );
    INT_InstallExceptionCallback( _sysExceptionPrefetchAbort,    1 );
    INT_InstallExceptionCallback( _sysExceptionDataAbort,        2 );

                        /****************************************************/
                        /* Initialize i2c ports. This may be overwritten by */
                        /* ASIC DDP_Init.                                   */
                        /****************************************************/

    GPIO_EnableAlternativeFunction( GPIO_I2C1, TRUE );
    I2C_Reset( I2C_PORT0 );
    I2C_Reset( I2C_PORT1 );

    if( PASS != I2C_SetConfig( I2C_PORT0, &eeConfig ))
        llFault( LLFAULT_SYS_I2C, FALSE );

    if( PASS != I2C_SetConfig( I2C_PORT1, &eeConfig ))
        llFault( LLFAULT_SYS_I2C, FALSE );

                        /****************************************************/
                        /* Reset the debug port using a default mask, thus  */
                        /* allowing EEPROM error messages to be shown. At   */
                        /* completion of EEPROM reset, set debug message    */
                        /* mask as defined in EEPROM.                       */
                        /*                                                  */
                        /* Upon completion, show results of operations that */
                        /* were obtained before debug was initialized.      */
                        /****************************************************/

    dbmsg_init();

⌨️ 快捷键说明

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