本帖最后由 wenyangzeng 于 2016-1-14 13:29 编辑
GD32F207移植STemWin 这个GD32F207移植STemWin的结果不是很成功,但是还是有必要将移植过程与各位分享。 使用FSMC模式驱动TFT-SSD1289,硬件的连接和编程请参阅: 试过几种编译环境,只有采用STM32CUbeMX在MDK5下能勉强运行。 代码中如果有“LCD.h”、”LCD.C”、“GUI.H”同名的文件必须另起新文件名。 STM32CUbeMX的配置中选择STM32F103ZET6,需要配置的选项有”SYS”、”CRC”、“FSMC”和“RCC”,见下图: 要注意那个CRC是必须的。
项目中芯片型号则选择GD32F207ZE,还要添加STemWinLibrary5.22库、GUIConfig.C、LCDConf_FiexColor_Template.C、GUI_X.C,GUIDEMO.C。
Options-Debug选项:
Driver Setup选项:
- 主函数:
- #include "stm32f1xx_hal.h"
- #include "SSD1289_lcd.h"
- #include "crc.h"
- #include "gpio.h"
- #include "fsmc.h"
- include "GUI.h"
- #include "GUIDEMO.h"
- #include "GUI_Type.h"
- void SystemClock_Config(void);
- extern __IO int32_t OS_TimeMS;
- int main(void)
- { HAL_Init();
- SystemClock_Config();
- MX_GPIO_Init();
- MX_CRC_Init(); //这个CRC是必须要的
- MX_FSMC_Init();
- STM3210E_LCD_Init();
- WM_SetCreateFlags(WM_CF_MEMDEV);
- GUI_Init();
- GUIDEMO_Main();
- }
- void SystemClock_Config(void)
- { RCC_OscInitTypeDef RCC_OscInitStruct;
- RCC_ClkInitTypeDef RCC_ClkInitStruct;
- RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
- RCC_OscInitStruct.HSEState = RCC_HSE_ON;
- RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
- HAL_RCC_OscConfig(&RCC_OscInitStruct);
- RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK;
- RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSE;
- RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV16;
- RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
- RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV4;
- HAL_RCC_ClockConfig(&RCC_ClkInitStruct,FLASH_LATENCY_0);
- HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/200);
- HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);
- HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);
- }
- //GUIConf.C的修改:
- #define GUI_NUMBYTES 1024*50
- //LCDConf_FlexColor_Template.c的修改:
- include "stm32f1xx.h"
- #include "SSD1289_lcd.h"
- typedef struct
- {
- __IO uint16_t LCD_REG;
- __IO uint16_t LCD_RAM;
- } LCD_TypeDef;
- #define LCD_BASE ((uint32_t)(0x60000000 |0x0C000000))
- #define LCD ((LCD_TypeDef *) LCD_BASE)
- static void LcdWriteReg(U16 Data) {
- __nop();__nop();
- LCD->LCD_REG = Data;
- }
- static void LcdWriteData(U16 Data) {
- __nop();__nop();
- LCD->LCD_RAM =Data;</font>
- }
- static void LcdWriteDataMultiple(U16 *pData, int NumItems) {
- while (NumItems--) {
- __nop();__nop();
- LCD->LCD_RAM = *pData++;</font>
- }
- }
- static void LcdReadDataMultiple(U16 *pData, int NumItems) {
- *pData=LCD->LCD_RAM ;
- while (NumItems--) {
- __nop();__nop();
- *pData++=LCD->LCD_RAM ;
- }
- }
- void LCD_X_Config(void) {
- GUI_DEVICE * pDevice;
- CONFIG_FLEXCOLOR Config = {0};
- GUI_PORT_API PortAPI = {0};
- pDevice = GUI_DEVICE_CreateAndLink(GUIDRV_FLEXCOLOR, GUICC_<font color="red">M</font>565, 0, 0);
- LCD_SetSizeEx (0, XSIZE_PHYS , YSIZE_PHYS);
- LCD_SetVSizeEx(0, VXSIZE_PHYS, VYSIZE_PHYS);
- Config.Orientation = GUI_SWAP_XY | GUI_MIRROR_Y;
- GUIDRV_FlexColor_Config(pDevice, &Config);
- PortAPI.pfWrite16_A0 =LcdWriteReg;
- PortAPI.pfWrite16_A1 =LcdWriteData;
- PortAPI.pfWriteM16_A1 = LcdWriteDataMultiple;
- PortAPI.pfReadM16_A1 =LcdReadDataMultiple;
- GUIDRV_FlexColor_SetFunc(pDevice, &PortAPI, GUIDRV_FLEXCOLOR_F66702,GUIDRV_FLEXCOLOR_M16C0B16);
- }
- //Stm32f1xx_it.c的修改:
- #include "stm32f1xx_hal.h"
- #include "stm32f1xx.h"
- #include "stm32f1xx_it.h"
- extern __IO int32_t OS_TimeMS;
- void SysTick_Handler(void)
- {
- HAL_IncTick();
- HAL_SYSTICK_IRQHandler();
- <font color="red">OS_TimeMS++;
- }
复制代码 编译下载运行:
运行结果并不如意,运行到一半就死机了,提示硬件的失败:
高手如果知道问题所在,望指教。
http://player.youku.com/player.php/sid/XMTQzODE5ODI0MA==/v.swf
|