Oliver_CHENG 发表于 2016-8-19 06:31 PM

【NUCLEO-F767ZI】移植EMWIN

前面讲了怎么用FMC来驱动TFT现在来记录一下自己移植EMWIN的过程<br />
先去ST官网下载STemwin的库文件,或者在cube里面也有<br />
路径:<br />

<ignore_js_op>



</ignore_js_op>
<br />
文件说明:<br />

<ignore_js_op>



</ignore_js_op>
<br />
然后在添加到工程文件里<br />
创建一个三个文件夹 emwin_lib emwin_config emwin_inc<br />
emwin_config 里面添加的是:<br />

<ignore_js_op>



</ignore_js_op>
<br />
emiwn_lib 里面添加的是:
<ignore_js_op>



</ignore_js_op>
<br />
<font size="3"><font style="color:rgb(51, 51, 51)"><font face="Arial"><font face="微软雅黑">这两种库</font></font></font></font><font size="3"><font style="color:rgb(51, 51, 51)"><font face="Arial"><font face="微软雅黑">STemWin528_CM7_Keil_ot.lib和STemWin528_CM7_Keil.lib是</font></font></font></font><font size="3"><font style="color:rgb(51, 51, 51)"><font face="Arial"><font face="微软雅黑">有区别的,</font></font></font></font><br />
<font size="3"><font style="color:rgb(51, 51, 51)"><font face="Arial"><font face="微软雅黑">带上字母ot的是表示做了优化 ot 表示高速优化</font></font></font></font><br />
<br />
emwin_inc里面添加的是直接把官方库里面的inc的所有点H文件复制过来。<br />
然后再工程中添加进去:<br />

<ignore_js_op>



</ignore_js_op>
<br />
<br />
<br />
<br />
然后在把头文件路径添加进去。<br />
创建一个LCDConfig.h的空文件。<br />
然后修改 GUIConfig.h文件这个文件件 定义了我们是否使用操作系统 鼠标 窗口管理等信息<br />
代码:<br />
#define GUI_NUM_LAYERS&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;1&nbsp; &nbsp; // Maximum number of available layers<br />
#define GUI_OS&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; (0)<br />
#define GUI_SUPPORT_TOUCH&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;(0)&nbsp;&nbsp;// Support touchscreen<br />
<br />
#define GUI_DEFAULT_FONT&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &amp;GUI_Font6x8<br />
typedef struct GUI_FONT GUI_FONT ;<br />
extern const&nbsp;&nbsp;GUI_FONT asc2_2412;<br />
#define GUI_SUPPORT_MOUSE&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; (1)&nbsp; &nbsp; <br />
#define GUI_WINSUPPORT&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; (1)&nbsp;&nbsp;<br />
#define GUI_SUPPORT_MEMDEV&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;(1)&nbsp; &nbsp;<br />
#define GUI_SUPPORT_DEVICES&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;(1)&nbsp;&nbsp;<br />
<br />
然后去修改GUIConfig.c文件这个文件定义了GUI所使用的内存<br />
代码:<br />
#define GUI_NUMBYTES&nbsp;&nbsp;( 110* 1024 )<br />
U32 aMemory __attribute__ ((section (&quot;GUI_RAM&quot;), zero_init));<br />
<br />
//GUI_X_Config<br />
//初始化的时候调用,用来设置emwin所使用的内存<br />
void GUI_X_Config(void) {<br />
&nbsp;&nbsp;GUI_ALLOC_AssignMemory(aMemory, GUI_NUMBYTES);<br />
}<br />
<br />
然后去配置:GUIDRV_Template.c文件:调用前面LCD驱动中写好的打点 读点 填充 函数 和 16BPP的显示<br />
在这个文件里面还有个函数 32<font style="font-size:14px">BPP的显示的函数(</font><font face="Verdana"><font color="#333333"><font style="background-color:rgb(243, 255, 236)">32bpp实际也只是24bpp,它是为了让每个象素都占据独立的32位双字,以对齐象素边界,加速处理速度)</font></font></font><br />
因为屏幕是16位的所以是RGB565的 <br />
网上也发现有篇讲解16位转24位的教程<br />
<font style="font-size:14px">16BPP与24BPP的相互转换:</font>http://blog.csdn.net/liushaowei2008/article/details/7858949<br />
下面就是修改代码:<br />
修改四个函数:_SetPixelIndex()(调用快速打点函数) _GetPixelIndex()(读点函数) _FillRext()(填充函数) _DrawBitLine16BPP()(16BPP写16位的数据)<br />
然后去配置LCDConfig_FlexColor_Template.c<br />
其他删除用不到<br />
//配置程序,用于创建显示驱动器件,设置颜色转换程序和显示尺寸<br />
void LCD_X_Config(void) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; GUI_DEVICE_CreateAndLink(&amp;GUIDRV_Template_API,GUICC_M565,0,0); //创建显示驱动器件<br />
&nbsp; &nbsp; &nbsp; &nbsp; LCD_SetSizeEx(0,lcddev.width,lcddev.height);<br />
&nbsp; &nbsp; &nbsp; &nbsp; LCD_SetVSizeEx(0,lcddev.width,lcddev.height);<br />
}<br />
<br />
//显示器驱动的回调函数<br />
int LCD_X_DisplayDriver(unsigned LayerIndex, unsigned Cmd, void * pData) {<br />
&nbsp;&nbsp;int r;<br />
&nbsp;&nbsp;(void) LayerIndex;<br />
&nbsp;&nbsp;(void) pData;<br />
<br />
&nbsp;&nbsp;switch (Cmd) {<br />
&nbsp;&nbsp;case LCD_X_INITCONTROLLER: {<br />
&nbsp; &nbsp; &nbsp; &nbsp; //当初始化的时候被调用,主要是设置显示控制器,如果显示控制器在外部初始化则需要用户初始化<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; //&nbsp; &nbsp; &nbsp; &nbsp; TFTLCD_Init(); //初始化LCD 已经在开始初始化了,所以此处不需要初始化。<br />
&nbsp; &nbsp; return 0;<br />
&nbsp;&nbsp;}<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; default:<br />
&nbsp; &nbsp; r = -1;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp;&nbsp;return r;<br />
}<br />
<br />
移植完成。<br />
下面附上我的代码:<br />

stm32f767标准工程.part01.rar
<br />

stm32f767标准工程.part02.rar
<br />

stm32f767标准工程.part03.rar
<br />

stm32f767标准工程.part04.rar
<br />

stm32f767标准工程.part05.rar
<br />

stm32f767标准工程.part06.rar
<br />

stm32f767标准工程.part07.rar
<br />

stm32f767标准工程.part08.rar
<br />
</td></tr>
页: [1]
查看完整版本: 【NUCLEO-F767ZI】移植EMWIN