【瑞萨RA8D1板卡】 LCD显示测试
<p><span style="font-size:16px;">测试LCD显示屏。</span></p><p> </p>
<p><span style="font-size:16px;"><strong>一、电路图部分</strong></span></p>
<p> </p>
<p><span style="font-size:16px;">LCD相关的引脚定义</span></p>
<p><span style="font-size:16px;"></span></p>
<p> </p>
<p><span style="font-size:16px;"><strong>二、配置LCD显示屏参数</strong></span></p>
<p> </p>
<p><span style="font-size:16px;">2.1、添加显示屏组件</span></p>
<p><span style="font-size:16px;"></span></p>
<p> </p>
<p><span style="font-size:16px;">2.2、设置参数</span></p>
<p> </p>
<p><span style="font-size:16px;">2.2.1、设置显示屏分辨率和颜色格式</span></p>
<p><span style="font-size:16px;"></span></p>
<p> </p>
<p><span style="font-size:16px;">2.2.2、设置显示屏时序</span></p>
<p><span style="font-size:16px;">根据显示屏参数,设置时序</span></p>
<p><span style="font-size:16px;"></span></p>
<p> </p>
<p><strong><span style="font-size:16px;">三、程序部分</span></strong></p>
<p> </p>
<p><span style="font-size:16px;">hal_entry.c</span></p>
<pre>
<code>/*
* Copyright (c) 2020 - 2024 Renesas Electronics Corporation and/or its affiliates
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include "hal_data.h"
#include "led/led.h"
#include "debug_uart/bsp_debug_uart.h"
#include "sdram/board_sdram.h"
//#include "ospi_flash/bsp_ospi_flash.h"
#include "common_utils.h"
#include "glcdc_ep.h"
fsp_err_t err;
void R_BSP_WarmStart(bsp_warm_start_event_t event);
/* Variables to store resolution information */
uint16_t g_hz_size, g_vr_size;
/* Variables used for buffer usage */
uint32_t g_buffer_size;
uint8_t * g_p_single_buffer, * g_p_double_buffer;
/* User defined functions */
#ifndef BOARD_RA8D1_CPKCOR
static void screen_display(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color);
#else
static void screen_display(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint32_t color);
#endif
static void color_band_display(void);
/*******************************************************************************************************************//**
* @brief Blinky example application
*
* Blinks all leds at a rate of 1 second using the software delay function provided by the BSP.
*
**********************************************************************************************************************/
void hal_entry (void)
{
fsp_err_t err = FSP_SUCCESS;
fsp_pack_version_t version = {RESET_VALUE};
R_FSP_VersionGet(&version);
init_led();
Debug_UART3_Init();
bsp_sdram_init();
/* Get LCDC configuration */
g_hz_size = (g_display_cfg.input.hsize);
g_vr_size = (g_display_cfg.input.vsize);
/* Initialize buffer pointers */
g_buffer_size = (uint32_t) (g_hz_size * g_vr_size * BYTES_PER_PIXEL);
g_p_single_buffer = (uint8_t *) g_display_cfg.input.p_base;
/* Double buffer for drawing color bands with good quality */
g_p_double_buffer = g_p_single_buffer + g_buffer_size;
/* Initialize GLCDC driver */
err = R_GLCDC_Open(&g_display_ctrl, &g_display_cfg);
/* Start GLCDC display output */
err = R_GLCDC_Start(&g_display_ctrl);
/* Clear LCD screen using appropriate co-ordinates */
screen_display((uint16_t)X1_CO_ORDINATE, (uint16_t)Y1_CO_ORDINATE, g_hz_size, g_vr_size, BLACK);
/* Display color bands on LCD screen */
color_band_display();
while (1)
{
/* Delay */
//R_BSP_SoftwareDelay(delay, bsp_delay_units);
R_BSP_SoftwareDelay(100, BSP_DELAY_UNITS_MILLISECONDS);
led201_on();
R_BSP_SoftwareDelay(100, BSP_DELAY_UNITS_MILLISECONDS);
led201_off();
}
}
#ifndef BOARD_RA8D1_CPKCOR
static void screen_display(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
{
/*Declare local variables */
uint16_t start_x, start_y, display_length, display_height;
uint32_t start_addr;
/* Assign co-ordinate values and calculate start address */
start_x = x1;
start_y = y1;
start_addr = (uint32_t)((start_x * BYTES_PER_PIXEL) + (start_y * g_hz_size* BYTES_PER_PIXEL));
/* Calculate display box length and height */
display_length = (uint16_t)((x2 - x1) * BYTES_PER_PIXEL);
display_height = (y2 - y1);
/* Display required color band */
for(uint16_t ver_value = Y1_CO_ORDINATE; ver_value < (display_height - INC_DEC_VALUE); ver_value++)
{
for(uint32_t hor_value = start_addr; hor_value < (start_addr + display_length); hor_value += BYTES_PER_PIXEL)
{
*(uint16_t *) (g_p_single_buffer + hor_value) = color;
*(uint16_t *) (g_p_double_buffer + hor_value) = color;
}
start_addr = (uint32_t)(start_addr + (g_hz_size * BYTES_PER_PIXEL));
}
}
#else
static void screen_display(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint32_t color)
{
/*Declare local variables */
uint16_t start_x, start_y, display_length, display_height;
uint32_t start_addr;
/* Assign co-ordinate values and calculate start address */
start_x = x1;
start_y = y1;
start_addr = (uint32_t)((start_x * BYTES_PER_PIXEL) + (start_y * g_hz_size* BYTES_PER_PIXEL));
/* Calculate display box length and height */
display_length = (uint16_t)((x2 - x1) * BYTES_PER_PIXEL);
display_height = (y2 - y1);
/* Display required color band */
for(uint16_t ver_value = Y1_CO_ORDINATE; ver_value < (display_height - INC_DEC_VALUE); ver_value++)
{
for(uint32_t hor_value = start_addr; hor_value < (start_addr + display_length); hor_value += BYTES_PER_PIXEL)
{
*(uint32_t *) (g_p_single_buffer + hor_value) = color;
*(uint32_t *) (g_p_double_buffer + hor_value) = color;
}
start_addr = (uint32_t)(start_addr + (g_hz_size * BYTES_PER_PIXEL));
}
}
#endif
/*******************************************************************************************************************//**
* @brief This function display eight color band horizontally on Graphical LCD .
* @paramNone
* @retval None
***********************************************************************************************************************/
static void color_band_display(void)
{
#ifndef BOARD_RA8D1_CPKCOR
uint16_t color= {RED, GREEN, BLUE, BLACK, WHITE, YELLOW, MAGENTA, CYAN};
#else
uint32_t color= {RED, GREEN, BLUE, BLACK, WHITE, YELLOW, MAGENTA, CYAN};
#endif
uint16_t width = g_vr_size/COLOR_BAND_COUNT;
for (uint8_t display_count = RESET_VALUE; display_count < COLOR_BAND_COUNT; display_count++)
{
screen_display((uint16_t)X1_CO_ORDINATE, (display_count * width), g_hz_size, (uint16_t)(((display_count * width) + width) + INC_DEC_VALUE), color);
}
}
/*******************************************************************************************************************//**
* This function is called at various points during the startup process.This implementation uses the event that is
* called right before main() to set up the pins.
*
* @paramevent Where at in the start up process the code is currently at
**********************************************************************************************************************/
void R_BSP_WarmStart (bsp_warm_start_event_t event)
{
if (BSP_WARM_START_RESET == event)
{
#if BSP_FEATURE_FLASH_LP_VERSION != 0
/* Enable reading from data flash. */
R_FACI_LP->DFLCTL = 1U;
/* Would normally have to wait tDSTOP(6us) for data flash recovery. Placing the enable here, before clock and
* C runtime initialization, should negate the need for a delay since the initialization will typically take more than 6us. */
#endif
}
if (BSP_WARM_START_POST_C == event)
{
/* C runtime environment and system clocks are setup. */
/* Configure pins. */
R_IOPORT_Open(&IOPORT_CFG_CTRL, &IOPORT_CFG_NAME);
}
}
</code></pre>
<p> </p>
<p><span style="font-size:16px;"><strong>四、运行结果</strong></span></p>
<p> </p>
<p><span style="font-size:16px;">运行后,显示屏显示</span></p>
<p></p>
<p> </p>
页:
[1]