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

📄 environment.c

📁 IT projecotr reference design.
💻 C
📖 第 1 页 / 共 2 页
字号:
/****************************************************************************/
/*             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.   */
/****************************************************************************/

/****************************************************************************/
/* environment.c                                                            */
/*                                                                          */
/* Environmental monitor.                                                   */
/****************************************************************************/

#include <stdlib.h>

#include "common.h"
#include "ddp.h"
#include "ddp_stat.h"
#include "gpio.h"
#include "lmp.h"
#include "pmd.h"
#include "pwm.h"

#include "global.h"
#include "iox.h"
#include "eeprom.h"
#include "gpioFunction.h"
#include "dbmessage.h"
#include "environment.h"
#include "illumination.h"
#include "datapath.h"
#include "keypad.h"



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

static int32  tiltPWM;                           /* last reported PWM count */
static int16  coolTimer;                                  /* cooldown timer */
static int16  taOffset;                                /* tilt angle offset */
static int16  taThreshold;                          /* tilt angle threshold */
static BOOL   autoTilt = FALSE;   /* automatic tilt angle reporting enabled */
static BOOL   enableEnvPoll;              /* environment polling is enabled */
static BOOL   checkFanLock;                    /* fan lock check is enabled */
static BOOL   checkOverTemp;                   /* overtemp check is enabled */
static BOOL   envFaultReported;    /* environmental fault has been reported */
static uint08 fanLockEnable;                            /* fan lock enables */
static uint08 fanRate;                /* fan speed as percentage duty cycle */
static BOOL   checkLampCWInterlock = FALSE;      /* CW/Lamp Interlock check */



/****************************************************************************/
/* Enable auto-tilt.                                                        */
/*                                                                          */
/* This setting is read from EEPROM at initialization time, then updated by */
/* the GUI at runtime. This is done to avoid reading the EEPROM during each */
/* environment poll.                                                        */
/****************************************************************************/

void   enviro_enableAutoTilt( BOOL enable )
{
    autoTilt = enable;
    tiltPWM  = 9999;                        /* out of range, ensures update */
}

/****************************************************************************/
/* Enable Color Wheel/Lamp Interlock check                                  */
/*                                                                          */
/* If enabled, this check will allow the environmental polling loop to      */
/* turn off the lamp if the color wheel is not spinning                     */
/****************************************************************************/

void enviro_enableLampCWInterlock( BOOL enable )
{
    checkLampCWInterlock = enable;
}



/****************************************************************************/
/* Module reset function.                                                   */
/****************************************************************************/

EXEC_CC_ENUM enviro_init( void )
{
    int    i;                                         /* temp counter/index */
    BOOL   isParallelFan;                           /* parallel fan control */

                        /****************************************************/
                        /* Detemine if API is handling emergency shutdown.  */
                        /* If not, and if environment polling is disabled,  */
                        /* issue a warning message.                         */
                        /****************************************************/

    if( gpConfiguration -> System.EnableASICEmergencyShutdown )
    {
        DDP_EnableEmergencyShutdown(TRUE);
    }

    else if( !gpConfiguration -> Environment.EnableEnvironmentPoll )
    {
        dbmsg_trace( DBM_ALWAYS, "\r\n\n*** WARNING ***\r\n\n" );
        dbmsg_trace( DBM_ALWAYS, "  BOTH ASIC EMERGENCY SHUTDOWN AND APPLICATION\r\n" );
        dbmsg_trace( DBM_ALWAYS, "  ENVIRONMENTAL POLLING ARE ARE DISABLED: THE\r\n" );
        dbmsg_trace( DBM_ALWAYS, "  PROJECTOR WILL NOT BE SHUT DOWN IN THE EVENT\r\n" );
        dbmsg_trace( DBM_ALWAYS, "  OF A FAILURE OR OVERTEMPERATURE CONDITION.\r\n\n" );
        dbmsg_trace( DBM_ALWAYS, "*** WARNING ***\r\n\n" );
    }
                        /****************************************************/
                        /* Configure fan rotor lock input and PWM speed     */
                        /* output.                                          */
                        /****************************************************/

    isParallelFan = /* determine if fan2 and fan3 in parallel configuration */
        ( 0x08 == ( 0x08 & gpConfiguration -> Environment.InstalledFans ));

    PMD_FAN_SetParallelCfg( isParallelFan, 0 );        /* set configuration */

    fanLockEnable = gpConfiguration -> Environment.InstalledFanLocks;

    for( i = 0; i < MAXFAN; i++ )           /* configure max number of fans */
    {
        if(( 0x01 << i ) & fanLockEnable )
        {
            if( PASS != iox_cfgSet( IOX_PINCFG( IOX_FAN1LOCK + i, IOX_IN, IOX_FALSE )))
                dbmsg_ftrace( DBM_ALWAYS, "Environment:Can't configure fan %d lock pin\r\n", i );
        }
    }

    enviro_fanSetDutyCycle( fanRate = 0 );                      /* fans off */

                        /****************************************************/
                        /* Initialize tilt sensor.                          */
                        /****************************************************/

    EE_GETVAR( UserMachine.Projector.AutoKeystone, autoTilt );

    GPIO_EnableAlternativeFunction( GPIO_PWM_IN_0, TRUE );           /* cfg */
    PWM_SetInCounterSampleRate( PWM_INCOUNT0,  1000000 );           /* rate */
    PWM_EnableInCounter( PWM_INCOUNT0, TRUE );                    /* enable */

    taOffset     = gpConfiguration -> Environment.TiltAngleOffset;
    taThreshold  = gpConfiguration -> Environment.TiltAngleThreshold;

    tiltPWM = 9999;                 /* out of range, ensures initial report */

                        /****************************************************/
                        /* Initialize cooldown timer.                       */
                        /****************************************************/

    coolTimer = 0;

                        /****************************************************/
                        /* Initialize environment polling options.          */
                        /****************************************************/

    enableEnvPoll = gpConfiguration -> Environment.EnableEnvironmentPoll;
    checkFanLock  = gpConfiguration -> Environment.CheckFanLock;
    checkOverTemp = gpConfiguration -> Environment.CheckOvertemp;

                        /****************************************************/
                        /* Initialize fault detection.                      */
                        /****************************************************/

    envFaultReported = FALSE;                     /* no environmental fault */
    keypad_LED( KPLED_LAMP, FALSE );                         /* no overtemp */
    keypad_LED( KPLED_TEMP, FALSE );               /* no projector overtemp */

    return EXEC_CC_PASS;
}



/****************************************************************************/
/* Periodic polling callback function.                                      */
/****************************************************************************/

void showTilt( int32 angle )               /* send tilt angle to debug port */
{
    dbmsg_trace( DBM_ENVIRO, "tilt: " );

    if( angle < 0 )
        dbmsg_trace( DBM_ENVIRO, "-" );

    angle = abs( angle );

    dbmsg_ftrace( DBM_ENVIRO, "%d.%03d\r\n", angle >> 8, ( 1000 * ( angle & 0xff )) >> 8 ) ;
}

/****************************************************************************/

int16 enviro_poll( uint16 tick )
{
    uint32 stat;                                       /* DDP system status */

    uint16 pwmHi;                                   /* X axis tilt hi count */
    uint16 pwmLo;                                   /* X axis tilt lo count */
    int16  offset;                              /* PWM offset from midrange */
    int16  filterOffset;                                 /* filtered offset */
    static int16 priorOffset = 0;                /* prior calculated offset */
    BOOL   lampLit = LMP_IsLampLit();                          /* read once */

                        /****************************************************/
                        /* If lamp is lit, ensure fans are running. Fans    */
                        /* are started in the illumination power-up se-     */
                        /* quence. This test is a backstop to ensure that   */
                        /* fans are indeed running when the lamp is lit.    */
                        /****************************************************/

    if( lampLit && ( 0 == fanRate ))
        enviro_fanSetDutyCycle( FANSPEED );               /* start the fans */

                        /****************************************************/
                        /* Run cooldown timer.                              */
                        /*                                                  */
                        /* Countdown is inhibited if lamp ever remains lit  */
                        /* after cooldown is initiated. Cooldown is started */
                        /* by the illumination power-down sequence. This    */
                        /* test is a backstop to ensure that cooldown will  */
                        /* not complete when the lamp is lit.               */
                        /****************************************************/

    if( coolTimer > 0 )
    {
        if( !lampLit )
            coolTimer--;

⌨️ 快捷键说明

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