跳轉到主要內容

MIPI-DS影片模式

This scenario describes how to configure a STM32 DSIHOST in Video Mode and TouchGFX Generator when using a display with Display Serial Interface (DSI).

The example used in this article will be for 24-bit RGB888 framebuffer format and goes through configurations in STM32CubeMX and exemplifies with generated code.

Configuration

LTDC設定

  • 模式
    • Display Type設置為RGB888(24位元)-DSI模式
  • 層設置
    • Number of layers設置為1 layer
    • 設置Layer 0 - Pixel Format設置為RGB888
    • 設置Layer 0 - Alpha constant for blending255

      LTDC設定

  • NVIC設定
    • 啟用LCD-TFT全域中斷

      LTDC NVIC 設定

DSIHOST 配置

  • 模式
    • DSIHost設定為_*Video Mode**
  • 顯示介面
    • Color Coding設定為“RGB888(24位元)- DSI模式”
    • 其餘配置取決於所選的LCD HW

      DSIHOST 配置

  • NVIC設定
    • DSIHOST無需全域中斷,應禁用。

      DSIHOST NVIC 設定

TouchGFX Generator

  • 模式
    • 啟用Graphics Application
  • TouchGFX Generator
    • Display / Interface設定為Parallel RGB(LTDC),因為這仍是應用程式與之通信的控制器。
    • Application Tick Source設定為LTDC

      TouchGFXGenerator設定

User Code

The TouchGFX Generator can generate a full TouchGFX AL that configures the LTDC to transfer pixels through the DSI Host controller from the framebuffer memory to the display and synchronize the display with the TouchGFX Engine. Only minor adjustments may be required as described below.

DSIHOST / LTDC初始化順序

MX_DSIHOST_DSI_Init()的呼叫必須在MX_LTDC_Init()之前完成。 This should be handled by STM32CubeMX. If this is not correct, take care to fix the order in a user code section.

After calling HAL_DSI_Start(), switch DSIHOST clock to the DSIPHY source:

static void MX_DSIHOST_DSI_Init(void)
{
...
/* Switch to DSI PHY PLL clock */
RCC_PeriphCLKInitTypeDef PeriphClkInit;
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_DSI;
PeriphClkInit.DsiClockSelection = RCC_DSICLKSOURCE_DSIPHY;
HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit);
/* USER CODE END DSIHOST_Init 2 */
...
}

使用者必須在MX_LTDC_Init()函數的尾端添加特定於所用LCD控制器的必要初始化程式碼。 That code will be based on the DSI HAL APIs HAL_DSI_ShortWrite() and HAL_DSI_LongWrite():

  static void MX_LTDC_Init(void)
{
...
/* USER CODE BEGIN LTDC_Init 2 */
// Specific LCD controller's initialization code
...

// Exit Sleep Mode
if (HAL_DSI_ShortWrite(&hdsi, 0, DSI_DCS_SHORT_PKT_WRITE_P0, DSI_EXIT_SLEEP_MODE, 0x00) != HAL_OK)
{
Error_Handler();
}

HAL_Delay(120);
/* USER CODE END LTDC_Init 2 */
...
}

更新了DSI影片模式的TouchGFXHAL類

The generated code for the LTDC interrupt is identical to the code generated when using Parallel RGB display interface.

One way to prevent the MIPI DSI display from turning on until we've rendered the first frame in the application is to guard the function TouchGFXHAL::endFrame to keep the display off until first frame is rendered by TouchGFX. TouchGFXHAL::endFrame()可像下面這樣更新,通過配置為PWM輸出的HW計時器啟用LCD及其背光。

void TouchGFXHAL::endFrame()
{
if (!display_on)
{
display_on = true;
/* Enable the LCD, Send Display on DCS command to display */
HAL_DSI_ShortWrite(&hdsi, 0, DSI_DCS_SHORT_PKT_WRITE_P1, DSI_SET_DISPLAY_ON, 0x00);
/* Start PWM Timer channel */
(void)HAL_TIM_PWM_Start(&htim8, TIM_CHANNEL_2);
/* Enable Backlight by setting Brightness to 100% */
__HAL_TIM_SET_COMPARE(&htim8, TIM_CHANNEL_2, 2U * 100);
}

TouchGFXGeneratedHAL::endFrame();
}

Supported Framebuffer Strategies

  • Single
  • Double
  • Partial - LTDC driven display
Further reading
See article Framebuffer Strategies for a general introduction to framebuffer strategies in TouchGFX.

Reference implementation

The TouchGFX Board Setup STM32U5G9J DK1 includes a reference implementation running DSI Video Mode in RGB888 24-bit framebuffer format.

Further reading
See article LTDC Display Interface for more information about the generated TouchGFX AL compatible with DSI Video mode with LTDC.