xslcdtest.c
来自「优龙YLP270开发板 光盘自带的BIOS和实验例程源码 强烈推荐」· C语言 代码 · 共 405 行
C
405 行
/******************************************************************************
**
** COPYRIGHT (C) 2000, 2001 Intel Corporation.
**
** This software, as well as the software described in it, is furnished under
** license and may only be used or copied in accordance with the terms of the
** license. The information in this file is furnished for informational use
** only, is subject to change without notice, and should not be construed as
** a commitment by Intel Corporation. Intel Corporation assumes no
** responsibility or liability for any errors or inaccuracies that may appear
** in this document or any software that may be provided in association with
** this document.
** Except as permitted by such license, no part of this document may be
** reproduced, stored in a retrieval system, or transmitted in any form or by
** any means without the express written consent of Intel Corporation.
**
** FILENAME: XsLcdTest.c
**
** PURPOSE: This file contains Test functions for the LCD Controller.
**
** LAST MODIFIED: $Modtime: 7/17/03 1:01p $
******************************************************************************/
/************* Header Files *************/
#include <stdio.h>
#include <string.h>
#include "systypes.h"
#include "dm_errors.h"
#include "platform.h"
#include "xslcdcontroller.h"
#include "XsLcdTest.h"
#include "timedelays.h"
#include "mallocx.h"
#include "ROS.h"
/************* Global Functions *************/
/*
*******************************************************************************
*
* FUNCTION: XsLcdPictureTest
*
* DESCRIPTION: This test will display a (640 * 480 pixels;16bpp) Windows BMP
* file. It calls ParseWindowsBmpFile() to convert a 24bpp BMP into
* 16bpp format, before displaying the picture is possible.
*
* INPUT PARAMETERS: None.
*
* RETURNS: Number of errors.
*
* GLOBAL EFFECTS: None.
*
* ASSUMPTIONS: None.
*
* CALLS: VerifyBmpHeader
* ParseBmpFile
*
* CALLED BY:
*
* PROTOTYPE: UINT XsLcdPictureTest(void);
*
*******************************************************************************
*/
extern unsigned char LOGO[];
void Paint_Bmp(int,int,int,int,unsigned char bmp[]);
UINT XsLcdPictureTest(void)
{
ErrorT retVal;
INT16 x, y;
PostDisplayProgress(ERR_L_LCD, 0x80, 0);
retVal = XsLcdHWSetup();
if (retVal != ERR_NONE) {
// XllpUtilityOutputError(retVal);
return 1;
}
PostDisplayProgress(ERR_L_LCD, 0x80, 1);
/* if (XsLcdBmp((BmpT *)BMP_FILE_START_VIRT_ADDR))
{;
}
else
{
// no bitmap found so create a default picture
XsLcdCreateDefaultPicture();
}
*/
// create a white background
for(x=0; x<240; x++)
for(y = 0; y <50; y++)
XsLcdPutXY(x, y, 0xFFFF);
//LOGO
Paint_Bmp(0,50,240,320, LOGO); //paint a bmp
for(x=0; x<240; x++)
for(y = 270; y <320; y++)
XsLcdPutXY(x, y, 0xFFFF);
PostDisplayProgress(ERR_L_LCD, 0x80, 2);
XsLcdOn(); // Enable the LCD Controller.
PostDisplayProgress(ERR_L_LCD, 0x80, 3);
DM_WaitMs(500); // Let the LCD settle down before turning on the backlight,
XsLcdBackLightOn(); //Turn on the backlight
/*
while(!GetUserInput(buf, sizeof(buf)));
XsLcdBmp((BmpT *)BMP_FILE_START_VIRT_ADDR);
printf("bmp:");
*/
//while(!GetUserInput(buf, sizeof(buf)));
PostDisplayProgress(ERR_L_LCD, 0x80, 4);
//DM_WaitS(2); masked by hzh
/*for (i=0; i<=9; i++)
{
printf("addr:0x%x ,val:0x%x \n", (0x44000000+i*4), ( *(volatile *)(0x44000000+i*4) ) );
}
*/
return 0;
// } else {
// XllpUtilityOutputError(ERRORCODEX(ERR_L_LCD, 0x80, 0, ERR_T_BMP));
// return 1;
// }
}
/************* Global Kludge Functions *************/
/*
*******************************************************************************
*
* FUNCTION: KXsLcdPictureTest
*
* DESCRIPTION: Kludge for legacy code.
*
* INPUT PARAMETERS: void *arg - Ignored.
* CHAR *param - Ignored.
*
* RETURNS: None.
*
* GLOBAL EFFECTS: None.
*
* ASSUMPTIONS: None.
*
* CALLS: XsLcdPictureTest()
*
* CALLED BY: Command List.
*
* PROTOTYPE: void KXsLcdPictureTest(PVOID arg, PCHAR param);
*
*******************************************************************************
*/
void KXsLcdPictureTest(PVOID arg, PCHAR param)
{
XsLcdPictureTest();
}
/*
*******************************************************************************
*
* FUNCTION: XsLcdCreateDefaultPicture
*
* DESCRIPTION: Creates a test image directly in the frame buffer.
*
* INPUT PARAMETERS: void .
*
*
* RETURNS: None.
*
* GLOBAL EFFECTS: None.
*
* ASSUMPTIONS: None.
*
* CALLS:
*
* CALLED BY: XsLcdPictureTest
*
* PROTOTYPE: void XsLcdCreateDefaultPicture(VOID);
*
*******************************************************************************
*/
void XsLcdCreateDefaultPicture()
{
UINT16 xmax;
UINT16 ymax;
UINT16 x, y;
UINT16 color_red = 0xF800;
UINT16 color_green = 0x07e0;
UINT16 color_blue = 0x001F;
UINT16 color_white = 0xFFFF;
UINT16 color_yellow = 0xFFE0;
UINT16 color_cyan =0x07FF;
UINT16 color_magenta = 0xF81F;
UINT16 color;
UINT16 color_bar_startx;
UINT16 color_bar_starty;
UINT16 bar = 6;
UINT16 step;
UINT16 characters_across;
char * title = "POST Test Image";
UINT16 i;
// determine the size limits by the type of screen
if (GetLcdPanelID() == LCDID_SHARP_QVGA)
{
if (GetLcdPanelOrientation())
{ // landscape
xmax = 319;
ymax = 239;
characters_across = 40;
}
else
{ // portrait
xmax = 239;
ymax = 319;
characters_across = 30;
}
}
else
{
if (GetLcdPanelOrientation())
{ // landscape
xmax = 639;
ymax = 479;
characters_across = 40;
}
else
{ // portrait
xmax = 479;
ymax = 639;
characters_across = 30;
}
}
// put some text up
// characters are already sized to work in the screens
// skip the first line
for(i=0; i<characters_across; i++)
XsLcdStr(" ");
// center the text
for(i=0; i<(characters_across/2) - strlen(title)/2; i++)
XsLcdStr(" ");
XsLcdStr(title);
// create the border
color = color_white;
for (x=0; x<=xmax; x++)
{
y = 0;
XsLcdPutXY(x, y, color);
}
for (x=0; x<=xmax; x++)
{
y = ymax;
XsLcdPutXY(x, y, color);
}
for (y=0; y<=ymax; y++)
{
x = 0;
XsLcdPutXY(x, y, color);
}
for (y=0; y<=ymax; y++)
{
x = xmax;
XsLcdPutXY(x, y, color);
}
// create the color bars 220 x 200 pixels
color_bar_startx = (xmax/2) - 110;
color_bar_starty = 20;
// create a white background
for(x=color_bar_startx; x<color_bar_startx +220; x++)
{
for(y = color_bar_starty; y <color_bar_starty + 200; y++)
XsLcdPutXY(x, y, color_white);
}
// put in color bars
do
{
if(bar == 6)
{
color = color_red;
step = 5;
// printf("red\r\n");
}
else if(bar == 5)
{
color = color_green;
step = 40;
// printf("green\r\n");
}
else if(bar == 4)
{
color = color_blue;
step = 75;
// printf("blue\r\n");
}
else if(bar == 3)
{
color = color_cyan;
step = 110;
// printf("cyan\r\n");
}
else if(bar == 2)
{
color = color_yellow;
step = 145;
// printf("yellow\r\n");
}
else if(bar == 1)
{
color = color_magenta;
step = 180;
// printf("magenta\r\n");
}
for(x=color_bar_startx + step; x<color_bar_startx + step +35; x++)
{
for(y = color_bar_starty + 5; y <color_bar_starty + 195; y++)
XsLcdPutXY(x, y, color);
}
bar--;
//printf("bar = %d\r\n", bar);
} while(bar != 0);
// mark the center of the screen and touch points on the corners
color = color_white;
color_bar_startx = 0;
color_bar_starty = 0;
for(x=color_bar_startx; x<color_bar_startx +xmax/25; x++)
{
for(y = color_bar_starty ; y <color_bar_starty + ymax/25; y++)
XsLcdPutXY(x, y, color);
}
color_bar_startx = xmax - xmax/25;
color_bar_starty = 0;
for(x=color_bar_startx; x<color_bar_startx +xmax/25; x++)
{
for(y = color_bar_starty ; y <color_bar_starty + ymax/25; y++)
XsLcdPutXY(x, y, color);
}
color_bar_startx = 0;
color_bar_starty = ymax - ymax/25;
for(x=color_bar_startx; x<color_bar_startx +xmax/25; x++)
{
for(y = color_bar_starty ; y <color_bar_starty + ymax/25; y++)
XsLcdPutXY(x, y, color);
}
color_bar_startx = xmax - xmax/25;
color_bar_starty = ymax - ymax/25;
for(x=color_bar_startx; x<color_bar_startx +xmax/25; x++)
{
for(y = color_bar_starty ; y <color_bar_starty + ymax/25; y++)
XsLcdPutXY(x, y, color);
}
color_bar_startx = xmax/2 - xmax/50;
color_bar_starty = ymax/2 - ymax/50;
for(x=color_bar_startx; x<color_bar_startx +xmax/25; x++)
{
for(y = color_bar_starty ; y <color_bar_starty + ymax/25; y++)
XsLcdPutXY(x, y, color);
}
// put the red dot at the first pixel and a green at the last.
// used for clock timing inspection
XsLcdPutXY(0, 0, color_red);
XsLcdPutXY(xmax, ymax, color_green);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?