STM32F407上移植emwin
扫描二维码
随时随地手机看文章
环境:
主机:WIN8
开发环境:MDK5.13
emwin版本:STemWinLibrary522
mcu: stm32f407VGT6
开发板:安富莱STM32-X3
TFT型号:艾蓝2.8寸TFT,主控芯片:ILI9325
说明:
在STM32F407上移植emwin,驱动屏幕接口为FSMC
移植步骤:
1.MDK新建文件结构:
2.GUIConf.c文件修改
a)增加宏定义:
#defineGUI_NUMBYTES(1024*80)
#defineGUI_BLOCKSIZE0x80
b)GUI_X_Config(void)函数中增加语句:
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
这两个BANK宏定义在tft驱动文件中定义:
#defineBANK1_BASE((uint32_t)(0x60000000|0x00000000))
#defineBANK1_LCD_RAM*(__IOuint16_t*)(BANK1_BASE+(1<<(18+1)))/*FSMC16位总线模式下,FSMC_A18口线对应物理地址A19*/
#defineBANK1_LCD_REG*(__IOuint16_t*)(BANK1_BASE)
具体值和接线相关
b)具体函数修改
/*********************************************************************
*
*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函数说明:
因为主控芯片为ILI9325,所以参数选择GUIDRV_FLEXCOLOR_F66708
4.GUI_X.c文件修改
此文件控制的是GUI中的延时,可以用定时器配合实现,修改如下:
/*********************************************************************
*
*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;
}