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

📄 environment.c

📁 IT projecotr reference design.
💻 C
📖 第 1 页 / 共 2 页
字号:

        if( 0 == coolTimer )
        {
            dbmsg_trace( DBM_ENVIRO, "Cooldown is complete\r\n" );
            enviro_fanSetDutyCycle( 0 );               /* stop cooling fans */

            sysmon_cooldown();      /* inform system of cooldown completion */
        }
    }
                        /****************************************************/
                        /* Run tilt sensing, if enabled.                    */
                        /* - Calculate offset count from midrange.          */
                        /* - Average prior and current offset count.        */
                        /* - Apply hysteresis.                              */
                        /* - If past hysteresis bounds, report value in     */
                        /*   s7.8 fixed-point format.                       */
                        /* - Offset to angle conversion is a linear approx- */
                        /*   imation.                                       */
                        /****************************************************/

    if( autoTilt )
    {
        PWM_GetInCounterPW( PWM_INCOUNT0, &pwmLo, &pwmHi );

        offset   = (int16)( pwmHi - (( pwmHi + pwmLo ) >> 1 ));   /* offset */
        offset  += taOffset;                           /* calibrated offset */

        filterOffset = ( offset + priorOffset ) >> 1;   /* average readings */
        priorOffset  = offset;                     /* current becomes prior */

        if( abs( filterOffset - tiltPWM ) >= taThreshold )    /* hysteresis */
        {
            tiltPWM = filterOffset;                /* update reported value */
            showTilt(( tiltPWM << 8 ) / 21 );         /* show updated value */
            datapath_UserSetKeystoneAnglePitch(( tiltPWM << 8 ) / 21 );
        }
    }

                        /****************************************************/
                        /* Run environment monitor, if enabled.             */
                        /****************************************************/

    if( enableEnvPoll )
    {
                        /****************************************************/
                        /* If lamp is lit, verify that color wheel is in    */
                        /* motion.                                          */
                        /****************************************************/

        if( lampLit && checkLampCWInterlock )
        {
            stat = DDP_GetSystemStatus();

            if( !( DDP_ST_CW_SPINNING & stat ))
            {
                dbmsg_trace( DBM_ALWAYS, "Environment: Color wheel stopped with lamp lit\r\n" );
                sysmon_fault();                    /* inform system monitor */
            }
        }
                        /****************************************************/
                        /* Verify operation of DAD1000.                     */
                        /****************************************************/

        stat = DDP_GetErrorStatus();

        if( 0 != ( stat & ( DDP_ST_DAD_THERM_FLT | DDP_ST_DAD_VOLT_FLT )))
        {
            dbmsg_trace( DBM_ALWAYS, "Environment: DAD1000 voltage/thermal fault\r\n" );
            keypad_LED( KPLED_TEMP, TRUE );             /* light keypad LED */
            sysmon_fault();                        /* inform system monitor */
        }
                        /****************************************************/
                        /* Other faults.                                    */
                        /****************************************************/

        if( lampLit && checkFanLock )
        {
            if(( !envFaultReported ) && enviro_fanCheckRotorLock())
            {
                dbmsg_trace( DBM_ALWAYS, "Environment: Fan rotor lock\r\n" );
                envFaultReported = TRUE;                  /* fan rotor lock */
                sysmon_fault();                    /* inform system monitor */
            }
        }

        if( checkOverTemp )
        {
            if(( !envFaultReported ) && illum_lampOvertemp())
            {
                keypad_LED( KPLED_LAMP, TRUE );         /* light keypad LED */
                dbmsg_trace( DBM_ALWAYS, "Environment: ballast/lamp over temp limit\r\n" );
                envFaultReported = TRUE;           /* lamp/ballast overtemp */
                sysmon_fault();                    /* inform system monitor */
            }
        }
    }

    return ENVIRONMENT_PERIOD / RTOS_MS_PER_TICK;
}



/****************************************************************************/
/* Return TRUE if any fan rotor is locked.                                  */
/*                                                                          */
/* Also returns TRUE if an invalid or fanNo not configured in appConfig is  */
/* requested,                                                               */
/****************************************************************************/

BOOL enviro_fanCheckRotorLock( void )
{
    int  fanNo;                                               /* fan number */
    BOOL isLocked = FALSE;                            /* assume none locked */
    BOOL foo;                                               /* temp boolean */

    for( fanNo = 0; fanNo < MAXFAN; fanNo++ )   /* check max number of fans */
    {
        if(( 0x01 << fanNo ) & fanLockEnable )
        {
            if( IOXCC_PASS != iox_pinGet( IOX_FAN1LOCK + fanNo, &foo ))
                    dbmsg_ftrace( DBM_ENVIRO, "Can't read fanLocked status\r\n", fanNo ) ;
            else
                isLocked = isLocked || foo;
        }
    }

    return isLocked;
}



/****************************************************************************/
/* Returns fanNo rate in percent.                                           */
/*  A value of zero indicates that the fan is off.                          */
/*                                                                          */
/* Returns zero if an invalid or fanNo not configured in appConfig is       */
/* requested,                                                               */
/****************************************************************************/

uint08 enviro_fanGetSpeed( uint08 fanNo )
{
    return fanRate;
}



/****************************************************************************/
/* Sets duty cycle of all fans.                                             */
/*  A value of zero turns off the fans.                                     */
/*                                                                          */
/* Returns TRUE if fans are set, returns FALSE if an API call error.        */
/*                                                                          */
/* The API does not allow a duty cycle of 0 (full off) so the duty cycle is */
/* passed as 1 when the caller requests zero. The API does not allow a duty */
/* cycle of 100 (full on) so values are clipped to 99 before passing to the */
/* API.                                                                     */
/****************************************************************************/

BOOL enviro_fanSetDutyCycle( uint08 dutyCycle )
{
    BOOL   status = TRUE;            /* assume operation will be successful */
    int08  cc;                                           /* completion code */
    uint08 i;                                                 /* fan number */

    for( i = 0; i < MAXFAN; i++ )           /* configure max number of fans */
    {
        if(( 0x01 << i ) & gpConfiguration -> Environment.InstalledFans )
        {
            if( PASS != ( cc = PMD_FAN_SetFrequency( i + 1, SFREQ_100KHZ, 0 )))
            {
                status = FALSE;
                dbmsg_ftrace(DBM_ALWAYS, "Can't set fan %d frequency: cc=%d\r\n", i, cc  );
            }
            
            if( PASS != ( cc = PMD_FAN_SetDutyCycle( i + 1, dutyCycle, 0 )))
            {
                dbmsg_ftrace(DBM_ALWAYS, "Can't set fan %d duty cycle: cc=%d\r\n", i, cc  );
                status = FALSE;
            }
        }
    }

    fanRate = dutyCycle;

    return status;
}



/****************************************************************************/
/* Set normal operation.                                                    */
/****************************************************************************/

EXEC_CC_ENUM enviro_powerNormal( void )
{
    envFaultReported = FALSE;                     /* no environmental fault */
    keypad_LED( KPLED_LAMP, FALSE );                    /* no lamp overtemp */
    keypad_LED( KPLED_TEMP, FALSE );               /* no projector overtemp */
    
    if( enviro_fanSetDutyCycle( FANSPEED ))           /* start cooling fans */
        return EXEC_CC_PASS;
    else
        return EXEC_CC_API;      /* all failures due to API function return */
}



/****************************************************************************/
/* Set standby operation.                                                   */
/****************************************************************************/

EXEC_CC_ENUM enviro_powerStandby( void )
{
    return EXEC_CC_PASS;
}



/****************************************************************************/
/* Start cooldown delay.                                                    */
/****************************************************************************/

void enviro_startCooldown( void )
{
    coolTimer = (int16)gpConfiguration -> Illum.CooldownDelay;   /* seconds */

                        /****************************************************/
                        /* Convert cooldown seconds to polling intervals.   */
                        /****************************************************/

    coolTimer = (int16)( ((int32)coolTimer * 1000 ) / ENVIRONMENT_PERIOD );
}

⌨️ 快捷键说明

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