GD32 단일 칩 기반 TFT-LCD 인터페이스 및 그래픽 처리 가속기

GD32F4 단일 칩에서 TLI(TFT-LCD Interface), IPA(Image Processing Accelerator) 그리고 TFT-LCD의 작동 원리를 다룹니다.

TFT-LCD 화면 구성 요소

TFT-LCD 디스플레이 시스템은 여러 계층으로 구성됩니다. 이 계층 구조는 배경부터 상위 층까지 다음과 같이 정리됩니다.

  1. BG(배경): 가장 아래에 위치하며 단색만 설정 가능합니다.
  2. Layer 0: 배치 주소, 창 위치, 크기, 픽셀 형식 등을 조정할 수 있습니다.
  3. Layer 1: Layer 0과 독립적으로 구성되며, 하드웨어로 투명하게 겹쳐질 수 있습니다.

화면 출력 순서

화면 출력은 아래에서 위 순서대로 이루어집니다:


BG(배경)
Layer 0(하단 이미지)
Layer 1(상단 이미지)

TLI는 자동으로 프레임 버퍼를 주기적으로 갱신하여 화면을 업데이트하고, IPA가 이를 통해 데이터를 처리하여 실시간으로 반영합니다.

tli_parameter_struct 분석

이 구조체는 GD32 단일 칩의 TLI 컨트롤러를 설정하는 데 사용됩니다.

typedef struct {
    uint32_t lcd_sync;                // 동기 신호 극성
    uint32_t lcd_hsync;               // 수평 동기화 주기
    uint32_t lcd_hbp;                // 수평 백포치
    uint32_t lcd_hfp;                // 수평 프론트포치
    uint32_t lcd_vsync;              // 수직 동기화 주기
    uint32_t lcd_vbp;                // 수직 백포치
    uint32_t lcd_vfp;                // 수직 프론트포치
    
    uint32_t lcd_clock_polarity;     // 픽셀 클록 극성
    uint32_t lcd_de_polarity;        // DE 신호 극성
    uint32_t lcd_output_enable;      // TLI 출력 활성화

    uint8_t lcd_background_red;       // 배경 R
    uint8_t lcd_background_green;     // 배경 G
    uint8_t lcd_background_blue;      // 배경 B
} tli_parameter_struct;

구조체 초기화 예제

아래 코드는 기본적인 TLI 구조체를 초기화하는 방법입니다.

tli_parameter_struct lcd_param;

// 초기화
tli_struct_para_init(&lcd_param);

// 동기화 설정
lcd_param.tli_sync = LCD_SYNC_HSYNC_LOW | LCD_SYNC_VSYNC_LOW;

// 수평 타이밍
lcd_param.tli_hsync = 41;
lcd_param.tli_hbp = 2;
lcd_param.tli_hfp = 2;

// 수직 타이밍
lcd_param.tli_vsync = 10;
lcd_param.tli_vbp = 2;
lcd_param.tli_vfp = 2;

// 클록 및 DE 설정
lcd_param.tli_clock_polarity = LCD_CLK_POLARITY_RISING;
lcd_param.tli_de_polarity = LCD_DE_POLARITY_HIGH;

// 배경 색상: 검정
lcd_param.tli_background_red = 0x00;
lcd_param.tli_background_green = 0x00;
lcd_param.tli_background_blue = 0x00;

// 출력 활성화
lcd_param.tli_output = LCD_OUTPUT_ENABLE;

// 초기화 함수 호출
tli_init(&lcd_param);

ipa_foreground_parameter_struct 및 ipa_destination_parameter_struct

IPA는 두 가지 주요 구조체를 사용하여 작업합니다.

typedef struct {
    uint32_t fg_memaddr;             // 전경 메모리 시작 주소
    uint32_t fg_lineoff;             // 전경 이미지 행 오프셋
    uint32_t fg_pixel_format;       // 전경 픽셀 형식
    uint32_t fg_alpha_algorithm;    // 알파 혼합 알고리즘
    uint32_t fg_prealpha;           // 전역 알파 값
} ipa_foreground_parameter_struct;

typedef struct {
    uint32_t dest_memaddr;          // 목적지 메모리 시작 주소
    uint32_t dest_lineoff;          // 목적지 이미지 행 오프셋
    uint32_t dest_pixel_format;     // 출력 픽셀 형식
    uint32_t dest_width;            // 이미지 너비
    uint32_t dest_height;           // 이미지 높이
} ipa_destination_parameter_struct;

예제 코드

아래는 IPA를 초기화하는 예제입니다.

ipa_foreground_parameter_struct fg_param;
ipa_destination_parameter_struct dest_param;

// 전경 초기화
ipa_foreground_struct_para_init(&fg_param);
fg_param.fg_memaddr = (uint32_t)0xC0000000;
fg_param.fg_pixel_format = FOREGROUND_PPF_ARGB8888;
fg_param.fg_lineoff = 0;
fg_param.fg_alpha_algorithm = IPA_FG_ALPHA_MODE_0;
fg_param.fg_prealpha = 0xFF;
ipa_foreground_init(&fg_param);

// 목적지 초기화
ipa_destination_struct_para_init(&dest_param);
dest_param.dest_memaddr = (uint32_t)TLI_LAYER0_FRAME_BUFFER_ADDR;
dest_param.dest_pixel_format = DESTINATION_PPF_RGB565;
dest_param.dest_lineoff = 0;
dest_param.dest_width = 240;
dest_param.dest_height = 320;
ipa_destination_init(&dest_param);

TLI와 IPA의 관계

TLI는 화면 출력을 담당하며, IPA는 이미지를 처리하고 변환하여 TLI에 전달합니다.

특징 TLI IPA
역할 화면 드라이버 및 출력 이미지 처리 및 가속
데이터 흐름 메모리 → TLI → LCD 메모리 → IPA → 메모리

태그: GD32 TFT-LCD IPA

9월 24일 19:01에 게시됨