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

📄 irstandby.c

📁 M3355的源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
    }
    else
    {
        SET_GPIO_LOW_standby(VFD0);
        SET_GPIO_HI_standby(VFD1);
        if( GET_GPIO_DATA_standby(VFD4) )//30216-01jf
        {
            temp = (*(TDR));//30216-01jf
            *(TDR) = temp |0x02;//30216-01jf
            _key_open_standby=1;//30216-01jf
        }
    }

    if( (_key_power_standby==1) || (_key_pause_standby==1) || (_key_open_standby==1) )
    {
        CurKey=C_KEY_POWER;
        if(LastKey_standby==PNL_KEY_NONE)
        {
            SET_GPIO_HI_standby(VFD1);
            SET_GPIO_LOW_standby(VFD0);
            LastKey_standby=CurKey;
            return CurKey;
        }
        else
        {
            SET_GPIO_HI_standby(VFD1);
            SET_GPIO_LOW_standby(VFD0);
            LastKey_standby=CurKey;
            return C_KEY_0;
        }
    }
    else
    {
        CurKey=PNL_KEY_NONE;
        LastKey_standby=CurKey;
        SET_GPIO_HI_standby(VFD1);
        SET_GPIO_LOW_standby(VFD0);
        return CurKey;
    }

    ///////////////////////////////////////30213jeff    //////////////
#else   ///30213jeff
    key = VfdGetKeys_standby();
    //    key = VfdGetKeys();
    if(key==0xffffffff)
        return PNL_KEY_NONE;
    if (!key)
        return PNL_KEY_NONE;
    else
    {
        if (key==0x01000001)
        {
            temp = (*(TDR));
            *(TDR) = temp |0x02;
            _key_open_standby=1;
        }
        else if (key==0x02000002)
        {
            temp = (*(TDR));//make sure not open
            *(TDR) = temp &0xfd;//make sure not open
            _key_pause_standby=1;
        }
        // else if (key==0x04000004)
        // {
        // 	_key_power_standby=1;
        // }
        if( (_key_pause_standby==1) || (_key_open_standby==1) || (_key_power_standby==1) )
            return C_KEY_POWER;
    }
    //    else
    //        return PnlTransformKey_standby(key);
#endif    ///30213jeff
}

#if (_TA != 301)///30213jeff  30213-11jf
/*----------------------------------------------------------------------
 * Function_Name: VfdGetKeys_standby
 *
 * Description:	
 *
 * Arguments:
 *
 * Return Value: 
 *     DWORD - key-map of 32 keys. (This chip should have 48 keys at most!)
 *----------------------------------------------------------------------*/
DWORD VfdGetKeys_standby()
{
    DWORD dwRet = 0;

    //    VfdHold();
    VfdHold_standby();
    //    SciSetByte(0x42); /* Get Key Command */
    SciSetByte_standby(0x42); /* Get Key Command */
    //    SciDelay(2);/* wait 2 us, need wait 1 us */
    SciDelay_standby(20);/* wait 2 us, need wait 1 us */

    //    BYTE0(dwRet)=SciGetByte();
    //    BYTE1(dwRet)=SciGetByte();
    //    BYTE2(dwRet)=SciGetByte();
    //    BYTE3(dwRet)=SciGetByte();
    BYTE0(dwRet)=SciGetByte_standby();
    BYTE1(dwRet)=SciGetByte_standby();
    BYTE2(dwRet)=SciGetByte_standby();
    BYTE3(dwRet)=SciGetByte_standby();

    //    VfdRelease();
    VfdRelease_standby();
    return dwRet;
}

/*----------------------------------------------------------------------
 * Function_Name: VfdHold_standby
 *
 * Description:	Hold Vfd Chip, pull VFD Strobe hi
 *
 * Arguments:
 *     DWORD* dwBuff - DisplayBuffer to set
 * Return Value: void
 *----------------------------------------------------------------------*/
void VfdHold_standby()
{
    int i;
    //    SET_GPIO_W_standby(SCI_MD | SCI_MC | SCI_VFD);/* SCI_MD,SCI_MC,SCI_VFD write mode */
    SET_GPIO_W_standby(0x00000430);/* SCI_MD,SCI_MC,SCI_VFD write mode */
    //    SET_GPIO_HI_standby(SCI_MD | SCI_MC);/* pull SCI_MD,SCI_MC high */
    SET_GPIO_HI_standby(0x00000030);/* pull SCI_MD,SCI_MC high */
    SET_GPIO_LOW_standby(SCI_VFD);/* pull SCI_VFD low */
    //alert(" ======= VfdHold return =======\n\r\0");
    for (i=0;i<5;i++)
    {}
}




/*----------------------------------------------------------------------
 * Function_Name: SciDelay_standby
 *
 * Description:	Make a short delay for SCI
 *
 * Arguments:
 *     WORD w : delay (M3325 at 108M)
 *
 * Return Value: void
 *----------------------------------------------------------------------*/
void SciDelay_standby(WORD w)
{
    DWORD dw;
    //    DWORD dwCountSize;
    //    dwCountSize=w*COUNTS_PER_MICROSECOND_standby;
    for(dw=0;dw<w;dw++)
        ;
}

/*----------------------------------------------------------------------
 * Function_Name: VfdRelease_standby
 *
 * Description:	Release Vfd Chip, pull VFD Strobe low
 *
 * Arguments:
 *
 * Return Value: void
 *----------------------------------------------------------------------*/
void VfdRelease_standby()
{
    SciDelay_standby(20);/* wait 2 us, need wait 1 us */
    //    SET_GPIO_W_standby(SCI_MD | SCI_MC | SCI_VFD);/* SCI_MD,SCI_MC,SCI_VFD write mode */
    SET_GPIO_W_standby(0x00000430);/* SCI_MD,SCI_MC,SCI_VFD write mode */
    //    SET_GPIO_HI_standby(SCI_MD | SCI_MC | SCI_VFD);/* pull SCI_MD,SCI_MC,SCI_VFD high */
    SET_GPIO_HI_standby(0x00000430);/* pull SCI_MD,SCI_MC,SCI_VFD high */
}

#if 0
/*----------------------------------------------------------------------
 * Function_Name: SciGetByteMF_standby
 *
 * Description:	Get one byte of bData from SCI, MSB first
 *     Stream Format:
 *     MC   \_____/----\
 *     MD   ??DDDDDDDDDD  
 *     width | Ta | Ta |
 *           Ta>400ns
 *
 * Arguments:
 *
 * Return Value: void
 *     byte get from SCI bus
 *----------------------------------------------------------------------*/
BYTE SciGetByteMF_standby()//maybe we can remove this function
{
    BYTE ret;
    BYTE b;

    for(b=0;b<8;b++)
    {
        SET_GPIO_LOW_standby(SCI_MC);/* pull SCI_MC low */
        SET_GPIO_R_standby(SCI_MD);/* SCI_MD read mode */
        ret<<=1;
        SciDelay_standby(20);/* delay 2us */
        SET_GPIO_HI_standby(SCI_MC);/* pull SCI_MC high */
        SciDelay_standby(10);/* delay 1us */
        if(GET_GPIO_DATA_standby(SCI_MD))
            ret|=0x01;/* SCI_MD=1 */
        else
            ret&=0xfe;/* SCI_MD=0 */
        SciDelay_standby(10);/* delay 1us */
    }
    return ret;
}
#endif
/*------------------------------------------------------------------\
|   Function_Name:                                                  |
|       void PnlTransformKey_standby(register DWORD key)                    |
|                                                                   |
|   Description: transform the type of key which got from vfd to K- |
|                EYCODE type                                        |
|                                                                   |
|   Arguments:                                                      |
|           register DWORD  key : key code would be translated      |
|                                                                   |
|   Return Value:                                                   |
|           unsigned long : the effectible key code for UI                |
|                                                                   |
\------------------------------------------------------------------*/
#if 0
unsigned long PnlTransformKey_standby(register DWORD key)
{
    register int    i;

    for (i = 0; i < (sizeof(PnlKeyTrans)/sizeof(unsigned long)-1); i++)
    {
        if (key & 0x00000001)
            return PnlKeyTrans[i];
        key >>= 1;
    }
}

#endif

/*----------------------------------------------------------------------
 * Function_Name: SciGetByte_standby
 *
 * Description:	Get one byte of bData from SCI, LSB First
 *     Stream Format:
 *     MC   \_____/----\
 *     MD   ??DDDDDDDDDD  
 *     width | Ta | Ta |
 *           Ta>400ns
 *
 * Arguments:
 *
 * Return Value: void
 *     byte get from SCI bus
 *----------------------------------------------------------------------*/
BYTE SciGetByte_standby()
{
    BYTE ret;
    BYTE b;

    for(b=0;b<8;b++)
    {
        SET_GPIO_LOW_standby(SCI_MC);/* pull SCI_MC low */
        SET_GPIO_R_standby(SCI_MD);/* SCI_MD read mode */
        ret>>=1;
        SciDelay_standby(20);/* delay 2us */
        SET_GPIO_HI_standby(SCI_MC);/* pull SCI_MC high */
        SciDelay_standby(10);/* delay 1us */
        if(GET_GPIO_DATA_standby(SCI_MD))
            ret|=0x80;/* SCI_MD=1 */
        else
            ret&=0x7f;/* SCI_MD=0 */
        SciDelay_standby(10);/* delay 1us */
    }
    return ret;
}

/*----------------------------------------------------------------------
 * Function_Name: SciSetByte_standby
 *
 * Description:	Set one byte of data to SCI , LSB First
 *     Stream Format:
 *     MC   \_____/----\
 *     MD   ??DDDDDDDDDD  
 *     width | Ta | Ta |
 *           Ta>400ns
 *
 * Arguments:
 *     BYTE bData :DATA to set to SCI
 *
 * Return Value: void
 *----------------------------------------------------------------------*/
void SciSetByte_standby(BYTE bData)
{
    BYTE b;
    for(b=0;b<8;b++)
    {
        SET_GPIO_LOW_standby(SCI_MC);/* pull SCI_MC low */
        SET_GPIO_W_standby(SCI_MD);/* SCI_MD write mode */
        if(bData&0x01)
            SET_GPIO_HI_standby(SCI_MD);/* pull SCI_MD high */
        else
            SET_GPIO_LOW_standby(SCI_MD);/* pull SCI_MD low */
        SciDelay_standby(10);/* delay 1us */
        SET_GPIO_HI_standby(SCI_MC);/*pull SCI_MC high*/
        SciDelay_standby(10);/* delay 1us */
        bData>>=1;
    }
}

#endif

/*----------------------------------------------------------------------
 * Function_Name: Gpio_Opr_standby
 *
 * Description:	some function, included SET_GPIO_W and SET_GPIO_HI ..., will call Gpio_Opr_standby
 *
 * Arguments:
 *     
 * Return Value: void
 *----------------------------------------------------------------------*/
DWORD Gpio_Opr_standby(BYTE operate,DWORD dwPorts)
{
    //	DWORD	readGPIORW_standby_value;
    //	DWORD	readGPIODAT_standby_value;
    //    readGPIORW_standby_value=(*((volatile unsigned int *)(GPIORW)));
    //    readGPIODAT_standby_value=(*((volatile unsigned int *)(GPIODAT)));
    //    bbb();
    if(operate==SET_READ)
        (writeGPIORW_standby(readGPIORW() & (~(dwPorts)) | 0x80000000));/* set GPIO ports Read Mode */
    else if(operate==SET_WRITE)
    {
        //    	bbb();
        (writeGPIORW_standby(readGPIORW() | (dwPorts) | 0x80000000));/*set GPIO ports Write Mode */
        //        bbb();
    }
    else if(operate==SET_HI)
        (writeGPIODAT_standby(readGPIODAT() & 0x7fffffff | (dwPorts)));/* set GPIO ports to High */
    else if(operate==SET_LOW)
        (writeGPIODAT_standby(readGPIODAT() & 0x7fffffff & (~(dwPorts))));/* set GPIO ports to Low */
    else if(operate==GET_DATA)
        return(readGPIODAT_standby() & (dwPorts));/* get GPIO ports value*/
    //    bbb();
    //EnInt();//replaced by assembly code belowed
}
#else
#include <comsub.h>
BOOL flag_UserSetKey_standby   = 0;	//30216-01jf
#endif

⌨️ 快捷键说明

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