STM32F407+STemwin学习笔记之STemwin移植
原文链接: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移植的更多相关文章
- STM32F407+STemwin学习笔记之STemwin移植补充Touch
原文地址:http://www.cnblogs.com/NickQ/p/8857213.html 环境:keil5.20 STM32F407ZGT6 LCD(320*240) STemwin:S ...
- LwIP学习笔记——STM32 ENC28J60移植与入门
0.前言 去年(2013年)的整理了LwIP相关代码,并在STM32上"裸奔"成功.一直没有时间深入整理,在这里借博文整理总结.LwIP的移植过程细节很多,博文也不可能一一 ...
- AM335x(TQ335x)学习笔记——u-boot-2014.10移植
根据最近移植u-boot-2014.10至TQ335x,基于这样的假设am335x evm移植.不是很多地方需要改变. 因为TI的am335x evm开发了使用eeprom船上保存配置信息.它使用不同 ...
- AM335x(TQ335x)学习笔记——USB驱动移植
对于AM335x来讲,TI维护的USB驱动已经非常完善了,本文称之为移植,实际上仅仅是配置内核选项使能USB HOST/OTG功能.废话少说,直接动手开启AM335x的USB驱动配置项. Step1. ...
- AM335x(TQ335x)学习笔记——LCD驱动移植
TI的LCD控制器驱动是非常完善的,共通的地方已经由驱动封装好了,与按键一样,我们可以通过DTS配置完成LCD的显示.下面,我们来讨论下使用DTS方式配置内核完成LCD驱动的思路. (1)初步分析 由 ...
- ucos实时操作系统学习笔记——操作系统在STM32的移植
使用ucos实时操作系统是在上学的时候,导师科研项目中.那时候就是网上找到操作系统移植教程以及应用教程依葫芦画瓢,功能实现也就罢了,没有很深入的去研究过这个东西.后来工作了,闲来无聊就研究了一下这个只 ...
- jz2440-linux3.4.2-kernel移植【学习笔记】【原创】
平台:jz2440 作者:庄泽彬(欢迎转载,请注明作者) 说明:韦东山二期视频学习笔记 交叉编译工具:arm-linux-gcc (GCC)4.3.2 linux:linu3.4.2 PC环境:ubu ...
- jz2440-uboot-201204版本移植【学习笔记】【原创】
平台:jz2440 作者:庄泽彬(欢迎转载,请注明作者) 说明:韦东山二期视频学习笔记 交叉编译工具:arm-linux-gcc (GCC)4.3.2 PC环境:ubuntu18.04 一.uboot ...
- 移植madplay到jz2440【学习笔记】
平台:jz2440 作者:庄泽彬(欢迎转载,请注明作者) 说明:韦东山一期视频学习笔记 交叉编译工具:arm-linux-gcc (GCC) 3.4.5 PC环境:ubuntu16.04 一.移植ma ...
随机推荐
- 网络安全-使用HTTP动词篡改的认证旁路
这个东西去年的安全扫描都没有,今天就扫出来了,非常奇怪的一个东西.好吧,找资料找原因.结果可能应为搜索名词的原因,这个问题在群友的帮助下解决了. 在我理解中servlet只有post和get方法,然后 ...
- .net通过代码发送邮件
关键代码: 需要引用命名空间: using System.Net.Mail;using System.Net; MailMessage mailObj = new MailMessage(); mai ...
- 使用GDI技术创建ASP.NET验证码
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Dr ...
- 7za 命令解析
转载自:blog.chinaunix.net/uid-26330274-id-3055157.html 7za 命令讲的很详细,收藏下来. 命令行压缩解压一 7z 1) 简介 7z,全称7-Zip ...
- React v15.5.0更新说明 & v16.0.0更新预告
React今日发布了15.5.0版本,同时这也将是以15开头的最后一个版本,下一次发布,我们将迎来React 16.0.0 在15.5.0这一版本中,主要有以下两处改动: 独立React.PropTy ...
- JavaScript的DOM_操作内容
一.innerText 属性 <script type="text/javascript"> window.onload = function(){ var box = ...
- reactnative调研
/** * This function parses the exported methods inside RCTBridgeModules and * generates an array ...
- luogu P2617 Dynamic Rankings(分块,n <= 1e4)
嘟嘟嘟 带修改区间第k大. 然而某谷把数据扩大到了1e5,所以用分块现在只能得50分. 分块怎么做呢?很暴力的. 基本思想还是块内有序,块外暴力统计. 对于修改,直接重排修改的数所在块,时间复杂度O( ...
- jquery分页例子
先看效果图: 实现原理很简单,使用了jquery.pagination这个插件,每当点击页码时异步去服务器去取该页的数据,简单介绍如下: 一.数据库表结构:很简单 就四个字段 分别是News_id ...
- Kernel Ridge Regression
回顾一下岭回归,岭回归的目的是学习得到特征和因变量之间的映射关系,由于特征可能很高维,所以需要正则化 岭回归的目标函数是 $$ \sum_{i=1}^n \left\|y-X\beta\right\| ...