答应大家的教程有好几个了,今天有点空先补上一个,希望大家感兴趣
一、准备工作
1、开发板为坛子里搞活动试用的LM3S8962开发板,图片坛子里很多就不发了
2、2.8寸TFT彩屏,淘宝上选购的48元2.8寸带触摸(无山寨图标) TFT 液晶屏,个人感觉还是比较超值,显示效果很细腻,说是SONY手机的屏
http://item.taobao.com/item.htm?id=4896524706
3、排线或者杜邦线,看大家自己的爱好了,我接9B92开发板是用的排线,接8962用的杜邦线
二、电路连接示意图
三、移植驱动
我是在rdk-idm的6918开发板的代码上移植的,只需要修改drivers目录下的formike240x320x16_ili9320.c文件中的对应GPIO口定义即可
#define LCD_DATAH_BASE GPIO_PORTA_BASE
#define LCD_DATAL_BASE GPIO_PORTB_BASE
#define LCD_RST_BASE GPIO_PORTG_BASE
#define LCD_RST_PIN GPIO_PIN_0
#define LCD_RS_BASE GPIO_PORTC_BASE
#define LCD_RS_PIN GPIO_PIN_4
#define LCD_RD_BASE GPIO_PORTC_BASE
#define LCD_RD_PIN GPIO_PIN_5
#define LCD_WR_BASE GPIO_PORTC_BASE
#define LCD_WR_PIN GPIO_PIN_6
#define LCD_BL_BASE GPIO_PORTC_BASE
#define LCD_BL_PIN GPIO_PIN_7
主函数如下:
int
main(void)
{
tContext sContext;
tRectangle sRect;
unsigned long ulUser0, ulUser1, ulLastIPAddr, ulIPAddr;
unsigned char pucMACAddr[6];
char pcBuffer[32];
//
// 初始化时钟
//
SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_8MHZ);
SysTickPeriodSet(SysCtlClockGet() / TICKS_PER_SECOND);
SysTickEnable();
SysTickIntEnable();
IntMasterEnable();
//FlashUserGet(&ulUser0, &ulUser1);
pucMACAddr[0] = 0x01;
pucMACAddr[1] = 0x23;
pucMACAddr[2] = 0x45;
pucMACAddr[3] = 0x67;
pucMACAddr[4] = 0x89;
pucMACAddr[5] = 0xab;
//lwIPInit(pucMACAddr, 0, 0, 0, IPADDR_USE_DHCP);
lwIPInit(pucMACAddr, 0xc0a8010b, 0xffffff00, 0x00000000, IPADDR_USE_STATIC);
//LocatorInit();
//LocatorMACAddrSet(pucMACAddr);
//LocatorAppTitleSet("RDK-IDM hello");
//SoftwareUpdateInit(SoftwareUpdateRequestCallback);
//
// 初始化显示器驱动
//
Formike240x320x16_ILI9320Init();
//
// 打开背光
//
Formike240x320x16_ILI9320BacklightOn();
//
// 初始化显示器上下文
//
GrContextInit(&sContext, &g_sFormike240x320x16_ILI9320);
//
// 填充24行为蓝色
//
sRect.sXMin = 0;
sRect.sYMin = 0;
sRect.sXMax = GrContextDpyWidthGet(&sContext) - 1;
sRect.sYMax = 23;
GrContextForegroundSet(&sContext, ClrDarkBlue);
GrRectFill(&sContext, &sRect);
//
// 画白色边框
//
GrContextForegroundSet(&sContext, ClrWhite);
GrRectDraw(&sContext, &sRect);
//
// 显示用应用程序名称
//
GrContextFontSet(&sContext, &g_sFontCm20);
GrStringDrawCentered(&sContext, "hello", -1,
GrContextDpyWidthGet(&sContext) / 2, 11, 0);
//
// 显示 hello eeworld
//
GrContextFontSet(&sContext, &g_sFontCm40);
GrStringDrawCentered(&sContext, "Hello EEWorld!", -1,
GrContextDpyWidthGet(&sContext) / 2,
((GrContextDpyHeightGet(&sContext) - 24) / 2) + 24,
0);
//
// Display the MAC address (so that the user can perform a firmware update
// if required).
//
usprintf(pcBuffer,
"MAC: %02x-%02x-%02x-%02x-%02x-%02x",
pucMACAddr[0], pucMACAddr[1], pucMACAddr[2], pucMACAddr[3],
pucMACAddr[4], pucMACAddr[5]);
GrContextFontSet(&sContext, &g_sFontCm20);
GrStringDrawCentered(&sContext, pcBuffer, -1,
GrContextDpyWidthGet(&sContext) / 2,
GrContextDpyHeightGet(&sContext) - 20, 0);
//
// Flush any cached drawing operations.
//
GrFlush(&sContext);
//
// Assume we don't have an IP address yet.
//
ulLastIPAddr = 0;
//
// Loop until someone requests a remote firmware update. Inside the loop,
// we check the IP address and update the display. This information is
// needed to allow someone to configure the LMFlash application to update
// the board but the IP address is likely not available by the time we
// get here initially.
//
while(!g_bFirmwareUpdate)
{
//
// What is our current IP address?
//
ulIPAddr = lwIPLocalIPAddrGet();
//
// If it changed, update the display.
//
if(ulIPAddr != ulLastIPAddr)
{
ulLastIPAddr = ulIPAddr;
usprintf(pcBuffer, "IP: %d.%d.%d.%d",
ulIPAddr & 0xff, (ulIPAddr >> 8) & 0xff,
(ulIPAddr >> 16) & 0xff, ulIPAddr >> 24);
GrStringDrawCentered(&sContext, pcBuffer, -1,
GrContextDpyWidthGet(&sContext) / 2,
GrContextDpyHeightGet(&sContext) - 40, 0);
}
}
//
// If we drop out, a remote firmware update request has been received.
//
//
// Tell the user what's up
//
GrContextFontSet(&sContext, &g_sFontCm40);
GrStringDrawCentered(&sContext, " Updating... ", -1,
GrContextDpyWidthGet(&sContext) / 2,
((GrContextDpyHeightGet(&sContext) - 24) / 2) + 24,
true);
//
// Transfer control to the bootloader.
//
//SoftwareUpdateBegin();
//
// The boot loader should take control, so this should never be reached.
// Just in case, loop forever.
//
while(1)
{
}
}
完整工程代码如下:
显示效果如下:
[ 本帖最后由 fengzhang2002 于 2011-1-9 15:07 编辑 ]