emWin driver GUIDRV_Lin

This driver supports all display controllers with linear video memory accessible via direct interface. It can be used with
and without a display controller. The driver does only manage the contents of the video memory. It does not send any
commands to the display controller or assumes any specific registers. So it is independent of the register interface of
the display controller and can be used for managing each linear mapped video memory.

Supported hardware

Controllers

The driver supports all systems with linear mapped video memory.

Bits per pixel

Supported color depths are 1, 2, 4, 8, 16, 24 and 32 bits per pixel.

Interfaces

The driver supports a direct bus interface from the CPU to the video memory. The video memory needs to be accessible
8, 16 and 32 bit wise.

Color depth and display orientation

The driver consists of several files. They are named GUIDRV_Lin_[O]_BPP.c. where the optional ’O’ stands for the
desired display orientation and ’BPP’ for the the color depth. The following table shows the driver files and the
configuration macros which should be used to create and link the driver during the initialization:

Identifier Color depth and orientation
GUIDRV_LIN_1 1bpp, default orientation
GUIDRV_LIN_2 2bpp, default orientation
GUIDRV_LIN_4 4bpp, default orientation
GUIDRV_LIN_8 8bpp, default orientation
GUIDRV_LIN_16 16bpp, default orientation
GUIDRV_LIN_OX_16 16bpp, X axis mirrored
GUIDRV_LIN_OY_16 16bpp, Y axis mirrored
GUIDRV_LIN_OS_16 16bpp, X and Y swapped
GUIDRV_LIN_OSX_16 16bpp, X axis mirrored, X and Y swapped
GUIDRV_LIN_OSY_16 16bpp, Y axis mirrored, X and Y swapped
GUIDRV_LIN_24 24bpp, default orientation
GUIDRV_LIN_OX_24 24bpp, X axis mirrored
GUIDRV_LIN_OY_24 24bpp, Y axis mirrored
GUIDRV_LIN_OS_24 24bpp, X and Y swapped
GUIDRV_LIN_OSX_24 24bpp, X axis mirrored, X and Y swapped
GUIDRV_LIN_OSY_24 24bpp, Y axis mirrored, X and Y swapped
GUIDRV_LIN_32 32bpp, default orientation
GUIDRV_LIN_OX_32 32bpp, X axis mirrored
GUIDRV_LIN_OY_32 32bpp, Y axis mirrored
GUIDRV_LIN_OS_32 32bpp, X and Y swapped
GUIDRV_LIN_OSX_32 32bpp, X axis mirrored, X and Y swapped
GUIDRV_LIN_OSY_32 32bpp, Y axis mirrored, X and Y swapped

The table above shows identifiers which can be used to select the driver. Each combination of orientation and color
depth is possible. Please note that currently not all combinations are shipped with the driver. If the required
combination is not available, please send a request to obtain the required combination.

Driver selection

To use GUIDRV_Lin for the given display, the following command can be used e.g.:

GUI_DEVICE_CreateAndLink(GUIDRV_LIN_OX_16, GUICC_565, 0, 0);

Please refer to the emWin documentation to get more information about using the proper palette mode.

Display data RAM organization

The picture above shows the relation between the display memory and the pixels of the LCD in terms of the color depth
and the endian mode.

Little endian video mode

Least significant bits are used and output first. The least significant bits are for the first (left-most) pixel.

Big endian video mode

Most significant bits are used and output first. The most significant bits are for the first (left-most) pixel.

RAM requirements of the driver

None.

Available configuration macros (compile time configuration)

The following table lists the macros which must be defined for hardware access:

Macro Description
LCD_ENDIAN_BIG Should be set to 1 for big endian mode, 0 (default) for little endian mode.

Available configuraion routines (run-time configuration)

The following table lists the available run-time configuration routines:

Routine Description
LCD_SetSizeEx() Changes the size of the visible area.
LCD_SetVRAMAddrEx() Changes the video RAM start address.
LCD_SetVSizeEx() Changes the size of the virtual display area.

Configuration example

The following shows how to create a display driver device with this driver and how to configure it:

void LCD_X_Config(void) {
  //
  // Set display driver and color conversion
  //
  GUI_DEVICE_CreateAndLink(GUIDRV_LIN_8,    // Display driver
                           GUICC_8666,      // Color conversion
                           0, 0);
  //
  // Display driver configuration
  //
  LCD_SetSizeEx    (0, 320, 240);           // Physical display size in pixels
  LCD_SetVSizeEx   (0, 320, 480);           // Virtual display size in pixels
  LCD_SetVRAMAddrEx(0, (void *)0x20000000); // Video RAM start address
}

Using the Lin driver in systems with cache memory

The rules to follow are quite simple:

Rule 1

All caches (if applicable, as in your case) should be fully enabled. This means I- and D- caches in systems with
separate caches.

Rule 2

All Code and data should be placed in cacheable areas to achieve maximum performance. If other parts of the
application require some or all data to be placed in non-cacheable areas, this is not a problem but may degrade
performance.

Rule 3

The only exception to Rule 2 is that the display memory (which is really a shared memory area, accessed by both
the CPU and the LCD-controller DMA) should be uncached. In many systems with MMU, this can be achieved by
mapping the RAM twice into the virtual address space: At its normal address, the RAM is cached, at the second
address, it is uncached. The address of the VRAM given to the driver should be the uncached address.