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

📄 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 页
字号:
    } 

    // Configure the SLCDC FIFO for the number of words to xmit in one burst cycle
    slcdc->FIFOC = SLCDC_FIFOCONFIG_BURST;
                
    // Configure the SLCDC Clock divider
    slcdc->LCDCC = SLCDC_CLOCKCONFIG_DIVIDE;

    // Configure the SLCDC Clock divider
    slcdc->LCDC = mode.width;

    // Configure the SLCDC Status Register to No IRQ / Go off
    slcdc->DMACCS = 0;  
}

//--------------------------------------------------------------------------
//
// Function: SendCommand
//
// This function Sends Command Data and parameter data to the SLCDC panel 
// by SLCDC controller
//
// Parameters:
//      cmd
//          [in] This argument is command id.
//
//      data
//          [in] This argument is command parameter data. NULL means the command
//          do not need parameter.
//
//      size
//          [in] This argument is the length(in 16 bits) of the parameter data.
//
// Returns:
//      Returns TRUE if the function properly send command to the SLCDC panel. 
//      Returns FALSE if the function can not send command to the SLCDC panel.
//
//--------------------------------------------------------------------------
BOOL SendCommand(UINT16 cmd, UINT16 *data, UINT32 size)
{
    BOOL result = TRUE;
        
    DEBUGMSG(GPE_ZONE_ENTER, (TEXT("++SendCommand\r\n")));

    // Allow previous transfer to complete
    {
        // Wait for Xfer to complete
        while (slcdc->DMACCS & SLCDC_BUSY_MASK)
            DEBUGMSG(GPE_ZONE_TEMP, (TEXT("Wait for Xfer to complete.\r\n")));
        
        // Clear the IRQ
        slcdc->DMACCS |= SLCDC_IRQ_MASK;
    
        // Check SLCDC FIFO Underflow
        if (slcdc->DMACCS & SLCDC_UNDERFLOW_MASK)
        {
            // Clear SLCDC FIFO Underflow
            slcdc->DMACCS |= SLCDC_UNDERFLOW_MASK;
            DEBUGMSG(GPE_ZONE_ERROR, (TEXT("SendCommand:Clear the underflow failed\r\n")));
            result = FALSE;
            goto cleanup;
        }
    
        // Check SLCDC DMA Transfer Error
        if (slcdc->DMACCS & SLCDC_TEA_MASK)
        {
            // Clear SLCDC DMA Transfer Error
            slcdc->DMACCS |= SLCDC_TEA_MASK;
            DEBUGMSG(GPE_ZONE_ERROR, (TEXT("SendCommand: SLCDC DMA Transfer Error.\r\n")));
            result = FALSE;
            goto cleanup;
        }
    }
    
    // Send the Command Data
    {
        // Write command data - and start transfer
        slcdc->LCDWD = cmd;
        
        // Wait for Xfer to complete
        while (slcdc->DMACCS & SLCDC_BUSY_MASK)
            DEBUGMSG(GPE_ZONE_TEMP, (TEXT("Wait for Xfer to complete.\r\n")));
        
        // Clear the IRQ
        slcdc->DMACCS |= SLCDC_IRQ_MASK;
    
        // Clear SLCDC FIFO Underflow
        slcdc->DMACCS |= SLCDC_UNDERFLOW_MASK;
    
        // Check SLCDC DMA Transfer Error
        if (slcdc->DMACCS & SLCDC_TEA_MASK)
        {
            // Clear SLCDC DMA Transfer Error
            slcdc->DMACCS |= SLCDC_TEA_MASK;
        
            DEBUGMSG(GPE_ZONE_ERROR, (TEXT("SendCommand: SLCDC DMA Transfer Error.\r\n")));
            result = FALSE;
            goto cleanup;
        }
    }
    
    // Send the parameter data (if any)
    if (data != NULL)
    {
        // Set the parameter data
        slcdc->DBBA = (UINT32) data;
        
        // Set the paramater data size
        slcdc->DBS = size;
        
        // Clear any previous AUTOMODE config
        slcdc->DMACCS &= ~SLCDC_AUTOMODE_MASK;
        
        // Configure AUTOMODE 01 - LCD_RS signal tied to 1
        slcdc->DMACCS |= SLCDC_AUTOMODE_ACTIVEHIGH;
    
        // Start Xfer
        slcdc->DMACCS |= SLCDC_GO_MASK;
    }

    // Handle timing
    SendCommandWait(cmd);
    
cleanup:
        
    DEBUGMSG(GPE_ZONE_ENTER, (TEXT("--SendCommand\r\n")));
    return(result);
}


// 3. pannel command operation
//--------------------------------------------------------------------------
//
// Function: DisplayFrame
//
// This function send display data to panel display RAM area.
//
// Parameters:
//      data
//          [in] This argument is the display data that are written subsequent to RAMWR,
//          causes the content of panel display RAM to be overwritten.
//
//      start_col
//          [in] This argument set the start column of panel display RAM area 
//           to access from interface.
//
//      end_col
//          [in] This argument set the end column of panel display RAM area 
//           to access from interface.
//
//      start_page
//          [in] This argument set the start page of panel display RAM area 
//           to access from interface.
//
//      end_page
//          [in] This argument set the end page of panel display RAM area 
//           to access from interface.
//
// Returns:
//      Returns TRUE if the function properly send display data to panel display RAM area. 
//      Returns FALSe if the function can not send display data to panel display RAM area.
//
//--------------------------------------------------------------------------
BOOL DisplayFrame(UINT16 *data, UINT16 start_col, UINT16 end_col, 
        UINT16 start_page, UINT16 end_page)
{
    UINT32 result;
    UINT32 size = (end_col - start_col + 1) * (end_page - start_page + 1); // The pixel numbers to display
    DEBUGMSG(GPE_ZONE_ENTER, (TEXT("++DisplayFrame\r\n")));

    static UINT16 start_col_prev = 0;
    static UINT16 end_col_prev = 0;
    static UINT16 start_page_prev = 0;
    static UINT16 end_page_prev = 0;
        
    // If the column address changed, set new starting and ending column address - (columns)
    if ((start_col_prev != start_col) || (end_col_prev != end_col))
    {
        memset((void*)parm_mem, 0, parm_size);
        
        parm_mem[0] = start_col/0xff;
        parm_mem[1] = start_col%0xff;
        parm_mem[2] = end_col/0xff;
        parm_mem[3] = end_col%0xff;

         // Send the command
        if(!(result = SendCommand(CASET, (UINT16 *) SLCDC_PARMBUFFER_PADDR, 4)))
        {
            DEBUGMSG(GPE_ZONE_ERROR, (TEXT("DisplayFrame:send column address command failed\r\n")));
            goto cleanup;
        }       
        
        // Set previous
        start_col_prev = start_col;
        end_col_prev = end_col;
    }
        
    // If the page address changed, set new starting and ending page address - (rows)
    if ((start_page_prev != start_page) || (end_page_prev != end_page))
    {
        memset((void*)parm_mem, parm_size, 0);
        
        parm_mem[0] = start_page/0xff;
        parm_mem[1] = start_page%0xff;
        parm_mem[2] = end_page/0xff;
        parm_mem[3] = end_page%0xff;
        
         // Send the command         
        if(!(result = SendCommand(PASET, (UINT16 *) SLCDC_PARMBUFFER_PADDR, 4)))
        {
            DEBUGMSG(GPE_ZONE_ERROR, (TEXT("DisplayFrame:send page address command failed\r\n")));
            goto cleanup;
        }       
        // Set previous
        start_page_prev = start_page;
        end_page_prev = end_page;
    }

    // write the display data to panel memory
    if(!(result = SendCommand(RAMWR, data, size)))
    {
        DEBUGMSG(GPE_ZONE_ERROR, (TEXT("DisplayFrame:send screen height command failed\r\n")));
        goto cleanup;
    }

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

//--------------------------------------------------------------------------
//
// Function: TurnOnSLCD
//
// This function send command to turn on or turn off the Smart LCD panel.
//
// Parameters:
//      bTurnOn
//          [in] This argument decide whether turn on or turn off the display of Smart LCD panel.
//               True means turn on, FALSE means turn off.
//
// Returns:
//      None.
//
//--------------------------------------------------------------------------
void TurnOnSLCD( BOOL bTurnOn)
{
    if (bTurnOn)
    {           
        if(!SendCommand(DISON, NULL, 0))
        {
            DEBUGMSG(1, (TEXT("DISON failed\r\n")));    
            goto cleanup;
        }
    } 
    else 
    {
        if(!SendCommand(DISOFF, NULL, 0))
        {
            DEBUGMSG(1, (TEXT("DISOFF failed\r\n")));   
            goto cleanup;
        }

        if(!SendCommand(SLPIN, NULL, 0))
        {
            DEBUGMSG(1, (TEXT("SLPIN failed\r\n")));    
            goto cleanup;
        }

        // Reset              
        ResetSLCD(TRUE);             
    }

cleanup:
    DEBUGMSG(GPE_ZONE_ENTER, (TEXT("TurnOnSLCD end\r\n")));
}

//--------------------------------------------------------------------------
//
// Function: SetDisplayConfig_16bit
//
// This function send command to config Smart LCD panel to 16 bit(565) parallel mode.
//
// Parameters:
//      None.
//
// Returns:
//      None.
//
//--------------------------------------------------------------------------
void SetDisplayConfig_16bit(void)
{
        int i;

        // 1. timing
        // DISCTL and the subsequent parameters are used to set the various timing for display. Be sure to enter DISCTL before
        // entering DISON  
        for(i=0; i<15; i++)
            parm_mem[i] = lcd_para_DISCTL[i];
        if(!SendCommand(DISCTL, (UINT16 *) SLCDC_PARMBUFFER_PADDR, 15))
        {
            DEBUGMSG(1, (TEXT("DISCTL failed\r\n")));   
            goto cleanup;
        }   
        
        // 2. gray
        // GAMSET and the subsequent parameter are used to select the setting of 64-gray scale. GAMSET and its parameters
        // should be entered under the DISOFF active state.
        parm_mem[0] = 0x01;
        if(!SendCommand(GAMSET, (UINT16 *) SLCDC_PARMBUFFER_PADDR, 1))
        {
            DEBUGMSG(1, (TEXT("GAMSET failed\r\n")));   
            goto cleanup;
        }   
        
        // GCPSET0 and the subsequent parameters are used to set the 64-gray scale control pulse's position. GCPSET0 and its
        // parameters should be entered under the DISOFF active state.
        for(i=0; i<64; i++)
            parm_mem[i] = lcd_para_GCPSET0_type500282[i];
        if(!SendCommand(GCPSET0, (UINT16 *) SLCDC_PARMBUFFER_PADDR, 64))
        {
            DEBUGMSG(1, (TEXT("GCPSET0 failed\r\n")));  
            goto cleanup;
        }
        
        // GCPSET1 and the subsequent parameters are used to set the 64-gray scale control pulse's position. GCPSET1 and its
        // parameters should be entered under the DISOFF active state.
        for(i=0; i<64; i++)
            parm_mem[i] = lcd_para_GCPSET1_type500282[i];
        if(!SendCommand(GCPSET1, (UINT16 *) SLCDC_PARMBUFFER_PADDR, 64))
        {
            DEBUGMSG(1, (TEXT("GCPSET1 failed\r\n")));  
            goto cleanup;
        }
        
        // 3. size
        // PASET and the subsequent parameters are used to set the page address area of display RAM to access from interface.
        // When column address is incremented to the end column, the column address returns to the start column and the page
        // address is incremented. After page address is incremented to the end page, the page address returns to the start page.
        // The start page value must be less than the end page value.
        for(i=0; i<4; i++)
            parm_mem[i] = lcd_para_PASET_500282[i];
        if(!SendCommand(PASET, (UINT16 *) SLCDC_PARMBUFFER_PADDR, 4))
        {
            DEBUGMSG(1, (TEXT("PASET failed\r\n")));    
            goto cleanup;
        }

        // CASET and the subsequent parameters are used to set the column address area of display RAM to access from
        // interface.
        for(i=0; i<4; i++)
            parm_mem[i] = lcd_para_CASET_500282[i];
        if(!SendCommand(CASET, (UINT16 *) SLCDC_PARMBUFFER_PADDR, 4))
        {
            DEBUGMSG(1, (TEXT("CASET failed\r\n")));    
            goto cleanup;
        }

        parm_mem[0] = 0x48;
        if(!SendCommand(MADCTL, (UINT16 *) SLCDC_PARMBUFFER_PADDR, 1))
        {
            DEBUGMSG(1, (TEXT("MADCTL failed\r\n")));   
            goto cleanup;
        }       

        // 4. data format
        // COLMOD and the subsequent parameter are used to set the color mode.
        // 565 mode: 1 0 1 :65K colors
        parm_mem[0] = 0x05;
        if(!SendCommand(COLMOD, (UINT16 *) SLCDC_PARMBUFFER_PADDR, 1))
        {
            DEBUGMSG(1, (TEXT("COLMOD failed\r\n")));   
            goto cleanup;
        }       

        // IFMOD and the subsequent parameter are used to set the interface mode.
        // 16 bit parallel: 0 1 1
        parm_mem[0] = 0x03;
        if(!SendCommand(IFMOD, (UINT16 *) SLCDC_PARMBUFFER_PADDR, 1))
        {
            DEBUGMSG(1, (TEXT("IFMOD failed\r\n")));    
            goto cleanup;
        }

        // 5. sleep out
        // SLPOUT is used to cancel the LCD module's sleep state. The oscillator circuit and the DC-DC converter circuit start
        // when SLPOUT is entered. DISON can be entered after more than 80ms to wait stabilizing DC output of the Power-IC.
        // SLPOUT can be entered after more than 20ms from SLPIN. By execution of SLPOUT, EVR setting is replaced to the
        // pre-set value fixed by SEIKO EPSON.       
        if(!SendCommand(SLPOUT, NULL, 0))
        {
            DEBUGMSG(1, (TEXT("SLPOUT failed\r\n")));   
            goto cleanup;
        }

cleanup:
    DEBUGMSG(GPE_ZONE_ENTER, (TEXT("SetDisplayConfig_16bit end\r\n")));
}

⌨️ 快捷键说明

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