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

📄 display.c

📁 Windows CE 6.0 BSP for VOIP sample phone. Intel PXA270 platform.
💻 C
📖 第 1 页 / 共 2 页
字号:
    {
        g_pSSPRegs->ssdr = 0x0;
    }

    while ((g_pSSPRegs->ssdr != 0x0000) && FIFOCnt--)
    {
        g_pSSPRegs->sscr0 &= ~SSCR0_SSE;
        g_pSSPRegs->sscr0 |= SSCR0_SSE;
        msWait(5);
        g_pSSPRegs->ssdr = 0x0;
        g_pSSPRegs->ssdr = 0x0;
        g_pSSPRegs->ssdr = 0x0;
    }
      
    return(TRUE);
}

BOOL WriteSSPLink(unsigned char start, unsigned int data)
{
    msWait(5);
    while((g_pSSPRegs->sssr & SSP_TRANSMIT_FIFO_NOT_FULL) == 0);
    g_pSSPRegs->ssdr = start;
    while((g_pSSPRegs->sssr & SSP_TRANSMIT_FIFO_NOT_FULL) == 0);
    g_pSSPRegs->ssdr = (data >> 8) & 0xFF;
    while((g_pSSPRegs->sssr & SSP_TRANSMIT_FIFO_NOT_FULL) == 0);
    g_pSSPRegs->ssdr = data & 0xFF;

    return(TRUE);
}

BOOL WriteLcdControllerData(LCD_CTRLR_DATA *plcdData)
{
    // Send source driver setting via SSP link
    while ( plcdData->lcd_data_index != LCD_DATA_LAST )
    {
        // Wait for specified ms
        if ( plcdData->lcd_data_index == LCD_DATA_WAIT )
        {
            msWait(plcdData->lcd_data_value);
        }
        else
        {
            // Send register index and data value.
            WriteSSPLink(HD66781_CTRL_REG_INDEX,plcdData->lcd_data_index);
            WriteSSPLink(HD66781_CTRL_TX_INSTR,plcdData->lcd_data_value);
        }

        // Next data set
        plcdData++;
    }

    return TRUE;
}

void BLSetDisplayColorSolid(UINT8 red, UINT8 green, UINT8 blue)
{
    UINT32 i;
    UINT32 *fbp;
    UINT16 color = RGBU16(red, green, blue);

    fbp = (UINT32 *) OALPAtoVA(g_pBLFrameBufferPhysical, FALSE);

    if (fbp)
    {
        for ( i = 0; i < (240*320*(2)/4); i++ )
             *fbp++ = color << 16 | color;
    }
    else
        KITLOutputDebugString("Display::SetFrameBuffer. bad memory\r\n");
}

void BLInitDisplay()
{
    KITLOutputDebugString("\r\nInitializing display...\r\n");
    
    // Initialize SSP Link
    SetupSSPLink();

    // Initialize the GPIO registers for proper LCD Controller operation
    SetupLCDGPIOs();

    // Initialize the LCD Controller and frame descriptors
    InitLCDController();

    // Clear LCD Controller status register
    ClearLCDStatusReg();

    // Initialize source driver
    WriteLcdControllerData(InitSequence);

    // Clear the Display
    BLSetDisplayColorSolid(0xFF, 0xFF, 0xFF);

    // Enable the LCD controller
    EnableLCDController();

    // Default to the brief menu
    g_DisplayMenu = FALSE;

    // Setup 
    g_pOEMReportError = OEMReportError;

    KITLOutputDebugString("Display initialized.\r\n");
}

void DisableLCDController()
{
    volatile LCDRegs *p_LCDRegs;
    volatile XLLP_GPIO_T *p_GPIORegs;

    p_LCDRegs = (volatile LCDRegs *) OALPAtoVA(BULVERDE_BASE_REG_PA_LCD, FALSE);
    p_GPIORegs = (volatile XLLP_GPIO_T *) OALPAtoVA(BULVERDE_BASE_REG_PA_GPIO, FALSE);

    // Turn off backlight
    p_GPIORegs->GPCR0   |= XLLP_GPIO_BIT_PWM_OUT0;

    // Make the contents of the framebuffer match uninitialised memory.
    // This prevents fragments of the boot screen from showing up during
    // display driver startup
    BLSetDisplayColorSolid(0xFF, 0xFF, 0xFF);
    msWait(100);

    if (p_LCDRegs->LCCR0 & LCD_ENB)
    {
        // Initiate power down sequence
        p_LCDRegs->LCCR0 |= LCD_DIS;

        // Wait for LDD bit to get set once the last DMA transfer has completed
        while(!(p_LCDRegs->LCSR0 & LCD_LDD));

        // Clear the sticky LDD bit
        p_LCDRegs->LCSR0 |= LCD_LDD;
    }
}

// Renders a string to the display. ASCII characters 32-127 are supported.
// This is primarily used to display the fixed menu text on lines 0-11.
void DisplayString(int line, char * str)
{
    UINT16 txt = RGBU16(0x00, 0x00, 0x00);
    UINT16 bkg = RGBU16(0xFF, 0xFF, 0xFF);
    UINT16 * fbp = (UINT16 *) OALPAtoVA(g_pBLFrameBufferPhysical, FALSE);
    unsigned int i, j, k, row, col;
    unsigned const char * bitmap;

    // Only write to valid lines
    if (line >= 320/FONT_HEIGHT) 
    {
        return;
    }

    row = line * FONT_HEIGHT;
    col = 0;

    if (fbp)
    {
        // Clear the line
        for (i = 0; i < 240 * FONT_HEIGHT; i++) 
        {
           *(fbp + (240 * row) + i) = bkg;
        }
            
        // Render the text
        for (i = 0; i < strlen(str); i++) 
        {
            // Only ASCII characters 32-127 have bitmaps, the rest will render as ' '
            if ((str[i] >= 32) && (str[i] <= 127)) 
            {
                bitmap = &(blfont[(str[i] - 32) * FONT_BYTESPERCHAR]);
            }
            else 
            {
                // Warn here about invalid chars?
                bitmap = &(blfont[0]);
            }

            // Wrap if the length exceeds one line. This prevents writing past the
            // end of the screen, and preserves the information found at the end of the string.
            if ((col + FONT_WIDTH) >= 240) {
                col = 0;
            }

            for (j = 0; j < FONT_HEIGHT; j++)
            {
                for (k = 0; k < FONT_WIDTH; k++)
                {
                    *(fbp + (240 * (row + j) + col + k)) = (bitmap[j] & ((1 << (FONT_WIDTH - 1)) >> k)) ? txt : bkg;
                }
            }
            col += FONT_WIDTH;
        }
    } 
    else 
    {
        KITLOutputDebugString("Display::DisplayString. bad memory\r\n");
    }
}

// Display a debug string as part of the lower 5 line scrolling segment.
void DisplayDebugString(char * str) {
    UINT16 * fbp = (UINT16 *) OALPAtoVA(g_pBLFrameBufferPhysical, FALSE);

    if (fbp) 
    {
        if (g_DisplayMenu) // Scroll the bottom four lines of the screen upwards by one line 
            memmove((fbp + (12 * FONT_HEIGHT * 240)), (fbp + (13 * FONT_HEIGHT * 240)), (240*320 - (13*FONT_HEIGHT*240)) * 2); 

        // Display the string at the bottom of the screen
        DisplayString(16, str);
    } 
    else 
    {
        KITLOutputDebugString("Display::WriteDebugScreen. bad memory\r\n");
    }
}

void DisplayStartUpScreen()
{
    if (g_DisplayMenu) {
        // Clear Splash Screen
        BLSetDisplayColorSolid(0xFF, 0xFF, 0xFF);

        DisplayString(1, "Plato Bootloader v" xstr(EBOOT_VERSION_MAJOR) "." xstr(EBOOT_VERSION_MINOR));
        DisplayString(2, "Built " __DATE__);

        if (g_EbootCFG.KITLEnabled)
            DisplayString(4, "KITL........: Enabled");
        else
            DisplayString(4, "KITL........: Disabled");

        if (g_DownloadImage) 
            DisplayString(5, "Img Src.....: Download");
        else
            DisplayString(5, "Img Src.....: Flash");

        if (g_pBSPArgs->bFormatPartFlag == TRUE)
            DisplayString(6, "Format Flash: Yes");
        else
            DisplayString(6, "Format Flash: No");

        if (g_EbootCFG.KITLEnabled)
            DisplayString(8, "3 -> Disable KITL.");
        else
            DisplayString(8, "1 -> Enable KITL.");

        if (g_EbootCFG.autoDownloadImage) 
            DisplayString(9, "7 -> Boot from flash.");
        else
            DisplayString(9, "9 -> Boot from PB.");
        
        DisplayString(10, "8 -> Format flash.");
        DisplayString(11, "0 -> Exit Menu.");
    } else {
        DisplaySplashScreen((UINT16 *) OALPAtoVA(g_pBLFrameBufferPhysical, FALSE));
        DisplayDebugString("Press 5 for boot menu.");
    }
}

BOOL OEMReportError(DWORD dwReason, DWORD dwReseved) {
    DisplayDebugString("ERROR:See serial dbg output.");
    return TRUE;
}

⌨️ 快捷键说明

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