📄 bsp_lcd.c
字号:
/*
*********************************************************************************************************
* MICRIUM BOARD SUPPORT SUPPORT
*
* (c) Copyright 2003-2008; Micrium, Inc.; Weston, FL
*
* All rights reserved. Protected by international copyright laws.
* Knowledge of the source code may NOT be used to develop a similar product.
* Please help us continue to provide the Embedded community with the finest
* software available. Your honesty is greatly appreciated.
*********************************************************************************************************
*/
/*
*********************************************************************************************************
*
* LCD BOARD SUPPORT PACKAGE
*
* NXP LPC2478
* on the
* IAR LPC2478-SK Kickstart Kit
*
* Filename : bsp_lcd.c
* Version : V1.00
* Programmer(s) : FT
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* INCLUDE FILES
*********************************************************************************************************
*/
#define BSP_LCD_MODULE
#include <includes.h>
/*
*********************************************************************************************************
* REGISTER DEFINES
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* LOCAL DEFINES
*********************************************************************************************************
*/
/*-------------- LCD GPIOO I/O DEFINES --------------------- */
#define BSP_LCD_GPIO0_IF_EN DEF_BIT_00 /* GPIO.0 LCD CPLD Interface Enable/Disable */
#define BSP_LCD_GPIO0_BACK_LIGHT_EN DEF_BIT_04 /* GPIO.4 LCD Backlight Enable */
#define BSP_LCD_CLK_IN_FREQ 0 /* LCDCLKIN signal frequency */
/* ------ LCD CONTROL REGISTER (LCD_CTRL) BITS DEFINES ----- */
#define BSP_LCD_CTRL_LCDEN DEF_BIT_00 /* LCD Enable Control bit (LCDEN) */
#define BSP_LCD_CTRL_BPP1 (0x00 << 1) /* LCD bits per pixel (LCDBPP) = 1 bpp */
#define BSP_LCD_CTRL_BPP2 (0x01 << 1) /* LCD bits per pixel (LCDBPP) = 2 bpp */
#define BSP_LCD_CTRL_BPP4 (0x02 << 1) /* LCD bits per pixel (LCDBPP) = 4 bpp */
#define BSP_LCD_CTRL_BPP8 (0x03 << 1) /* LCD bits per pixel (LCDBPP) = 8 bpp */
#define BSP_LCD_CTRL_BPP16 (0x04 << 1) /* LCD bits per pixel (LCDBPP) = 16 bpp */
#define BSP_LCD_CTRL_BPP24 (0x05 << 1) /* LCD bits per pixel (LCDBPP) = 24 bpp */
#define BSP_LCD_CTRL_BPP16_565 (0x06 << 1) /* LCD bits per pixel (LCDBPP) = 16 565 bpp */
#define BSP_LCD_CTRL_BPP12_444 (0x07 << 1) /* LCD bits per pixel (LCDBPP) = 12 444 bpp */
#define BSP_LCD_CTRL_BW_EN DEF_BIT_04 /* LCD Monochrome/color sel.(LCDBW). Monochrom enable */
#define BSP_LCD_CTRL_LCD_TFT_EN DEF_BIT_05 /* LCD Panel TFT type selection (LCDTFT). TFT display */
#define BSP_LCD_CTRL_MONO_8_EN DEF_BIT_06 /* LCD Monochrome interface width. 8-bit interface */
#define BSP_LCD_CTRL_DUAL_PANEL_EN DEF_BIT_07 /* LCD Dual panel selection. 1 = Dual 0 = Single panel */
#define BSP_LCD_CTRL_BGR DEF_BIT_08 /* LCD Color format selection. RGB or BGR */
#define BSP_LCD_CTRL_BEBO_EN DEF_BIT_09 /* LCD big-endian order */
#define BSP_LCD_CTRL_BEPO_EN DEF_BIT_10 /* LCD big-endian pixel ordering */
#define BSP_LCD_CTRL_PWR DEF_BIT_11 /* LCD Power enable */
#define BSP_LCD_CTRL_VCOMP_VS (0x00 << 12) /* LCD vertical compare interrupt. Start of vert synch */
#define BSP_LCD_CTRL_VCOMP_BP (0x01 << 12) /* LCD vertical compare interrupt. Start of back porch */
#define BSP_LCD_CTRL_VCOMP_AV (0x02 << 12) /* LCD vertical compare interrupt. Start of active video */
#define BSP_LCD_CTRL_VCOMP_FP (0x03 << 12) /* LCD vertical compare interrupt. Start of front porch */
#define BSP_LCD_CTRL_WATERM_8 (0x01 << 16) /* LCD DMA request when FIFOs have 8 or more empty locations */
/* ---- CLOCK AND SIGNAL POLARITY REGISTER BITS DEFINES ---- */
/* LCD Clock and Signal Polarity (LCD_POL) */
#define BSP_LCD_POL_IVS DEF_BIT_11 /* LCD Invert Vertical synchronization */
#define BSP_LCD_POL_IHS DEF_BIT_12 /* LCD Invert Horizontal synchronization */
#define BSP_LCD_POL_IPC DEF_BIT_13 /* LCD Invert panel clock */
#define BSP_LCD_POL_IOE DEF_BIT_14 /* LCD Invert output enable */
#define BSP_LCD_POL_BCD_EN DEF_BIT_26 /* LCD Bypass pixel clock divider */
/* ------- LCD LINE END (LCD_LE) REGISTER BIT DEFINES ----- */
#define BSP_LCD_LE_LEE_EN DEF_BIT_16 /* LCD Line end enable */
/* ---- LCD CONFIGURATION(LCD_CFG) REGISTER BIT DEFINES ---- */
#define BSP_LCD_CFG_HCLK_EN DEF_BIT_05 /* Enable the HCLK signal to the LCD controller */
#define BSP_LCD_CFG_DISP_TYPE_STN DEF_BIT_08 /* STN Display type */
/*
#define BSP_LCD_POL_IOE 0
#define BSP_LCD_POL_IPC 1
#define BSP_LCD_POL_IHS 1
#define BSP_LCD_POL_IVS 1
*/
//extern CPU_INT32U LCD_VRAM_BASE_ADDR = 0xA0000000;
//extern CPU_INT32U SDRAM_BASE_ADDR;
//#define LCD_VRAM_BASE_ADDR ((CPU_INT32U)&SDRAM_BASE_ADDR)
/*
*********************************************************************************************************
* LOCAL DATA TYPES
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* LOCAL MACRO'S
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* LOCAL DATA TYPES
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* LOCAL TABLES
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* LOCAL GLOBAL VARIABLES
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* LOCAL FUNCTION PROTOTYPES
*********************************************************************************************************
*/
/* ------------------ LCD LOCAL FUNCTIONS ------------------ */
static void BSP_LCD_CtrlInit (BSP_LCD_PARAM *LCDInit);
static void BSP_LCD_Dly_ms (CPU_INT16U dly_ms);
static CPU_INT32U BSP_LCD_GetClkFreq (void);
/*
*********************************************************************************************************
*********************************************************************************************************
** GLOBAL FUNCTIONS
*********************************************************************************************************
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* BSP_LCD_Init()
*
* Description : Initialize the LCD controller and display.
* (1) Initialize the LCD controller with the LCD display parameters.
* (2) Turn On the LCD.
* (3) Disable the LCD controller
*
* Argument(s) : p_param Pointer to the BSP_LCD_PARAM structure where all LCD display parameters are defined
*
* Return(s) : none.
*
* Caller(s) : Application.
*
* Note(s) : none.
*********************************************************************************************************
*/
void BSP_LCD_Init (BSP_LCD_PARAM *p_param)
{
BSP_LCD_CtrlInit(p_param); /* Initialize the LCD controller */
BSP_LCD_TurnOn(); /* Turn on the LCD display */
BSP_LCD_CTRL_OFF(); /* Disable the LCD controller */
}
/*
*********************************************************************************************************
* BSP_LCD_TurnOn()
*
* Description : Turn On the LCD display.
* (1) Enable the LCD controller.
* (2) Enable Power on the LCD controller.
* (3) Wait for 500 ms
*
* Argument(s) : none.
*
* Return(s) : none.
*
* Caller(s) : Application.
*
* Note(s) : none.
*********************************************************************************************************
*/
void BSP_LCD_TurnOn (void)
{
BSP_LCD_CTRL_ON();
BSP_LCD_Dly_ms(500);
LCD_CTRL |= BSP_LCD_CTRL_PWR;
}
/*
*********************************************************************************************************
* BSP_LCD_TurnOff()
*
* Description : Turn Off the LCD display.
* (1) Disable the LCD Controller.
* (2) Disable Power on the LCD controller.
* (3) Wait for 500 ms.
*
* Argument(s) : none.
*
* Return(s) : none.
*
* Caller(s) : Application.
*
* Note(s) : none.
*********************************************************************************************************
*/
void BSP_LCD_TurnOff (void)
{
BSP_LCD_CTRL_OFF();
BSP_LCD_Dly_ms(500);
LCD_CTRL &= ~BSP_LCD_CTRL_PWR;
}
/*
*********************************************************************************************************
*********************************************************************************************************
** LOCAL FUNCTIONS
*********************************************************************************************************
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* BSP_LCD_Dly_ms()
*
* Description : Delay the execution for a specified amount of time.
*
* Argument(s) : dly_ms Delay in miliseconds.
*
* Return(s) : none.
*
* Caller(s) : BSP_LCD_TurnOff()
* BSP_LCD_TurnOn ()
*
*
* Note(s) : none.
*********************************************************************************************************
*/
static void BSP_LCD_Dly_ms (CPU_INT16U dly_ms)
{
OSTimeDlyHMSM(0, 0, 0, dly_ms);
}
/*
*********************************************************************************************************
* BSP_LCD_CtrlInit()
*
* Description : Initialize the LCD controller.
*
* Argument(s) : p_param Pointer to the BSP_LCD_PARAM structure.
*
* Each member of the structure can take the following values:
* LCD_ACB Any integer value that specifies the AC Bias pin frequency.
* It is only used in STN displays.
*
* LCD_BPP BSP_LCD_BPP_1
* BSP_LCD_BPP_2
* BSP_LCD_BPP_4
* BSP_LCD_BPP_16_565
* BSP_LCD_BPP_24
* BSP_LCD_BPP_12_444
*
*
* LCD_DispType BSP_LCD_DISP_TYPE_STN
* BSP_LCD_DISP_TYPE_TFT
*
* LCD_DispMode BSP_LCD_DISP_MODE_TFT_SINGLE_12_444
* BSP_LCD_DISP_MODE_TFT_SINGLE_16_565
* BSP_LCD_DISP_MODE_TFT_SINGLE_16_1555
* BSP_LCD_DISP_MODE_TFT_SINGLE_24
* BSP_LCD_DISP_MODE_STN_SINGLE_4_MONO
* BSP_LCD_DISP_MODE_STN_SINGLE_8_MONO
* BSP_LCD_DISP_MODE_STN_SINGLE_COLOR
* BSP_LCD_DISP_MODE_STN_DUAL_4_MONO
* BSP_LCD_DISP_MODE_STN_DUAL_8_MONO
* BSP_LCD_DISP_MODE_STN_DUAL_COLOR
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -