19.1 Introduction--介绍
The LCD Controller allows a variety of different character and graphic displays to be connected
to and driven by the microcontroller. The LCD module contains two independent controllers, one
supporting LCD Interface Display Driver (LIDD) mode command and data transactions to character
displays or those containing an integrated controller with a packet-based interface, and the
other driving clock, syncs and data suitable for RGB raster displays. Up to two simultaneous LIDD
displays may be driven or a single RGB raster mode display.
The LCD API provides functions to configure the interface type and timing for the attached display
or displays. For LIDD mode displays, functions allow an application to send commands or data to
the display or read back status or data. For raster displays, functions allow the pixel clock, HSYNC,
VSYNC and ACTIVE timings to be set. Additional functions allow the frame buffer memory to be
configured and the color palette to be set.
This driver is contained in driverlib/lcd.c, with driverlib/lcd.h containing the API declarations
for use by applications.
19.2.2 LCD Interface Display Driver (LIDD) Mode:LCD接口显示驱动模式
The LIDD mode controller allows connection of displays via a synchronous or asynchronous interface
using Chip Select (CS), Write Enable (WE), Output Enable (OE) and Address Latch Enable
(ALE) signals along with a parallel data bus of 8 to 16 bits.
Several different bus signaling modes are supported to allow connection of devices making use of
Hitachi, Motorola or Intel bus conventions. For timing diagrams showing the operation of each of
these modes, please consult the datasheet for your particular Tiva part.
LIDD mode would typically be used with displays where updates are made via a packet-based
command and data protocol rather than by direct access to a local frame buffer. These will generally
be lower resolution RGB panels or character-mode displays.
Interface signaling, timing and basic mode are set using three API functions. To select LIDD mode,
LCDModeSet() is called with the ui8Mode parameter set to LCD_MODE_LIDD and the desired
bit clock rate. LCDIDDConfigSet() is then called to set the basic operating mode of the LIDD
interface (synchronous or asynchronous Motorola or Intel mode, or asynchronous Hitachi mode)
and configure the polarities of the various interface control signals. Finally LCDIDDTimingSet() is
called to set the timings associated with the interface strobes. When using the asynchronous Intel
or Motorola interface modes, two independent chip select (CS) signals are available and timings
may be set for these individually allowing two different LIDD panels to be attached simultaneously.
Data may be transfered to or from the panel either one item (8-bit byte or 16-bit word depending
upon the panel) at a time or in blocks using DMA. In basic operation, the API provides two sets of
functions which allow reading and writing. The choice of function is dictated by the specification
of the display in use and the hardware interface it uses. Functions LCDIDDDataRead(), LCDIDDDataWrite(),
LCDIDDCommandWrite() and LCDIDDStatusRead() can be used with panels which
support a Data/Control (DC) signal to control command or data accesses. Command writes and
status reads are performed with the DC signal (on the ALE pin) active whereas data operations
occur with the DC signal inactive.
For displays using an external address latch and configured in one of the Intel or Motorola modes,
LCDIDDIndexedRead() and LCDIDDIndexedWrite() may be used to read or write indexed registers
in the display.
To transfer large blocks of data to the display, DMA may be used via the LCDIDDDMAWrite() function.
This function enables the DMA engine in the LCD controller before transfering the required
block of data to the display. The DMA engine transfers data 16 bits at a time so data must be
padded if a display with an 8 bit interface is used. The completion of a DMA transfer is indicated
via the LCD_INT_DMA_DONE interrupt.
Care must be taken when mixing DMA and non-DMA accesses to the display. The application is
responsible for ensuring that any previous DMA operation has completed before another is scheduled.
Similarly, the application must ensure that it disables DMA using LCDIDDDMADisable() before
making a call to LCDIDDCommandWrite(), LCDIDDStatusRead(), LCDIDDDataWrite(), LCDIDDDataRead(),
LCDIDDIndexedWrite() or LCDIDDIndexedRead().
Raster Mode--光栅模式
Raster mode connects both passive- and active-matrix displays using a traditional video-style, synchronous
interface based on VSYNC (LCDFP), HSYNC (LCDLP), VALID (LCDAC), CLK (LCPCP)
and DATA (LCDDATA) signals. Unlike LIDD displays which contain their own frame buffer, the display
image for a raster display is stored in internal or EPI-attached memory and is scanned to the
display using the LCD controller hardware and appropriate refresh rate and line timings provided
by the application.
The function LCDModeSet() with parameter ui8Mode set to LCD_MODE_RASTER will select the
raster controller mode. This function also sets the required pixel clock frequency. Note that this
must be an integer factor of the system clock frequency so applications must ensure that they
choose an appropriate system clock frequency to allow the required pixel clock to be set. In cases
where the current system clock setting is such that the exact requested pixel clock cannot be set,
LCDModeSet() will set the closest lower pixel clock that can be derived given the current system
clock frequency and will return that frequency to the caller.
Properties of the display being driven can be set using a call to the function LCDRasterConfigSet().
This configures active- or passive-matrix display, how the color palette is used and various parameters
relating to the packing order of pixels in memory. Raster timings and signal polarities are
configured using a call to LCDRasterTimingSet().
The frame buffer, whose layout is described in the following section, is configured using a call to
LCDRasterFrameBufferSet() which accepts parameters indicating the address of the start of the
buffer in memory and its size. Because the frame buffer also contains the pixel format identifier
and color palette in addition to the pixel data, LCDRasterPaletteSet() must be called to initialize the
palette and format header before the raster is enabled. This is required for all pixel formats, even
those which do not require a color lookup table, to ensure correct display.
Once all controller and frame buffer initialization is complete, the display raster can be enabled by
calling LCDRasterEnable(). If the display is to be shut down at any point, LCDRasterDisable() may
be used.
The LCD controller also supports a subpanel mode which may be helpful in memory constrained
systems. This allows the active area on the display to be set to use a number of lines less than the
native height. Lines above or below the active area are filled with a default color. The subpanel may
be configured using LCDRasterSubPanelConfigSet() which defines the split point between active
image and default color and also determines whether the active image area is above or below the
split line. When a subpanel is configured, LCDRasterFrameBufferSet() can be called with a frame
buffer sized for the number of lines in the subpanel rather than the whole screen. The subpanel may
be enabled using LCDRasterSubPanelEnable() and disabled using LCDRasterSubPanelDisable().
19.2.4 Frame Buffer and Palette Formats--帧缓冲与调色板格式
When using raster mode, the frame buffer is stored in local SRAM or EPI- connected SDRAM
and the application is responsible for ensuring that it is formatted correctly for the LCD controller’s
current configuration.
The frame buffer contains two sections:
A header containing the pixel format identifier and palette (color lookup table). This contains
either 16 or 128 16-bit entries.
An array of pixels comprising the image to display.
The frame buffer header is 8 words (or 16 half-word palette entries) long when displaying any pixel
format other than 8 bits-per-pixel in which case it is 128 words (256 half-word palette entries) in
length. Note that the header cannot be removed even when using pixel formats which do not
require a palette.
Each entry in the header comprises a 16-bit half-word containing a 12-bit RGB444 color in the
bottom 12 bits. The top 4 bits of each entry other than the first are reserved and must be set to 0.
The top 4 bits of the first entry contains an identifier informing the LCD controller of the color depth
(1-, 2-, 4- or 8-bpp palettized, or direct color 12-, 16- or 24-bpp) in use for the following image data.
The frame buffer type identifier may be set by calling LCDRasterPaletteSet() or by directly
writing the first half-word of the frame buffer header with LCD_PALETTE_TYPE_1BPP,
LCD_PALETTE_TYPE_2BPP, LCD_PALETTE_TYPE_4BPP, LCD_PALETTE_TYPE_8BPP or
LCD_PALETTE_TYPE_DIRECT.