STM32H750移植STemWin,驱动ST7789

移植基于正点原子1.3寸SPI显示屏,驱动芯片为ST7789,使用STM32Cube+STM32CubeIDE+STemWin。

1.新建STM32Cube工程,选择STM32H750VB

2.时钟配置如下图,我选用的是25MHz无源晶振

STM32H750移植STemWin,驱动ST7789_第1张图片

 3.设置SPI接口和其它引脚,注意Clock Parameters设置

STM32H750移植STemWin,驱动ST7789_第2张图片

STM32H750移植STemWin,驱动ST7789_第3张图片

 注意上面的引脚速度不能设置为High。

4.设置其它引脚,并打开CRC。

STM32H750移植STemWin,驱动ST7789_第4张图片

STM32H750移植STemWin,驱动ST7789_第5张图片

STM32H750移植STemWin,驱动ST7789_第6张图片

 

5.工程设置如下图,生成工程并打开。

STM32H750移植STemWin,驱动ST7789_第7张图片

6.打开\STM32Cube\Repository\STM32Cube_FW_H7_V1.9.1\Middlewares\ST文件夹,将STemWin复制到工程中。

 STM32H750移植STemWin,驱动ST7789_第8张图片

 7.打开该文件夹,对文件进行裁剪。首先删掉这四个文件

STM32H750移植STemWin,驱动ST7789_第9张图片

8.删除Config下的这三个文件.

STM32H750移植STemWin,驱动ST7789_第10张图片

9.lib中只保留STemWin_CM7_wc16_ARGB.a文件

10.OS中保留GUI_X.c文件

11.工程设置中,C/C++General -> Paths and Symbols -> Source Location添加STemWin文件夹(Add Folder)。 STM32H750移植STemWin,驱动ST7789_第11张图片

 12.在C/C++ Build中的Settings,MCU GCC Compiler添加STemWin的四个路径。

13.添加库链接,注意库名称前加:

STM32H750移植STemWin,驱动ST7789_第12张图片

14.删除LCD_Private.h和LCD_ConfDefaults.h中的    #include "LCDConf.h"

 15.修改GUIConf.c中的#define GUI_NUMBYTES  1024*50

16.至此,编译应能通过,略掉LCD的基础移植。

17.修改GUIConf.h 

#define GUI_NUM_LAYERS            1  

#ifndef   GUI_SUPPORT_TOUCH
  #define GUI_SUPPORT_TOUCH       (0)  // Support touchscreen
#endif

#define GUI_SUPPORT_MOUSE             (0)    /* Support a mouse */
#define GUI_WINSUPPORT                (1)    /* Use window manager */
#define GUI_SUPPORT_MEMDEV            (0)    /* Memory device package available */
#define GUI_SUPPORT_DEVICES           (0)    /* Enable use of device pointers */

18. 修改GUIDRV_Template.c中的下列函数,添加LCD_Draw_ColorPoint(x,y,PixelIndex);函数

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);
    {
      //
      // Write into hardware ... Adapt to your system
      //
      // TBD by customer...
      //
    	LCD_Draw_ColorPoint(x,y,PixelIndex);
    }
    #if (LCD_MIRROR_X == 0) && (LCD_MIRROR_Y == 0) && (LCD_SWAP_XY == 0)
      #undef xPhys
      #undef yPhys
    #endif
}

19.修改LCDConf_FlexColor_Template.c文件,注意LCD_X_Config只保留三行,并修改&GUIDRV_Template_API


#include "GUI.h"
#include "GUIDRV_FlexColor.h"

/*********************************************************************
*
*       Layer configuration (to be modified)
*
**********************************************************************
*/

//
// Physical display size
//
#define XSIZE_PHYS  240 // To be adapted to x-screen size
#define YSIZE_PHYS  240 // To be adapted to y-screen size


void LCD_X_Config(void) {
  GUI_DEVICE * pDevice;
  CONFIG_FLEXCOLOR Config = {0};
  GUI_PORT_API PortAPI = {0};
  //
  // Set display driver and color conversion
  //
  pDevice = GUI_DEVICE_CreateAndLink(&GUIDRV_Template_API, GUICC_565, 0, 0);
  //
  // Display driver configuration, required for Lin-driver
  //
  LCD_SetSizeEx (0, XSIZE_PHYS , YSIZE_PHYS);
  LCD_SetVSizeEx(0, VXSIZE_PHYS, VYSIZE_PHYS);
  //
  // Orientation
  //
//  Config.Orientation = GUI_SWAP_XY | GUI_MIRROR_Y;
//  GUIDRV_FlexColor_Config(pDevice, &Config);
//  //
//  // Set controller and operation mode
//  //
//  PortAPI.pfWrite16_A0  = LcdWriteReg;
//  PortAPI.pfWrite16_A1  = LcdWriteData;
//  PortAPI.pfWriteM16_A1 = LcdWriteDataMultiple;
//  PortAPI.pfReadM16_A1  = LcdReadDataMultiple;
//  GUIDRV_FlexColor_SetFunc(pDevice, &PortAPI, GUIDRV_FLEXCOLOR_F66708, GUIDRV_FLEXCOLOR_M16C0B16);
}

 

 

 

你可能感兴趣的:(STM32,单片机,stm32,嵌入式硬件)