MIPI-DSIビデオ・モード
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 bits) - DSI Modeに設定
- レイヤーの設定
Number of layers
を1 layerに設定Layer 0 - Pixel Format
をRGB888に設定Layer 0 - Alpha constant for blending
を255に設定
- NVICの設定
- LCD-TFT global interruptを有効にする
DSIHOSTの設定
- モード
DSIHost
をVideo Modeに設定
- ディスプレイ・インタフェース
Color Coding
をRGB888 (24 bits) - DSI modeに設定- 残りの設定は選択したLCD HWに応じて異なる
- NVICの設定
- DSIHOST global interruptは必要ないので、無効にすること
TouchGFX Generator
- モード
- Graphics Applicationを有効にする
- TouchGFX Generator
Display / Interface
をParallel RGB (LTDC)に設定(これはコントローラであり、アプリケーションとの通信の必要があるため)Application Tick Source
をLTDCに設定
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
Reference implementation
The TouchGFX Board Setup STM32U5G9J DK1 includes a reference implementation running DSI Video Mode in RGB888 24-bit framebuffer format.