STemWin:裸机移植(ILI9325)

LCD芯片:ILI9325

STemWin版本:5.32b

手头有ILI9325屏及OTM8009A屏,由于ILI9325芯片资料较多,移植比较简单,先从ILI9325入手。

整体移植需要以下步骤

1.下载STemWin,添加GUI_X.c、GUIConf.c、LCDConf_FlexColor_Template.c、STemWin532_CM3_keil.lib到工程

2.修改GUIConf.c文件#define GUI_NUMBYTES  1024*150

3.修改LCDConf_FlexColor_Template.c文件

XSIZE_PHYS 、YSIZE_PHYS修改为合适屏幕参数,添加液晶相关函数 

/********************************************************************
*
*       LcdWriteReg
*
* Function description:
*   Sets display register
*/
static void LcdWriteReg(U16 Data) {
  // ... TBD by user
	ILI9325_WR_CMD(Data);
}

/********************************************************************
*
*       LcdWriteData
*
* Function description:
*   Writes a value to a display register
*/
static void LcdWriteData(U16 Data) {
  // ... TBD by user
	ILI9325_WR_Data(Data);
}

/********************************************************************
*
*       LcdWriteDataMultiple
*
* Function description:
*   Writes multiple values to a display register.
*/
static void LcdWriteDataMultiple(U16 * pData, int NumItems) {
  while (NumItems--) {
    // ... TBD by user
		ILI9325_WR_Data(*pData++);
  }
}

/********************************************************************
*
*       LcdReadDataMultiple
*
* Function description:
*   Reads multiple values from a display register.
*/
static void LcdReadDataMultiple(U16 * pData, int NumItems) {
  while (NumItems--) {
    // ... TBD by user
		*pData++ = (U16)ILI9325_RD_Data();
  }
}


int LCD_X_DisplayDriver(unsigned LayerIndex, unsigned Cmd, void * pData)函数中加入LCD初始化函数。

int LCD_X_DisplayDriver(unsigned LayerIndex, unsigned Cmd, void * pData) {
  int r;
  (void) LayerIndex;
  (void) pData;
  
  switch (Cmd) {
  case LCD_X_INITCONTROLLER: {
    //
    // Called during the initialization process in order to set up the
    // display controller and put it into operation. If the display
    // controller is not initialized by any external routine this needs
    // to be adapted by the customer...
    //
    // ...
		ILI9325_Init();
    return 0;
  }
  default:
    r = -1;
  }
  return r;
}

修改LCD_X_Config函数,其中GUIDRV_FlexColor_SetFunc尤其注意,在说明书中查找支持的控制器,修改其内容。由于默认的支持ILI9325,就不修改。

4.main函数中添加应用函数

  /* USER CODE BEGIN 2 */
  __HAL_RCC_CRC_CLK_ENABLE();
	GUI_Init();

  /* Start Demo */
  GUIDEMO_Main();
  /* USER CODE END 2 */


网上相关教程较多,由于使用的是STM32CubeMX,在应用中,不要忘记__HAL_RCC_CRC_CLK_ENABLE();



你可能感兴趣的:(STemWin)