1. 程式人生 > >STemWin:裸機移植(ILI9325)

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();