STemWin移植过程
神舟III号开发板移植STemWin 5.22
(笔记)
llnid
一、学习心得
Stemwin的魅力你们都懂得 带主题风格皮肤比UCGUI漂亮
网上找了很多移植案例
失败过多次
最后看到帖子
http://blog.sina.com.cn/s/blog_6e230f020102v3aq.html
才发现 移植如此简单,
废话不多说
二、移植准备
我们首先需要去ST官网下载最新的STemWinLibrary522库文件。
官网地址:
http://www.st.com/web/en/catalog/tools/PF259225#。
下载完成后,放在你想放的任意盘符文件夹里。下载后解压如下图所示
三、移植开始
前期工作准备的要充分哦,不要偷懒,一步一步来。很快就成功率。
看完上面的准备工作,大家应该明白,我是利用ST现有的工程来一只的,是的,没错。
这样移植的失败率会大大减小。为什么这么做的?
首先,我们知道
STM32驱动彩屏大多数用的都是FSMC总线形式,当然我用的也不例外。
1、那就让我们迫不及待打开项目工程。修改程序吧!如下图所示
2、我可以说这就移植成功了吗!哈……反正已经完成80%啦,剩下的就是把你液晶屏的底层驱动换掉现在项目里驱动。如下图所示
3、修改成你液晶的ID号
4、修改你的分辨率
5、修改相关宏定义,主要用于屏类型选择和数据总线选择
上面都是借用上面链接红牛开发板的图片
如下加入自己神舟开发板移植的细节
要修改一下文件
MDK项目中
Libraries 目录下
Stm3210e_eval_lcd.c
Stm3210e_eval_lcd.h
STemWin_v522目录下
LDCConf_stm3210e_eval.c
========================================================================
Stm3210e_eval_lcd.c文件中
修改LCD ID号定义我 ssd1289 8989 改为如下
#define LCD_HX8347D 0x8989
修改下面LCD初始化代码 我的LCD驱动是SSD1289 ID8989
//void STM3210E_LCD_Init(void)
Delay可用范例库内函数
//=====================================================
void Delay(u32 nCount)
{
u32
timingDelay;
while(nCount--)
{
for(TimingDelay=0;TimingDelay<10000;TimingDelay++);
}
}
//=====================================================
void STM3210E_LCD_Init(void)
{
/* Configure the LCD Control pins */
LCD_CtrlLinesConfig();
/* Configure the FSMC arallel interface */
LCD_FSMCConfig();
/* delay 50 ms */
_delay_(5);
/* Read the LCD ID */
// LCD_ID = LCD_ReadReg(0x00);
/* Check if the LCD is HX8347D Controller */
// if(LCD_ID == LCD_HX8347D)
LCD_ID = LCD_ReadReg(0x0000);
Delay(5); /* delay 50 ms */
LCD_ID = LCD_ReadReg(0x0000);
if(LCD_ID==0x8989)
{
LCD_WriteReg(0x0000,0x0001); //?ò???§??
LCD_WriteReg(0x0010,0x0000);
Delay(5); // Wait 30ms
LCD_WriteReg(0x0007,0x0233);
LCD_WriteReg(0x0011,0x6078); //?¨?????????? 16???? ?á?? 0x6058
LCD_WriteReg(0x0002,0x0600);
LCD_WriteReg(0x0003,0xA8A4);//0x0804
LCD_WriteReg(0x000C,0x0000);
LCD_WriteReg(0x000D,0x080C);
LCD_WriteReg(0x000E,0x2900);
LCD_WriteReg(0x001E,0x00B8);
LCD_WriteReg(0x0001,0x293F);
LCD_WriteReg(0x0010,0x0000);
LCD_WriteReg(0x0005,0x0000);
LCD_WriteReg(0x0006,0x0000);
LCD_WriteReg(0x0016,0xEF1C);
LCD_WriteReg(0x0017,0x0003);
LCD_WriteReg(0x0007,0x0233); //0x0233
LCD_WriteReg(0x000B,0x0000|(3<<6));
LCD_WriteReg(0x000F,0x0000); //?¨?è???????·
LCD_WriteReg(0x0041,0x0000);
LCD_WriteReg(0x0042,0x0000);
LCD_WriteReg(0x0048,0x0000);
LCD_WriteReg(0x0049,0x013F);
LCD_WriteReg(0x004A,0x0000);
LCD_WriteReg(0x004B,0x0000);
LCD_WriteReg(0x0044,0xEF00);
LCD_WriteReg(0x0045,0x0000);
LCD_WriteReg(0x0046,0x013F);
LCD_WriteReg(0x0030,0x0707);
LCD_WriteReg(0x0031,0x0204);
LCD_WriteReg(0x0032,0x0204);
LCD_WriteReg(0x0033,0x0502);
LCD_WriteReg(0x0034,0x0507);
LCD_WriteReg(0x0035,0x0204);
LCD_WriteReg(0x0036,0x0204);
LCD_WriteReg(0x0037,0x0502);
LCD_WriteReg(0x003A,0x0302);
LCD_WriteReg(0x003B,0x0302);
LCD_WriteReg(0x0023,0x0000);
LCD_WriteReg(0x0024,0x0000);
LCD_WriteReg(0x0025,0x8000);
LCD_WriteReg(0x004e,0); //??(X)?×?·0
LCD_WriteReg(0x004f,0); //??(Y)?×?·0
}else
{
// printf("nr ###### Err: Unknow DeviceCode 0x%x ###### ", LCD_ID);
}
Lcd_Light_ON
Delay(1200);
LCD_SetFont(&LCD_DEFAULT_FONT);
}
==========================================================
/* Configure the LCD Control pins */
LCD_CtrlLinesConfig();
/* Configure the FSMC arallel interface */
LCD_FSMCConfig();
根据你的LCD板修改这两个函数
窝的神舟III号+3.2LCD SSD1289 ID8989
void LCD_CtrlLinesConfig(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
/* Enable FSMC, GPIOD, GPIOE, GPIOF, GPIOG and AFIO clocks */
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE |
RCC_APB2Periph_GPIOF | RCC_APB2Periph_GPIOG | RCC_APB2Periph_GPIOC |
RCC_APB2Periph_AFIO, ENABLE);
/* Set D.00(D2), D.01(D3), D.04(NOE), D.05(NWE), D.08(D13), D.09(D14),
D.10(D15), D.14(D0), PD.15(D1) as alternate
function push pull */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_4 | GPIO_Pin_5 |
GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_14 |
GPIO_Pin_15;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_Init(GPIOD, &GPIO_InitStructure);
/* Set PE.07(D4), PE.08(D5), PE.09(D6), PE.10(D7), PE.11(D8), PE.12(D9), PE.13(D10),
PE.14(D11), PE.15(D12) as alternate function push pull */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 |
GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 |
GPIO_Pin_15;
GPIO_Init(GPIOE, &GPIO_InitStructure);
/* Set PF.00(A0 (RS)) as alternate function push pull */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
GPIO_Init(GPIOF, &GPIO_InitStructure);
/* Set PG.12(NE4 (LCD/CS)) as alternate function push pull - CE3(LCD /CS) */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;
GPIO_Init(GPIOG, &GPIO_InitStructure);
/*FSMC A21??A22???????????ì????????*/
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5 | GPIO_Pin_6;
GPIO_Init(GPIOE, &GPIO_InitStructure);
/* Lcd_Light_Control */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOC, &GPIO_InitStructure);
//Lcd_Light_OFF
Lcd_Light_ON
/* LEDs pins configuration */
#if 1
/* Set PD7 to disable NAND */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOD, &GPIO_InitStructure);
GPIO_SetBits(GPIOD, GPIO_Pin_7);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9 | GPIO_Pin_10;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOG, &GPIO_InitStructure);
GPIO_SetBits(GPIOG, GPIO_Pin_9 | GPIO_Pin_10);
/* Set PC7 to disable NAND */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOC, &GPIO_InitStructure);
GPIO_SetBits(GPIOC, GPIO_Pin_7);
#endif
}
void LCD_FSMCConfig(void)
{
FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure;
FSMC_NORSRAMTimingInitTypeDef Timing_read, Timing_write;
/*-- FSMC Configuration ------------------------------------------------------*/
/*----------------------- SRAM Bank 4 ----------------------------------------*/
/* FSMC_Bank1_NORSRAM4 configuration */
Timing_read.FSMC_AddressSetupTime = 6;
Timing_read.FSMC_AddressHoldTime = 0;
Timing_read.FSMC_DataSetupTime = 6;
Timing_read.FSMC_BusTurnAroundDuration = 0;
Timing_read.FSMC_CLKDivision = 0;
Timing_read.FSMC_DataLatency = 0;
Timing_read.FSMC_AccessMode = FSMC_AccessMode_A;
Timing_write.FSMC_AddressSetupTime = 2;
Timing_write.FSMC_AddressHoldTime = 0;
Timing_write.FSMC_DataSetupTime = 2;
Timing_write.FSMC_BusTurnAroundDuration = 0;
Timing_write.FSMC_CLKDivision = 0;
Timing_write.FSMC_DataLatency = 0;
Timing_write.FSMC_AccessMode = FSMC_AccessMode_A;
/* Color LCD configuration ------------------------------------
LCD configured as follow:
- Data/Address MUX = Disable
- Memory Type = SRAM
- Data Width = 16bit
- Write Operation = Enable
- Extended Mode = Enable
- Asynchronous Wait = Disable */
FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM4;
FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable;
FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_SRAM;
FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b;
FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable;
FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable;
FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low;
FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable;
FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState;
FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable;
FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable;
FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable;
FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable;
FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &Timing_read;
FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &Timing_write;
FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure);
/* BANK 4 (of NOR/SRAM Bank 1~4) is enabled */
FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM4, ENABLE);
}
==============================================
Lcd_Light_ON
会报错
需要在Stm3210e_eval_lcd.h 头文件中加入
#define Lcd_Light_ON GPIO_SetBits(GPIOC, GPIO_Pin_7);
#define Lcd_Light_OFF GPIO_ResetBits(GPIOC, GPIO_Pin_7);
================================================
在LDCConf_stm3210e_eval.c 文件中
查找函数void LCD_X_Config(void)
这里要根据你的LCD 及5.22官方文档修改以下两行参数
pDevice = GUI_DEVICE_CreateAndLink(GUIDRV_FLEXCOLOR, GUICC_565, 0, 0);
GUIDRV_FlexColor_SetFunc(pDevice, &PortAPI, GUIDRV_FLEXCOLOR_F66702, GUIDRV_FLEXCOLOR_M16C0B16);
至此已完成90%
可以编译排错了
以上针对神舟3号+3.2tft 移植
文章至此
窝的Demo已显示,不过水平翻转的
就像在镜子后面看图像一样,郁闷
仅此记录
望对爱好者有用
触摸也未完成
哈哈
慢慢来吧。
F103ZE 带这个未优化的STM32F10E-EAVL 板的DEMO 稍稍有点吃力
估计SRAM 等参数没有设置好或者其他优化问题 在个别子demo中稍卡顿
额征程刚开始
有机会再分享