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

📄 utillcd.c.svn-base

📁 多个厂家的LCD 驱动程序
💻 SVN-BASE
字号:
/*
****************************************************************
*                      Magic Pixel Inc.
*
*    Copyright 2004-2005, Magic Pixel Inc., HsinChu, Taiwan
*                    All rights reserved.
*
*
*
* Filename:    UtilLcd.c
*
* Programmer:    Chiunghua Lee
*                MPX E120 division
*
* Created: 08/14/2005
*
* Description: Source file of utility functions.
*
*
* Change History (most recent first):
*     <1>     08/14/2005    C.H.Lee    first file
****************************************************************
*/
/*
** TODO:
*/
//#include "os.h"
#include "iMagicApi.h"
#include "LCM.h"
#include "UtilLcd.h"

static BOOL m_boolDualPanel = 0;


BOOL UtilDualPanelSupport(void)
{
    return m_boolDualPanel;
}



void UtilMainPanelSingleFrmTx(U32 bufferAddr)
{
    U32 i;

    SelectPrimaryLCM();
    IntDisable();
    MC_PRIMATY_LCM_RAM_ADDRESS(LCMTARGET_MAIN, 0, 0);

    for (i = 0; i < (GetPrimaryPanelWidth() * GetPrimaryPanelHeight()); i++)
    {
        LCM_WRITE_DAT = *(U16 *) bufferAddr;
        bufferAddr += 2;
        BBP_ShortDelay(_LCM_RW_DELAY_TIME);
    }

    IntEnable();
    iMagic_CSSel(IMAGIC_CS_321);        // Why necessary ????
}



void UtilSubPanelSingleFrmTx(U32 bufferAddr)
{
    U16 i;

    if (!UtilDualPanelSupport())
        return;

    SelectSecondaryLCM();
    IntDisable();
    MC_SECONDARY_LCM_RAM_ADDRESS(LCMTARGET_SUB, 0, 0);

    for (i = 0; i < (GetSecondaryPanelWidth() * GetSecondaryPanelHeight()); i++)
    {
        LCM_WRITE_DAT = *((U16 *) bufferAddr);
        bufferAddr += 2;
        BBP_ShortDelay(_LCM_RW_DELAY_TIME);
    }

    IntEnable();
    iMagic_CSSel(IMAGIC_CS_321);
}



static void CusRstPanel(void)
{
#ifdef _MPX_MP421
    /*
    mpx_GpioConfiguraionSet(VGPIO_11, 0x00);
    mpx_GpioDataSet(VGPIO_11, 1);
    UtilWait(10);
    mpx_GpioDataSet(VGPIO_11, 0);
    UtilWait(70);
    mpx_GpioDataSet(VGPIO_11, 1);
    */
    //mpx_GpioConfiguraionSet(TGPIO_8, 0x00);
    mpx_GpioDataSet(TGPIO_8, 1);
    UtilWait(10);
    mpx_GpioDataSet(TGPIO_8, 0);
    UtilWait(70);
    mpx_GpioDataSet(TGPIO_8, 1);
#else
    //mpx_GpioConfiguraionSet(VGPIO_25, 0x00);
    mpx_GpioDataSet(VGPIO_25, 1);
    UtilWait(10);
    mpx_GpioDataSet(VGPIO_25, 0);
    UtilWait(70);
    mpx_GpioDataSet(VGPIO_25, 1);
    UtilWait(10);
#endif
}



void DisplayInit()
{
    U32 i;

    DPrintf("Init main panel");

    CusRstPanel();

    if (LCM_INTERFACE_MPU_TYPE == GetPrimaryPanelInterfaceType())
    {
        DPrintf("MC_PRIMARY_LCM_INIT");
        MC_PRIMARY_LCM_INIT(LCMTARGET_MAIN);

        DPrintf("Clear main panel - %3dx%3d", GetPrimaryPanelWidth(), GetPrimaryPanelHeight());
        IntDisable();

        for (i = 0; i < (GetPrimaryPanelWidth() * GetPrimaryPanelHeight()); i++)
        {
            LCM_WRITE_DAT = 0x0000;
            BBP_ShortDelay(_LCM_RW_DELAY_TIME);
        }

        IntEnable();
        iMagic_CSSel(IMAGIC_CS_321);
    }
    else
    {
        DPrintf("Primary LCM is not MPU type");
    }

    if (UtilDualPanelSupport() && (LCM_INTERFACE_MPU_TYPE == GetSecondaryPanelInterfaceType()))
    {
        DPrintf("Init sub panel");

        DPrintf("MC_SECONDARY_LCM_INIT");

        MC_SECONDARY_LCM_INIT(LCMTARGET_SUB);
        DPrintf("Clear sub panel");
        IntDisable();

        for (i = 0; i < (GetSecondaryPanelWidth() * GetSecondaryPanelHeight()); i++)
        {
            LCM_WRITE_DAT = 0x0000;
            BBP_ShortDelay(_LCM_RW_DELAY_TIME);
        }

        IntEnable();
        iMagic_CSSel(IMAGIC_CS_321);
    }
    else
    {
        DPrintf("Secondary LCM is not MPU type or not support dual panel");
    }

    //m_pstActiveDisplay = &stMainDisplay;
}



U16 GetPrimaryPanelWidth()
{
    return PRIMARY_LCM_WIDTH;
}



U16 GetPrimaryPanelHeight()
{
    return PRIMARY_LCM_HEIGHT;
}



U16 GetSecondaryPanelWidth()
{
    return SECONDARY_LCM_WIDTH;
}



U16 GetSecondaryPanelHeight()
{
    return SECONDARY_LCM_HEIGHT;
}



/*
void LCMCommandWrite(U16 cmd)
{
    U08 i;

    LCM_WRITE_ADR = cmd;
    for(i = 0; i < 5; i++)
        __asm("nop");
}



void LCMParameterWrite(U16 para)
{
    U08 i;

    LCM_WRITE_DAT = para;
    for(i = 0; i < 5; i++)
        __asm("nop");
}
*/



void SelectPrimaryLCM()
{
    //DPrintf("P");
    if (LCMTARGET_MAIN == PANEL_CS0)
        iMagic_CSSel(IMAGIC_CS_LCM1);
    else
        iMagic_CSSel(IMAGIC_CS_LCM2);
}



void SelectSecondaryLCM()
{
    //DPrintf("S");
    if (LCMTARGET_SUB == PANEL_CS0)
        iMagic_CSSel(IMAGIC_CS_LCM1);
    else
        iMagic_CSSel(IMAGIC_CS_LCM2);
}



U08 GetPrimaryPanelInterfaceType()
{
    return PRIMARY_LCM_TYPE;
}



U08 GetSecondaryPanelInterfaceType()
{
    return SECONDARY_LCM_TYPE;
}

⌨️ 快捷键说明

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