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

📄 configlcdc.cpp

📁 Microsoft WinCE 6.0 BSP FINAL release source code for use with the i.MX27ADS TO2 WCE600_FINAL_MX27_S
💻 CPP
📖 第 1 页 / 共 2 页
字号:
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//
//  Copyright (C) 2004, Motorola Inc. All Rights Reserved
//
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
//
//  Copyright (C) 2006, Freescale Semiconductor, Inc. All Rights Reserved.
//  THIS SOURCE CODE, AND ITS USE AND DISTRIBUTION, IS SUBJECT TO THE TERMS
//  AND CONDITIONS OF THE APPLICABLE LICENSE AGREEMENT
//
//------------------------------------------------------------------------------
//
//  File:  configlcdc.cpp
//
//  Provides BSP-specific configuration routines for the Display driver.
//  Includes initialization routine for the TV out encoder chip.
//
//------------------------------------------------------------------------------

#include "precomp.h"


//------------------------------------------------------------------------------
// External Functions
//------------------------------------------------------------------------------
extern void   BSPTurnOnLCD(void);
extern void   BSPTurnOffLCD(void);

//------------------------------------------------------------------------------
// External Variables
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// Defines
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// Types
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// Global Variables
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// Local Variables
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// Local Functions
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
//
// Function: LCDCEnable
//
// This function enable or disable Lcdc gpio and clock for LCD panel mode.
//
// Parameters:
//      bEnable
//          [in] This argument is enable or disable Lcdc gpio and clock for LCD panel mode.
//
// Returns:
//      None.
//
//------------------------------------------------------------------------------
static void LCDCEnable(BOOL bEnable)
{
    BOOL initState; 
    DDK_GPIO_CFG cfg;

    DDK_GPIO_SET_CONFIG(cfg, LCDC);

    if(bEnable)
    {
        // Configure LCDC GPIO pins
        initState = DDKGpioEnable(&cfg);

        initState = DDKClockSetGatingMode(DDK_CLOCK_GATE_INDEX_LCDC, DDK_CLOCK_GATE_MODE_ENABLE);
        initState = DDKClockSetGatingMode(DDK_CLOCK_GATE_INDEX_HCLK_LCDC, DDK_CLOCK_GATE_MODE_ENABLE);
    }
    else
    {
        // Disable LCDC
        DDKClockSetGatingMode(DDK_CLOCK_GATE_INDEX_LCDC, DDK_CLOCK_GATE_MODE_DISABLE);
        DDKClockSetGatingMode(DDK_CLOCK_GATE_INDEX_HCLK_LCDC, DDK_CLOCK_GATE_MODE_DISABLE);

        // Reset LCDC GPIO pins
        DDKGpioDisable(&cfg);
    }    
}

//------------------------------------------------------------------------------
//
// Function: InitializeLCDC
//
// This function init and config Lcdc.
//
// Parameters:
//      bTVModeActive
//          [in] This argument choose config for TV mode or LCD mode.
//      bTVNTSCOut
//          [in] This argument choose config for NTSC or PAL mode.
//      dwPanelType
//          [in] This argument choose config for SHARP QVGA or NEC VGA mode.
//
// Returns:
//      Returns TRUE if success. 
//      Returns FALSE if failure.
//
//------------------------------------------------------------------------------
BOOL InitializeLCDC(BOOL bTVModeActive, BOOL bTVNTSCOut, DWORD dwPanelType)
{
    BOOL                  rc = FALSE;
    PHYSICAL_ADDRESS      phyAddr;
    CSP_LCDC_REGS         *pLCDC;
    PCSP_PLLCRC_REGS      g_pPLLCRC;
    LCDC_CTX              CLcdcCtx;
    GPEMode               *pCLcdcMode;
    struct DisplayPanel   *pDisplayPanel;
    DWORD                 dHtotal, dVtotal, dPCDR1DIV3, dPCR;
    UINT32                uLCDRefClk, uLCDPixClk;

    phyAddr.QuadPart = CSP_BASE_REG_PA_CRM;
    // Map peripheral physical address to virtual address
    g_pPLLCRC = (PCSP_PLLCRC_REGS) MmMapIoSpace(phyAddr, sizeof(CSP_PLLCRC_REGS),
            FALSE);
    if (g_pPLLCRC  ==  NULL)   
    {
        DEBUGMSG (1, (TEXT("MmMapIoSpace CSP_PLLCRC_REGS Failed\r\n")) );
        goto cleanup;
    }
    
    phyAddr.QuadPart = CSP_BASE_REG_PA_LCDC;
    pLCDC = (CSP_LCDC_REGS *)MmMapIoSpace(phyAddr, sizeof(CSP_LCDC_REGS), FALSE);
    if (pLCDC  ==  NULL)   
    {
        DEBUGMSG (1, (TEXT("MmMapIoSpace CSP_LCDC_REGS Failed\r\n")) );
        goto cleanup;
    }
    
    pDisplayPanel = BSPConfigPanel(bTVModeActive, bTVNTSCOut, dwPanelType);
    BSPInitLCDC(&CLcdcCtx);
    pCLcdcMode = (GPEMode*)(CLcdcCtx.pGPEModeInfo);

    // Disable LCD panel
    BSPTurnOffLCD();
    // Disable LCDC clock
    LCDCEnable(FALSE);

    // LCDC Refresh Mode Control Register
    CLRREG32(&pLCDC->RMCR, CSP_BITFMASK(LCDC_RMCR_SELF_REF));

    // LCDC Screen Start Address Register
    OUTREG32(&pLCDC->SSAR, 
              (CLcdcCtx.VideoMemoryPhyAdd));

    // LCDC Size Register
    OUTREG32(&pLCDC->SR, 
              (CSP_BITFVAL(LCDC_SR_BUSSIZE, LCDC_SR_BUSSIZE_32BIT)|  // ???
              CSP_BITFVAL(LCDC_SR_XMAX, (pDisplayPanel->width / 16))|
              CSP_BITFVAL(LCDC_SR_YMAX, (pDisplayPanel->height))));

    // LCDC Virtual Page Width Register
    OUTREG32(&pLCDC->VPWR, 
              (pDisplayPanel->width / (32/pCLcdcMode->Bpp))); // the number of 32-bit words

    // LCDC Cursor Position Register
    OUTREG32(&pLCDC->CPR, 
                (CSP_BITFVAL(LCDC_CPR_OP, LCDC_CPR_OP_DISABLE) |
                CSP_BITFVAL(LCDC_CPR_CC, LCDC_CPR_CC_DISABLED)));

    // LCDC Cursor Width Height and Blink Register
    OUTREG32(&pLCDC->CWHBR, 
                  (CSP_BITFVAL(LCDC_CWHBR_BK_EN, LCDC_CWHBR_BK_EN_DISABLE) |
                  CSP_BITFVAL(LCDC_CWHBR_CW, LCDC_CWHBR_CW_CURSOR_DISABLED) |
                  CSP_BITFVAL(LCDC_CWHBR_CH, LCDC_CWHBR_CH_CURSOR_DISABLED) |
                  CSP_BITFVAL(LCDC_CWHBR_BD, LCDC_CWHBR_BD_MAX_DIV)));

    // LCDC Color Cursor Mapping Register
    OUTREG32(&pLCDC->CCMR, 0);

    // LCDC Panel Configuration Register
    if(bTVModeActive)
    {
        dPCDR1DIV3 = 1;
        INSREG32BF(&g_pPLLCRC->PCDR1, PLLCRC_PCDR1_PERDIV3, (dPCDR1DIV3-1));
        uLCDRefClk = 266400000 / dPCDR1DIV3;
    }
    else
    {
        dPCDR1DIV3 = EXTREG32BF(&g_pPLLCRC->PCDR1, PLLCRC_PCDR1_PERDIV3)+1;
        uLCDRefClk = 266000000 / dPCDR1DIV3;
    }
    dHtotal = pDisplayPanel->width + pDisplayPanel->hsync_width + pDisplayPanel->hwait1

⌨️ 快捷键说明

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