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

📄 bspslcdcclass.cpp

📁 Microsoft WinCE 6.0 BSP FINAL release source code for use with the i.MX27ADS TO2 WCE600_FINAL_MX27_S
💻 CPP
📖 第 1 页 / 共 3 页
字号:
void SlcdcInit (void)
{
    DEBUGMSG(GPE_ZONE_ENTER, (TEXT("++SlcdcInit\r\n")));
    
    // Reset Smart LCD panel
    ResetSLCD(TRUE);

    // Disable Clock for Smart LCD controller
    ConfigClock_to_SLCDC(FALSE);
    
    // Enable Clock for Smart LCD controller
    ConfigClock_to_SLCDC(TRUE);
    
    // Config Smart LCD controller
    SLCDConfig();
        
    // Cancel reset Smart LCD panel  
    ResetSLCD(FALSE);
    
    // Select Smart LCD panel
    SelectPanel();
    
    // Config Smart LCD panel
    SetDisplayConfig_16bit();

	// Turn on Smart LCD panel
    TurnOnSLCD(TRUE);  
    TurnOnBKL(TRUE);
            
    DEBUGMSG(GPE_ZONE_ENTER, (TEXT("--SlcdcInit\r\n")));
    return;
}
    
//--------------------------------------------------------------------------
//
// Function: SendCommandWait
//
// This function handles the timing for SendCommand method. The waiting time is set 
// according to the panel spec.
//
// Parameters:
//      cmd
//          [in] This argument is command id.
//
// Returns:
//      None.
//
//--------------------------------------------------------------------------
void SendCommandWait(UINT16 cmd)
{
    DEBUGMSG(GPE_ZONE_ENTER, (TEXT("++SendCommandWait\r\n")));
    
    switch (cmd)
    {
        case RAMWR:
            break;
        
        case CASET:
        case PASET:
                break;
        
        case DISON:
            Sleep(60);
            break;
        
        case DISOFF:
            Sleep(60);
            break;
        
        case SLPIN:
            Sleep(20);
            break;
        
        case SLPOUT:
            Sleep(80);
            break;
            
        case DISCTL:
            break;
            
        default:
            break;
    }
    
    DEBUGMSG(GPE_ZONE_ENTER, (TEXT("--SendCommandWait\r\n")));
}

// 1. used by csp
//--------------------------------------------------------------------------
//
// Function: GetPanelTypeFromRegistry
//
// This function gets the current panel type from registry.
//
// Parameters:
//      None.
//
// Returns:
//      Panel type number for initial display panel.
//
//--------------------------------------------------------------------------
DWORD  GetPanelTypeFromRegistry(void) 
{
    SCODE result;
    HKEY  hKey = NULL;
    DWORD dwSize, dwPanelType;

    DEBUGMSG(GPE_ZONE_ENTER, (TEXT("++GetPanelTypeFromRegistry\r\n")));

    // Get video key
    result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, VIDEO_REG_PATH, 0 , 0, &hKey);
    if(result != ERROR_SUCCESS)
    {
        DEBUGMSG(GPE_ZONE_ERROR, (TEXT("GetPanelTypeFromRegistry:Open the RegKey failed\r\n")));
        goto cleanup;
    }
    
    // Get panel type
    dwSize = sizeof(dwPanelType);
    result = RegQueryValueEx(hKey, PANEL_TYPE, NULL, NULL,(LPBYTE)&dwPanelType, 
        (LPDWORD) &dwSize);
    if(result != ERROR_SUCCESS)
    {
        DEBUGMSG(GPE_ZONE_ERROR, (TEXT("GetPanelTypeFromRegistry:Get mode.width failed\r\n")));
        dwPanelType = -1;
        goto cleanup;
    }
    
cleanup:
    // Close the video key
    if (hKey != NULL)
        RegCloseKey(hKey);   

    DEBUGMSG(GPE_ZONE_ENTER, (TEXT("--GetPanelTypeFromRegistry\r\n")));  
    return (dwPanelType);
}

//--------------------------------------------------------------------------
//
// Function: BspNumModes
//
// This function returns the number of display modes supported by a driver. 
// A simple implementation returns 1.
//
// Parameters:
//      None.
//
// Returns:
//      Returns the number of display modes supported by a driver.
//
//--------------------------------------------------------------------------
int BspNumModes(void)
{
    return MAX_NUM_MODES;
}

//--------------------------------------------------------------------------
//
// Function: BspSetMode
//
// This function enable the device driver based on the Graphics Primitive Engine (GPE) 
// and to request a specific mode for the display.
//
// Parameters:
//      modeID 
//          [in] Mode number to set
//
//      pPalette
//          [in, out] On input, a handle to a palette. On output, 
//                    this parameter provides a palette filled in by the EngCreatePalette function.
//
// Returns:
//      Returns S_OK if successfully.
//      Returns S_FALSE if not successfully.
//
//--------------------------------------------------------------------------
SCODE BspSetMode(int modeId, HPALETTE *pPalette)
{
    SCODE result = S_OK;
    
    DEBUGMSG(GPE_ZONE_ENTER, (TEXT("++BSPSlcdcClass::SetMode\r\n")));
    if (modeId <= MAX_NUM_MODES)
    {
        DEBUGMSG(GPE_ZONE_ENTER, (TEXT("%s: Got display mode, %d!\r\n"), __WFUNCTION__, m_SupportedModes[modeId].modeId));
        memcpy(&mode, &(m_SupportedModes[modeId]), sizeof(GPEMode));
    }
        
    // Create a palette for MGDI
    if(pPalette != NULL)
    {
        // 15,16,24, and 32bpp primaries are defined by red,green, and blue
        if(!(*pPalette = EngCreatePalette(PAL_BITFIELDS, 0, NULL, RGB565_RED, 
            RGB565_GREEN, RGB565_BLUE)))
        {
            DEBUGMSG(GPE_ZONE_ERROR, (TEXT("SetMode:Create a palette for MGDI failed\r\n")));
            result = S_FALSE;
            goto cleanup;
        }
         
    }
    
cleanup:
    DEBUGMSG(GPE_ZONE_ENTER, (TEXT("--BSPSlcdcClass::SetMode\r\n")));
    return (result);
}

//--------------------------------------------------------------------------
//
// Function: BspGetModeInfo
//
// This function populates a GPEMode structure with data for the requested mode.
//
// Parameters:
//      pMode
//          [out] Pointer to a GPEMode structure.
//
//      modeNo
//          [in] Integer specifying the mode to return information about.
// Returns:
//      Returns S_OK if successfully.
//      Returns E_INVALIDARG if the requested mode is not supported.
//
//--------------------------------------------------------------------------
SCODE BspGetModeInfo(GPEMode *pMode, int modeNo)
{
    SCODE result = S_OK;

    DEBUGMSG(GPE_ZONE_ENTER, (TEXT("++BSPSlcdcClass::GetModeInfo\r\n")));
    // Check mode number    
    if(modeNo != mode.modeId)
    {
        DEBUGMSG(GPE_ZONE_ERROR, (TEXT("+GetModeInfo:Invalid mode number!\r\n")));
        result = E_INVALIDARG;
        goto cleanup;
    }

    // Return the mode
    *pMode = mode;

cleanup:
    DEBUGMSG(GPE_ZONE_ENTER, (TEXT("--BSPSlcdcClass::GetModeInfo\r\n")));
    return (result);
}

//--------------------------------------------------------------------------
//
// Function: BspPowerHandler
//
// This function implement the powerHandler method to turn on/off SLCDC.
//
// Parameters:
//      bOff
//          [in] This argument decide whether turn on or turn off the Smart LCD panel.
//               True means turn off, FALSE means turn on.
//
// Returns:
//      None.
//
//--------------------------------------------------------------------------
void BspPowerHandler(BOOL bOff)
{   
    DEBUGMSG(GPE_ZONE_ENTER, (TEXT("++BSPSlcdcClass::PowerHandler\r\n")));

    // Turn off the display
    TurnOnSLCD(!bOff);

    DEBUGMSG(GPE_ZONE_ENTER, (TEXT("--BSPSlcdcClass::PowerHandler\r\n")));
    return;
}

//--------------------------------------------------------------------------
//
// Function: BspBltComplete
//
// This function executes to complete a blit sequence initiated by GPE::BltPrepare.
//
// Parameters:
//      None.
//
// Returns:
//      Returns S_OK if complete a blit sequence successfully.
//      Returns S_FALSE if not complete a blit sequence successfully.
//
//--------------------------------------------------------------------------
SCODE BspBltComplete(void)
{
    SCODE status;
    BOOL result;
    DEBUGMSG(GPE_ZONE_ENTER, (TEXT("++BSPSlcdcClass::BltComplete\r\n")));

    // Refresh the screen
    if(!(result = DisplayFrame((UINT16 *) SLCDC_FRAMEBUFFER_PADDR, SLCD_START_COL, SLCD_END_COL, 
        SLCD_START_ROW, SLCD_END_ROW))) 
    {
        DEBUGMSG(GPE_ZONE_ERROR, (TEXT("BltComplete:Refresh the screen failed\r\n")));
        goto cleanup;
    }

cleanup:
    // Translate boolean to status code
    if (result == TRUE)
        status = S_OK;      
    else
        status = S_FALSE;   
    DEBUGMSG(GPE_ZONE_ENTER, (TEXT("--BSPSlcdcClass::BltComplete\r\n")));   
    return (status);
}

//--------------------------------------------------------------------------
//
// Function: BSPGetSLCDCBitMasks
//
// This function returns the bitmask used by CSP.
//
// Parameters:
//      None.
//
// Returns:
//      Returns the bitmask used by CSP.
//
//--------------------------------------------------------------------------
ULONG* BSPGetSLCDCBitMasks(void)
{
    return masks;
}

//--------------------------------------------------------------------------
//
// Function: BspGetVideoMem
//
// This function returns the video memory address used by CSP.
//
// Parameters:
//      None.
//
// Returns:
//      Returns the video memory address used by CSP.
//
//--------------------------------------------------------------------------
UINT16 *BspGetVideoMem(void)
{
    return video_mem;
}

//--------------------------------------------------------------------------
//
// Function: BspGetMode
//
// This function returns the mode used by CSP.
//
// Parameters:
//      None.
//
// Returns:
//      Returns the mode used by CSP.
//
//--------------------------------------------------------------------------
GPEMode BspGetMode(void)
{
    return mode;
}

// 2. slcdc controller
//--------------------------------------------------------------------------
//
// Function: SLCDConfig
//
// This function config SLCDC controller to 16 bit parallel / 8 bit command / 16 bit little endian mode.
//
// Parameters:
//      None.
//
// Returns:
//      None.
//
//--------------------------------------------------------------------------
void SLCDConfig(void) 
{
    // Init the SLCD
    memset((void *) slcdc, sizeof(*slcdc), 0);
    
    // Configure SLCDC to 16 bit parallel / 8 bit command / 16 bit little endian
    {
        // Configure IMGEND - 16 bit little endian
        slcdc->LCDTXC = SLCDC_IMGEND_16BLE;
        
        // Configure WORDDEFWRITE - 8 Bit write data words
        slcdc->LCDTXC &= ~SLCDC_WORDDEFWRITE_16BIT;
        
        // Configure WORDDEFDAT - 16 Bit buffer words
        slcdc->LCDTXC |= SLCDC_WORDDEFDAT_16BIT;

        // Configure WORDDEFCOM - 8 bit command words
        slcdc->LCDTXC &= ~SLCDC_WORDDEFCOM_16BIT;

        // Configure XFERMODE - Word parallel transfers
        slcdc->LCDTXC |= SLCDC_XFERMODE_PARALLEL;
        
        // Configure CSPOL - Chip select polarity to active high
        slcdc->LCDTXC &= ~SLCDC_CSPOL_ACTIVEHIGH;

⌨️ 快捷键说明

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