原文链接:http://www.cnblogs.com/NickQ/p/8748011.html

环境:keil5.20  STM32F407ZGT6  LCD(320*240)  STemwin:STemWin_Library_V1.1.2

准备:

STemWIn在裸机上的移植,需要准备STemwin的库( STemwin:STemWin_Library_V1.1.2.rar  链接:https://pan.baidu.com/s/1ekMm-X7RG5JK185GnV9fFw

提取码:peup ),LCD的空工程(带有LCD画点,读点函数)。

开始移植

第一步:解压STemWin_Library_V1.1.2.rar,目录结构如下

打开目录STemWin_Library_V1.1.2\Libraries\STemWinLibrary522,复制Config,inc,OS,LIB四个目录到工程文件夹中

删除Config中LCDConf_Lin_Template.c,LCDConf_Lin_Template.h文件。

根据需要保留LIB中文件,删除其他文件。此处使用CM4内核的F407,Keil IDE,保留STemWin522_CM4_Keil.lib。

根据是否使用OS,保留OS文件夹中相应文件。此处不使用OS,保留GUI_X.c。

将留下的文件添加进工程,并包含头文件路径。

留下的文件如图所示。

第二步,修改部分文件,

修改GUIConf.c   修改分配给GUI的内存大小,此处为16K

 // Define the available number of bytes available for the GUI
#define GUI_NUMBYTES 0x4000 //16KB 2018/04/15-17:52:54 By Nick

修改GUIConf.h   配置GUI相关功能

 #ifndef GUICONF_H
#define GUICONF_H //Multi layer/display support
#define GUI_NUM_LAYERS 2 // Maximum number of available layers //Multi tasking support
#ifdef OS_SUPPORT
#define GUI_OS (1) // Compile with multitasking support
#else
#define GUI_OS (0)
#endif //Configuration of touch suppor
#ifndef GUI_SUPPORT_TOUCH
#define GUI_SUPPORT_TOUCH (1) // Support touchscreen
#endif //Default font
#define GUI_DEFAULT_FONT &GUI_Font6x8 //Configuration of available packages
#define GUI_SUPPORT_MOUSE (1) /* Support a mouse */
#define GUI_WINSUPPORT (1) /* Use window manager */
#define GUI_SUPPORT_MEMDEV (1) /* Memory device package available */
#define GUI_SUPPORT_DEVICES (1) /* Enable use of device pointers */ #endif /* Avoid multiple inclusion */

修改GUIDRV_Template.c   修改画点和读点函数,注意要引入自己的LCD头文件

 /*********************************************************************
*
* _SetPixelIndex
*
* Purpose:
* Sets the index of the given pixel. The upper layers
* calling this routine make sure that the coordinates are in range, so
* that no check on the parameters needs to be performed.
*/
static void _SetPixelIndex(GUI_DEVICE * pDevice, int x, int y, int PixelIndex) {
//
// Convert logical into physical coordinates (Dep. on LCDConf.h)
//
#if (LCD_MIRROR_X == 1) || (LCD_MIRROR_Y == 1) || (LCD_SWAP_XY == 1)
int xPhys, yPhys; xPhys = LOG2PHYS_X(x, y);
yPhys = LOG2PHYS_Y(x, y);
#else
#define xPhys x
#define yPhys y
#endif
GUI_USE_PARA(pDevice);
GUI_USE_PARA(x);
GUI_USE_PARA(y);
GUI_USE_PARA(PixelIndex);
{
lcd_drawpoint(xPhys,yPhys,PixelIndex); //2018/04/15-18:47:44 By Nick
}
#if (LCD_MIRROR_X == 0) && (LCD_MIRROR_Y == 0) && (LCD_SWAP_XY == 0)
#undef xPhys
#undef yPhys
#endif
} /*********************************************************************
*
* _GetPixelIndex
*
* Purpose:
* Returns the index of the given pixel. The upper layers
* calling this routine make sure that the coordinates are in range, so
* that no check on the parameters needs to be performed.
*/
static unsigned int _GetPixelIndex(GUI_DEVICE * pDevice, int x, int y) {
unsigned int PixelIndex;
//
// Convert logical into physical coordinates (Dep. on LCDConf.h)
//
#if (LCD_MIRROR_X == 1) || (LCD_MIRROR_Y == 1) || (LCD_SWAP_XY == 1)
int xPhys, yPhys; xPhys = LOG2PHYS_X(x, y);
yPhys = LOG2PHYS_Y(x, y);
#else
#define xPhys x
#define yPhys y
#endif
GUI_USE_PARA(pDevice);
GUI_USE_PARA(x);
GUI_USE_PARA(y);
{
PixelIndex = lcd_read_gram(xPhys,yPhys); //2018/04/15-18:47:29 By Nick
}
#if (LCD_MIRROR_X == 0) && (LCD_MIRROR_Y == 0) && (LCD_SWAP_XY == 0)
#undef xPhys
#undef yPhys
#endif
return PixelIndex;
}

修改 GUIDRV_FlexColor.c文件  配置屏幕尺寸(此处为320*240),可以用宏,Nick在此不用宏的原因是方便LCD初始化函数自动识别屏幕后,传递给GUI

 #include "Nick_lcd.h"
#include "GUI.h"
#include "GUIDRV_FlexColor.h" u16 XSIZE_PHYS,YSIZE_PHYS,VXSIZE_PHYS,VYSIZE_PHYS; //2018/04/15-18:48:10 By Nick #ifndef GUICC_565
#error Color conversion not defined!
#endif
#ifndef GUIDRV_FLEXCOLOR
#error No display driver defined!
#endif void LCD_X_Config(void) { //2018/04/15-18:48:24 By Nick
// Physical display size
XSIZE_PHYS = lcddev.width;// To be adapted to x-screen size 240
YSIZE_PHYS = lcddev.height; // To be adapted to y-screen size 320
VXSIZE_PHYS = XSIZE_PHYS;
VYSIZE_PHYS = YSIZE_PHYS;
GUI_DEVICE_CreateAndLink(&GUIDRV_Template_API,GUICC_M565,,);
LCD_SetSizeEx(,XSIZE_PHYS,YSIZE_PHYS);
LCD_SetVSizeEx(,VXSIZE_PHYS,VYSIZE_PHYS);
} int LCD_X_DisplayDriver(unsigned LayerIndex, unsigned Cmd, void * pData) {
int r;
(void) LayerIndex;
(void) pData; switch (Cmd) {
case LCD_X_INITCONTROLLER: {
return ;
}
default:
r = -;
}
return r;
}

在此,修改已完成。

第三步,编写测试程序。

#include "stm32f4xx_conf.h"
#include "GUI.h"
#include "Nick_lcd.h" int main(void)
{
lcd_init(); //LCD初始化
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_CRC,ENABLE);//使能CRC时钟,否则STemWin不能使用
GUI_Init(); GUI_SetColor(GUI_RED);
GUI_SetBkColor(GUI_BLUE);
GUI_SetFont(&GUI_Font24_ASCII);
GUI_Clear();
GUI_DispStringAt("Hello World",,);
}

到此可以看到现象。如图

当然,到此STemwin移植就结束了。下一篇将添加触摸屏点击功能。

STM32F407+STemwin学习笔记之STemwin移植的更多相关文章

  1. STM32F407+STemwin学习笔记之STemwin移植补充Touch

    原文地址:http://www.cnblogs.com/NickQ/p/8857213.html 环境:keil5.20  STM32F407ZGT6  LCD(320*240)  STemwin:S ...

  2. LwIP学习笔记——STM32 ENC28J60移植与入门

    0.前言     去年(2013年)的整理了LwIP相关代码,并在STM32上"裸奔"成功.一直没有时间深入整理,在这里借博文整理总结.LwIP的移植过程细节很多,博文也不可能一一 ...

  3. AM335x(TQ335x)学习笔记——u-boot-2014.10移植

    根据最近移植u-boot-2014.10至TQ335x,基于这样的假设am335x evm移植.不是很多地方需要改变. 因为TI的am335x evm开发了使用eeprom船上保存配置信息.它使用不同 ...

  4. AM335x(TQ335x)学习笔记——USB驱动移植

    对于AM335x来讲,TI维护的USB驱动已经非常完善了,本文称之为移植,实际上仅仅是配置内核选项使能USB HOST/OTG功能.废话少说,直接动手开启AM335x的USB驱动配置项. Step1. ...

  5. AM335x(TQ335x)学习笔记——LCD驱动移植

    TI的LCD控制器驱动是非常完善的,共通的地方已经由驱动封装好了,与按键一样,我们可以通过DTS配置完成LCD的显示.下面,我们来讨论下使用DTS方式配置内核完成LCD驱动的思路. (1)初步分析 由 ...

  6. ucos实时操作系统学习笔记——操作系统在STM32的移植

    使用ucos实时操作系统是在上学的时候,导师科研项目中.那时候就是网上找到操作系统移植教程以及应用教程依葫芦画瓢,功能实现也就罢了,没有很深入的去研究过这个东西.后来工作了,闲来无聊就研究了一下这个只 ...

  7. jz2440-linux3.4.2-kernel移植【学习笔记】【原创】

    平台:jz2440 作者:庄泽彬(欢迎转载,请注明作者) 说明:韦东山二期视频学习笔记 交叉编译工具:arm-linux-gcc (GCC)4.3.2 linux:linu3.4.2 PC环境:ubu ...

  8. jz2440-uboot-201204版本移植【学习笔记】【原创】

    平台:jz2440 作者:庄泽彬(欢迎转载,请注明作者) 说明:韦东山二期视频学习笔记 交叉编译工具:arm-linux-gcc (GCC)4.3.2 PC环境:ubuntu18.04 一.uboot ...

  9. 移植madplay到jz2440【学习笔记】

    平台:jz2440 作者:庄泽彬(欢迎转载,请注明作者) 说明:韦东山一期视频学习笔记 交叉编译工具:arm-linux-gcc (GCC) 3.4.5 PC环境:ubuntu16.04 一.移植ma ...

随机推荐

  1. 安装或删除Skype for business server组件的时候,报错"错误: 找不到 SQL 服务"

    安装或删除Skype for business server组件的时候,到了安装所有并置数据库的时候,报错“错误: 找不到 SQL 服务.确保计算机 skype.centos.com 中安装了 SQL ...

  2. Maven学习总结(一)——pom.xml文件配置详解

    <build>标签:<plugins>给出构建过程中所用到的插件 <plugins> <plugin> <groupId>org.apach ...

  3. Intellij idea 一次性包导入

    Intellij idea中优化包导入用的快捷键是 ctrl + alt + o,但是如果需要一次性优化自动导入包,可以按照如下配置

  4. July 19th 2017 Week 29th Wednesday

    Rather than envy others, it is better to speed up their own pace. 与其羡慕他人,不如加快自己的脚步. The envy of othe ...

  5. MVC 接收参数时会自动解码

    MVC在接收传递过来的参数时,会自动对参数进行解码,无需手动解码 例: public ActionResult SendMsg2(string name) { return Content(name) ...

  6. AngularJs学习笔记--Modules

    原版地址:http://code.angularjs.org/1.0.2/docs/guide/module 一.什么是Module? 很多应用都有一个用于初始化.加载(wires是这个意思吗?)和启 ...

  7. MyBatis动态sql语句归纳

    1.删除数据(假删除)并修改时间 <!--根据id删除学生信息(多条)--> <update id="updateStuStatus" parameterType ...

  8. Axure RP 8 学习记录

    一.Axure RP 简介 Axure是一个专业的快速原型设计工具.能够快速创建应用软件或Web网站的线框图.流程图.原型和规格说明文档. 二.Axure RP下载 1.下载安装包 https://w ...

  9. 关于WEB的URL安全测试

    测试思路: 对WEB做个简单的安全测试,主要是针对URL的测试. 回想起来,这次测试本质可以归为“权限”的测试,如下: 案例1: 1.分别开两个浏览器,以两个不同的帐号登陆web后台 2.第一个浏览器 ...

  10. 转-四种方案解决ScrollView嵌套ListView问题

    本人网上用的ID是泡面或安卓泡面,学习一年半之前开始从事Android应用开发,这是我写的第一篇Android技术文章,转载请注明出处和作者,有写的不好的地方还请帮忙指出,谢谢. 在工作中,曾多次碰到 ...