STM32F407上移植emwin
環(huán)境:
主機(jī):WIN8
開(kāi)發(fā)環(huán)境:MDK5.13
emwin版本:STemWinLibrary522
mcu: stm32f407VGT6
開(kāi)發(fā)板:安富萊STM32-X3
TFT型號(hào):艾藍(lán)2.8寸TFT,主控芯片:ILI9325
說(shuō)明:
在STM32F407上移植emwin,驅(qū)動(dòng)屏幕接口為FSMC
移植步驟:
1.MDK新建文件結(jié)構(gòu):
2.GUIConf.c文件修改
a)增加宏定義:
#defineGUI_NUMBYTES(1024*80)
#defineGUI_BLOCKSIZE0x80
b)GUI_X_Config(void)函數(shù)中增加語(yǔ)句:
GUI_ALLOC_SetAvBlockSize(GUI_BLOCKSIZE);
修改后:
/*********************************************************************
*
*GUI_X_Config
*
*Purpose:
*Calledduringtheinitializationprocessinordertosetupthe
*availablememoryfortheGUI.
*/
voidGUI_X_Config(void){
//
//32bitalignedmemoryarea
//
staticU32aMemory[GUI_NUMBYTES/4];
//
//AssignmemorytoemWin
//
GUI_ALLOC_AssignMemory(aMemory,GUI_NUMBYTES);
GUI_ALLOC_SetAvBlockSize(GUI_BLOCKSIZE);
//
//Setdefaultfont
//
GUI_SetDefaultFont(GUI_FONT_6X8);
}
3.LCDConf_FlexColor_Template.c文件修改
a)增加宏定義:
#defineLCD_REG_ADDRESSBANK1_LCD_REG
#defineLCD_DATA_ADDRESSBANK1_LCD_RAM
這兩個(gè)BANK宏定義在tft驅(qū)動(dòng)文件中定義:
#defineBANK1_BASE((uint32_t)(0x60000000|0x00000000))
#defineBANK1_LCD_RAM*(__IOuint16_t*)(BANK1_BASE+(1<<(18+1)))/*FSMC16位總線模式下,F(xiàn)SMC_A18口線對(duì)應(yīng)物理地址A19*/
#defineBANK1_LCD_REG*(__IOuint16_t*)(BANK1_BASE)
具體值和接線相關(guān)
b)具體函數(shù)修改
/*********************************************************************
*
*Localfunctions
*
**********************************************************************
*/
/********************************************************************
*
*LcdWriteReg
*
*Functiondescription:
*Setsdisplayregister
*/
staticvoidLcdWriteReg(U16Data){
//...TBDbyuser
LCD_REG_ADDRESS=Data;
}
/********************************************************************
*
*LcdWriteData
*
*Functiondescription:
*Writesavaluetoadisplayregister
*/
staticvoidLcdWriteData(U16Data){
//...TBDbyuser
LCD_DATA_ADDRESS=Data;
}
/********************************************************************
*
*LcdWriteDataMultiple
*
*Functiondescription:
*Writesmultiplevaluestoadisplayregister.
*/
staticvoidLcdWriteDataMultiple(U16*pData,intNumItems){
while(NumItems--){
//...TBDbyuser
LCD_DATA_ADDRESS=*pData++;
}
}
/********************************************************************
*
*LcdReadDataMultiple
*
*Functiondescription:
*Readsmultiplevaluesfromadisplayregister.
*/
staticvoidLcdReadDataMultiple(U16*pData,intNumItems){
while(NumItems--){
//...TBDbyuser
*pData++=LCD_DATA_ADDRESS;
}
}
/*********************************************************************
*
*Publicfunctions
*
**********************************************************************
*/
/*********************************************************************
*
*LCD_X_Config
*
*Functiondescription:
*Calledduringtheinitializationprocessinordertosetupthe
*displaydriverconfiguration.
*
*/
voidLCD_X_Config(void){
GUI_DEVICE*pDevice;
CONFIG_FLEXCOLORConfig={0};
GUI_PORT_APIPortAPI={0};
//
//Setdisplaydriverandcolorconversion
//
pDevice=GUI_DEVICE_CreateAndLink(GUIDRV_FLEXCOLOR,GUICC_565,0,0);
//
//Displaydriverconfiguration,requiredforLin-driver
//
LCD_SetSizeEx(0,XSIZE_PHYS,YSIZE_PHYS);
LCD_SetVSizeEx(0,VXSIZE_PHYS,VYSIZE_PHYS);
//
//Orientation
//
//Config.Orientation=GUI_SWAP_XY|GUI_MIRROR_Y;
Config.FirstCOM=0;
Config.FirstSEG=0;
//Config.Orientation=GUI_MIRROR_X|GUI_MIRROR_Y;
Config.NumDummyReads=2;
GUIDRV_FlexColor_Config(pDevice,&Config);
//
//Setcontrollerandoperationmode
//
PortAPI.pfWrite16_A0=LcdWriteReg;
PortAPI.pfWrite16_A1=LcdWriteData;
PortAPI.pfWriteM16_A1=LcdWriteDataMultiple;
PortAPI.pfReadM16_A1=LcdReadDataMultiple;
GUIDRV_FlexColor_SetFunc(pDevice,&PortAPI,GUIDRV_FLEXCOLOR_F66708,GUIDRV_FLEXCOLOR_M16C0B16);
//GUIDRV_FlexColor_SetFunc(pDevice,&PortAPI,GUIDRV_FLEXCOLOR_F66709,GUIDRV_FLEXCOLOR_M16C0B16);
}
其中:GUIDRV_FlexColor_SetFunc函數(shù)說(shuō)明:
因?yàn)橹骺匦酒瑸镮LI9325,所以參數(shù)選擇GUIDRV_FLEXCOLOR_F66708
4.GUI_X.c文件修改
此文件控制的是GUI中的延時(shí),可以用定時(shí)器配合實(shí)現(xiàn),修改如下:
/*********************************************************************
*
*Globaldata
*/
volatileGUI_TIMER_TIMEOS_TimeMS;
/*********************************************************************
*
*Timing:
*GUI_X_GetTime()
*GUI_X_Delay(int)
SometimingdependentroutinesrequireaGetTime
anddelayfunction.Defaulttimeunit(tick),normallyis
1ms.
*/
extern__IOint32_tg_iRunTime;
GUI_TIMER_TIMEGUI_X_GetTime(void){
//returnOS_TimeMS;
returng_iRunTime;
}