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

📄 scaler.c

📁 车载 液晶显示器的主控程序(主要使用芯片为 MYSON MTV512 单片机、RealTek 2323 Scare 芯片、TVP5147(视频解码)。配Sharp 8寸液晶显示器 )。
💻 C
📖 第 1 页 / 共 2 页
字号:
    SETSCALERSDIO0((bit)(ucValue & 0x01));
    SETSCALERSDIO1((bit)(ucValue & 0x02));
    SETSCALERSDIO2((bit)(ucValue & 0x04));
    SETSCALERSDIO3((bit)(ucValue & 0x08));
    SETSCALERSCLK();

    SETSCALERSDIO0((bit)(ucValue & 0x10));
    SETSCALERSDIO1((bit)(ucValue & 0x20));
    SETSCALERSDIO2((bit)(ucValue & 0x40));
    SETSCALERSDIO3((bit)(ucValue & 0x80));
    CLRSCALERSCLK();

#elif(_HOST_INTERFACE == _SERIAL_PORT)

    SETSCALERSDIO3((bit)(ucValue & 0x01));
        CLRSCALERSCLK();
    SETSCALERSDIO3((bit)(ucValue & 0x02));
    SETSCALERSCLK();
    SETSCALERSDIO3((bit)(ucValue & 0x04));
    CLRSCALERSCLK();
    SETSCALERSDIO3((bit)(ucValue & 0x08));
    SETSCALERSCLK();
    SETSCALERSDIO3((bit)(ucValue & 0x10));
    CLRSCALERSCLK();
    SETSCALERSDIO3((bit)(ucValue & 0x20));
    SETSCALERSCLK();
    SETSCALERSDIO3((bit)(ucValue & 0x40));
    CLRSCALERSCLK();
    SETSCALERSDIO3((bit)(ucValue & 0x80));
        SETSCALERSCLK();

#endif
}

BYTE CScalerGetByte(void)
{
#if(_HOST_INTERFACE == _PARALLEL_PORT)

    BYTE value = 0;

    SETSCALERSCLK();
    if(GETSCALERSDIO0())
        value   |= 0x01;
    if(GETSCALERSDIO1())
        value   |= 0x02;
    if(GETSCALERSDIO2())
        value   |= 0x04;
    if(GETSCALERSDIO3())
        value   |= 0x08;
    CLRSCALERSCLK();
    if(GETSCALERSDIO0())
        value   |= 0x10;
    if(GETSCALERSDIO1())
        value   |= 0x20;
    if(GETSCALERSDIO2())
        value   |= 0x40;
    if(GETSCALERSDIO3())
        value   |= 0x80;

#elif(_HOST_INTERFACE == _SERIAL_PORT)

    BYTE value = 0;

        CLRSCALERSCLK();
    if(GETSCALERSDIO3())
        value   |= 0x01;
        SETSCALERSCLK();
    if(GETSCALERSDIO3())
        value   |= 0x02;
    CLRSCALERSCLK();
    if(GETSCALERSDIO3())
        value   |= 0x04;
    SETSCALERSCLK();
    if(GETSCALERSDIO3())
        value   |= 0x08;
    CLRSCALERSCLK();
    if(GETSCALERSDIO3())
        value   |= 0x10;
    SETSCALERSCLK();
    if(GETSCALERSDIO3())
        value   |= 0x20;
    CLRSCALERSCLK();
    if(GETSCALERSDIO3())
        value   |= 0x40;
    SETSCALERSCLK();
    if(GETSCALERSDIO3())
        value   |= 0x80;

#endif

    return value;
}

//--------------------------------------------------
// Description  : Write a data array into registers of scaler
// Input Value  : ucAddr    --> Start address of register
//                ucLength  --> Numbers of data we want to write
//                pArray    --> Pointer of the writing data array
//                bAutoInc  --> Address auto increasing select
// Output Value : None
//--------------------------------------------------
void CScalerWrite(BYTE ucAddr, WORD usLength, BYTE *pArray, bit bAutoInc)
{
    if(usLength > 0)
    {
        CScalerSendAddr(ucAddr, _WRITE, bAutoInc);

        do
        {
            CScalerSendByte(*pArray++);

        }while(--usLength);

        CScalerSendWriteStop();
    }
}

//--------------------------------------------------
// Description  : Read data from registers of scaler and put it into an reading data array
// Input Value  : ucAddr    --> Start address of register
//                ucLength  --> Numbers of data we want to read
//                pArray    --> Pointer of the reading data array
//                bAutoInc  --> Address auto increasing select
// Output Value : None
//--------------------------------------------------
void CScalerRead(BYTE ucAddr, BYTE ucLength, BYTE *pArray, bit bAutoInc)
{
    if(ucLength > 0)
    {
        CScalerSendAddr(ucAddr, _READ, bAutoInc);

        do
        {
            *pArray++ = CScalerGetByte();

        }while(--ucLength);

        CScalerSendReadStop();
    }
}

//--------------------------------------------------
// Description  : Write a data array into registers of scaler
// Input Value  : ucAddr    --> Start address of register
//                ucLength  --> Numbers of data we want to write
//                pValue    --> Value we want to write
//                bAutoInc  --> Address auto increasing select
// Output Value : None
//--------------------------------------------------
void CScalerWriteAmount(BYTE ucAddr, WORD usLength, BYTE ucValue, bit bAutoInc)
{
    if(usLength > 0)
    {
        CScalerSendAddr(ucAddr, _WRITE, bAutoInc);

        do
        {
            CScalerSendByte(ucValue);

        }while(--usLength);

        CScalerSendWriteStop();
    }
}

//--------------------------------------------------
// Description  : Set the value into selected register
// Input Value  : ucAddr    --> Address of register
//                ucValue   --> Value we want to set
// Output Value : None
//--------------------------------------------------
void CScalerSetByte(BYTE ucAddr, BYTE ucValue)
{
    CScalerWrite(ucAddr, 1, &ucValue, _AUTOINC);
}

//--------------------------------------------------
// Description  : Set some bits of selected register
// Input Value  : ucAddr    --> Address of register
//                ucAnd     --> & operation
//                ucOr      --> | operation
// Output Value : None
//--------------------------------------------------
void CScalerSetBit(BYTE ucAddr, BYTE ucAnd, BYTE ucOr)
{
    BYTE value;

    CScalerRead(ucAddr, 1, &value, _AUTOINC);

    value   = (value & ucAnd) | ucOr;

    CScalerWrite(ucAddr, 1, &value, _AUTOINC);
}

//--------------------------------------------------
// Description  : Get bits from selected register
// Input Value  : ucAddr    --> Address of register
//                ucAnd     --> & operation
// Output Value : Value after & operation
//--------------------------------------------------
BYTE CScalerGetBit(BYTE ucAddr, BYTE ucAnd)
{
    BYTE value;

    CScalerRead(ucAddr, 1, &value, _AUTOINC);

    return (value & ucAnd);
}

//--------------------------------------------------
// Description  : Write a table into scaler
// Input Value  : pArray    --> Selected table which contains numbers, address auto increasing information, address of registers and values
// Output Value : None
//--------------------------------------------------
void CScalerCodeW(BYTE code *pArray)
{
    BYTE length;

    do
    {
        if((*pArray & 0xfc) == 0)
            return;

        length  = *pArray - 3;

        if((*(pArray + 1)) == _BURST)
        {
            CScalerSendAddr(*(pArray + 2), _WRITE, _NON_AUTOINC);

            pArray += 3;
            
            do
            {
                CScalerSendByte(*pArray);

            }while(--length);

            pArray++;
        }
        else if((*(pArray + 1) == _AUTOINC) || (*(pArray + 1) == _NON_AUTOINC))
        {
            CScalerSendAddr(*(pArray + 2), _WRITE, *(pArray + 1));

            pArray += 3;

            do
            {
                CScalerSendByte(*pArray++);

            }while(--length);

        }

        CScalerSendWriteStop();

    }while(_TRUE);
}

//--------------------------------------------------
// Description  : Load OSD font into OSD SRAM
// Input Value  : pArray    --> Font table
//                usOffset  --> Offset of font base start address
//                usLength  --> Font amounts we want to load (unit in 1 bit font)
//                ucPar     --> Choose normal or compress font table
// Output Value : None
//--------------------------------------------------
void CScalerLoadFont(BYTE code *pArray, WORD usOffset, WORD usLength, BYTE ucPar)
{
    BYTE temp0, temp1, temp2;

    if(usLength == 0)
        return;

    usOffset = usOffset * 9;
    usOffset += _OSD_FONT_START_POSITION;

    CScalerSendAddr(_OSD_ADDR_MSB_90, _WRITE, _AUTOINC);
    CScalerSendByte((HIBYTE(usOffset) & 0x000f) | 0xd0);
    CScalerSendByte(LOBYTE(usOffset));
	CScalerSendWriteStop();

    if(ucPar == _COMPRESS_FONT)
    {
        ucVLDCnt    = 0;
        ucVLDTemp   = 0;
        pvldarray   = (pArray + 16);

        for(temp0=0;temp0<16;temp0++)
            pData[temp0] = *(pArray + temp0);
    }

	CScalerSendAddr(_OSD_DATA_PORT_92, _WRITE, _NON_AUTOINC);
	do
	{
		for (usOffset=0;usOffset<9;usOffset++)
		{
            if(ucPar == _COMPRESS_FONT)
            {
                temp0   = CScalerGetVLD() << 4;
                temp0   |= CScalerGetVLD();
                temp1   = CScalerGetVLD() << 4;
                temp1   |= CScalerGetVLD();
                temp2   = CScalerGetVLD() << 4;
                temp2   |= CScalerGetVLD();
            }
            else
            {
                temp0 = *pArray++;
                temp1 = *pArray++;
                temp2 = *pArray++;
            }
			
            // Rearrange the byte order
            CScalerSendByte((temp1 << 4) | (temp2 & 0x0f));
            CScalerSendByte((temp2 & 0xf0) | (temp0 & 0x0f));
            CScalerSendByte((temp0 & 0xf0) | (temp1 >> 4));
        }
	}
	while(--usLength);

	CScalerSendWriteStop();
}

BYTE CScalerGetVLD(void)
{
	BYTE zerocnt = 0;

    while(!CScalerGetBitVLD())   zerocnt  += 1;

    if(zerocnt == 0)    return *(pData);

    switch(zerocnt)
    {
        case 1:
            return (CScalerGetBitVLD() ? *(pData + 1) : *(pData + 2));

        case 2:
            return (CScalerGetBitVLD() ? *(pData + 3) : *(pData + 4));

        case 3:
            return (CScalerGetBitVLD() ? *(pData + 5) : *(pData + 6));

        case 4:
            if (CScalerGetBitVLD())
            {
                return (CScalerGetBitVLD() ? *(pData + 7) : *(pData + 8));
            }
            else
            {           
                if (CScalerGetBitVLD())
                {
                    return (CScalerGetBitVLD() ? *(pData + 9) : *(pData + 10));
                }
                else
                {
                    return (CScalerGetBitVLD() ? *(pData + 11) : *(pData + 12));
                }
            }

        default:
            if (CScalerGetBitVLD())
            {
                return (CScalerGetBitVLD() ? *(pData + 13) : *(pData + 14));
            }
            else
            {
                CScalerGetBitVLD();    
            
                return *(pData + 15);
            }
    }
}

bit CScalerGetBitVLD(void)
{
    ucVLDTemp = ((ucVLDCnt & 0x07) == 0) ? *(pvldarray++) : (ucVLDTemp << 1);

    ucVLDCnt += 1;

    return (bit)(ucVLDTemp & 0x80);
}

⌨️ 快捷键说明

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