Software Drivers

xtft.c File Reference


Detailed Description

This file defines all the functions for the XTft driver. See the xtft.h header file for more details on this driver.

 MODIFICATION HISTORY:

 Ver    Who   Date      Changes
 -----  ----  --------  -----------------------------------------------
 1.00a  sg    03/24/08  First release
 2.00a	 ktn   07/06/09	 Added XTft_IntrEnable(), XTft_IntrDisable()and,
			 XTft_GetVsyncStatus() functions to access newly added
			 Interrupt Enable and Status Register.
 3.00a  ktn   10/22/09  Updated driver to use the HAL APIs/macros.
		         Removed the macros XTft_mSetPixel and XTft_mGetPixel.
 3.00a  bss   01/16/12  Updated driver to remove warnings from asserts.
 3.01a  sg    05/30/12  Corrected the brace error introduced in
			 XTft_GetPixel while changing it from macro to
			 function for CR 647750.
 3.02a  bss   11/30/12 CR 690338 - Corrected the brace error introduced in
			 XTft_GetPixel for CR 647750.
 4.00a  bss   01/25/13	 Added support for AXI TFT controller,
			 XTft_WriteReg and XTft_ReadReg functions are updated
			 Removed all functionality associated with DCR access
 

#include "xtft.h"
#include "xtft_charcode.h"

Functions

int XTft_CfgInitialize (XTft *InstancePtr, XTft_Config *ConfigPtr, u32 EffectiveAddr)
void XTft_SetPos (XTft *InstancePtr, u32 ColVal, u32 RowVal)
void XTft_SetPosChar (XTft *InstancePtr, u32 ColVal, u32 RowVal)
void XTft_SetColor (XTft *InstancePtr, u32 FgColor, u32 BgColor)
void XTft_SetPixel (XTft *InstancePtr, u32 ColVal, u32 RowVal, u32 PixelVal)
void XTft_GetPixel (XTft *InstancePtr, u32 ColVal, u32 RowVal, u32 *PixelVal)
void XTft_Write (XTft *InstancePtr, u8 CharValue)
void XTft_Scroll (XTft *InstancePtr)
void XTft_ClearScreen (XTft *InstancePtr)
void XTft_FillScreen (XTft *InstancePtr, u32 ColStartVal, u32 RowStartVal, u32 ColEndVal, u32 RowEndVal, u32 PixelVal)
void XTft_EnableDisplay (XTft *InstancePtr)
void XTft_DisableDisplay (XTft *InstancePtr)
void XTft_ScanReverse (XTft *InstancePtr)
void XTft_ScanNormal (XTft *InstancePtr)
void XTft_SetFrameBaseAddr (XTft *InstancePtr, u32 NewFrameBaseAddr)
void XTft_WriteReg (XTft *InstancePtr, u32 RegOffset, u32 Data)
u32 XTft_ReadReg (XTft *InstancePtr, u32 RegOffset)
void XTft_IntrEnable (XTft *InstancePtr)
void XTft_IntrDisable (XTft *InstancePtr)
int XTft_GetVsyncStatus (XTft *InstancePtr)


Function Documentation

int XTft_CfgInitialize XTft InstancePtr,
XTft_Config ConfigPtr,
u32  EffectiveAddr
 

This function initializes a TFT Driver Instance.

Parameters:
InstancePtr is a pointer to the XTft instance.
ConfigPtr is a pointer to a XTft_Config configuration structure.This structure will contain the requested configuration for the device. Typically, this is a local structure and the content of which will be copied into the configuration structure within XTft.
EffectiveAddr is the device base address in the virtual memory address space. If the address translation is not used then the physical address is passed. Unexpected errors may occur if the address mapping is changed after this function is invoked.
Returns:
  • XST_SUCCESS if successful.
  • XST_FAILURE if unsuccessful.
Note:
None.

void XTft_ClearScreen XTft InstancePtr  ) 
 

This function re-initializes all the pixels to the default background color.

Parameters:
InstancePtr is a pointer to the XTft instance.
Returns:
None.
Note:
None.

void XTft_DisableDisplay XTft InstancePtr  ) 
 

This function disables the TFT display by clearing the Display Enable bit in the Control register.

Parameters:
InstancePtr is a pointer to the XTft instance.
Returns:
None.
Note:
None.

void XTft_EnableDisplay XTft InstancePtr  ) 
 

This function enables the TFT display by setting the Display Enable bit in the Control register.

Parameters:
InstancePtr is a pointer to the XTft instance.
Returns:
None.
Note:
None.

void XTft_FillScreen XTft InstancePtr,
u32  ColStartVal,
u32  RowStartVal,
u32  ColEndVal,
u32  RowEndVal,
u32  PixelVal
 

This function fills the screen with the range defined by the start and end values of column and row with the color passed as argument.

Parameters:
InstancePtr is a pointer to the XTft instance.
ColStartVal is the value of the starting column. The valid values are 0 to (XTFT_DISPLAY_WIDTH - 1).
RowStartVal is the value of the starting row. The valid values are 0 to (XTFT_DISPLAY_HEIGHT - 1).
ColEndVal is the value of the ending column. The valid values are 0 to (XTFT_DISPLAY_WIDTH - 1).
RowEndVal is the value of the ending row. The valid values are 0 to (XTFT_DISPLAY_HEIGHT - 1).
PixelVal represents the color with which it will be filled on screen.
Returns:
None.
Note:
It must be taken care to pass values such that column start position should not exceed column end position, same is the case with row position.

void XTft_GetPixel XTft InstancePtr,
u32  ColVal,
u32  RowVal,
u32 *  PixelVal
 

This function gets the color of the pixel at the given column, row position.

Parameters:
InstancePtr is a pointer to the XTft instance.
ColVal represents the column on the screen. The valid values are 0 to (XTFT_DISPLAY_WIDTH - 1).
RowVal represents the row on the screen. The valid values are 0 to (XTFT_DISPLAY_HEIGHT - 1).
PixelVal stores the color value on the screen pointed by given Column and Row position.
Returns:
None.
Note:
This API is independent of the interface the TFT Controller is connected to. The data is read from the Video Memory.

int XTft_GetVsyncStatus XTft InstancePtr  ) 
 

This function gets the Vsync(Video address latch) status from the Interrupt Enable and Status Register.

Parameters:
InstancePtr is a pointer to the XTft instance.
Returns:
  • TRUE if Vsync pulse has occurred after displaying the current frame.
  • FALSE if the TFT core has not completed displaying the current frame.
Note:
Vsync(Video address latch) Status bit will be cleared by the HW after it loads the address from the Address Register and starts displaying the Frame.

void XTft_IntrDisable XTft InstancePtr  ) 
 

This function disables the Vsync Interrupt in the Interrupt Enable and Status Register.

Parameters:
InstancePtr is a pointer to the XTft instance.
Returns:
None.
Note:
None.

void XTft_IntrEnable XTft InstancePtr  ) 
 

This function enables the Vsync Interrupt in the Interrupt Enable and Status Register.

Parameters:
InstancePtr is a pointer to the XTft instance.
Returns:
None.
Note:
None.

u32 XTft_ReadReg XTft InstancePtr,
u32  RegOffset
 

Read a value from a TFT register. A 32 bit read is performed.

Parameters:
InstancePtr is a pointer to the XTft instance.
RegOffset is the register offset from the base to read from.
Returns:
Data read from the register.
Note:
None.

void XTft_ScanNormal XTft InstancePtr  ) 
 

This function enables normal scan by clearing the Display Scan Control(DPS) bit in the Control register.

Parameters:
InstancePtr is a pointer to the XTft instance.
Returns:
None.
Note:
None.

void XTft_ScanReverse XTft InstancePtr  ) 
 

This function enables reverse scan by setting the Display Scan Control(DPS) bit in the Control register.

Parameters:
InstancePtr is a pointer to the XTft instance.
Returns:
None.
Note:
By default the scan direction is reverse, the image we see in reverse scan mode is the horizontal and vertical mirror image of the image in normal scan mode.

void XTft_Scroll XTft InstancePtr  ) 
 

This function inserts a new blank line at the bottom of the screen, it deletes the first line and moves the remaining lines up by one line.

Parameters:
InstancePtr is a pointer to the XTft instance.
Returns:
None.
Note:
None.

void XTft_SetColor XTft InstancePtr,
u32  FgColor,
u32  BgColor
 

This function changes the color values in the instance structure of driver.

Parameters:
InstancePtr is a pointer to the XTft instance.
FgColor is the color with which member FgColor of Instance structure is updated.
BgColor is the color with which member BgColor of Instance structure is updated.
Returns:
None.
Note:
Color Values must be 32bit. They can range from 0x0 to 0xFFFFFFFF, out of these only 18 bits are valid data. These 18 bits contain the Red, Green, Blue color values with 6 bits each and bit positions as Red[8-13], Green[16-21], Blue[24-29].

void XTft_SetFrameBaseAddr XTft InstancePtr,
u32  NewFrameBaseAddr
 

This function changes the Video Memory Base address stored in the Address Register.

Parameters:
InstancePtr is a pointer to the XTft instance.
NewFrameBaseAddr is the new memory address value to be written to the Address register.
Returns:
None.
Note:
The new memory address must be in the address range of external memory and it must be taken care that 2MB memory is available from this new address so that frame data to 640*480 screen can be written.

void XTft_SetPixel XTft InstancePtr,
u32  ColVal,
u32  RowVal,
u32  PixelVal
 

This function sets the pixel with the given color at the given column, row position.

Parameters:
InstancePtr is a pointer to the XTft instance.
ColVal represents the column on the screen. The valid values are 0 to (XTFT_DISPLAY_WIDTH - 1).
RowVal represents the row on the screen. The valid values are 0 to (XTFT_DISPLAY_HEIGHT - 1).
PixelVal represents the color with which it will be filled on screen.
Returns:
None.
Note:
This API is independent of the interface the TFT Controller is connected to. The data is written to the Video Memory.

void XTft_SetPos XTft InstancePtr,
u32  ColVal,
u32  RowVal
 

This function updates the column, row position in the Instance structure of driver.

Parameters:
InstancePtr is a pointer to the XTft instance.
ColVal is the column number to which ColVal member of Instance structure is updated. The valid values are 0 to (XTFT_DISPLAY_WIDTH - 1).
RowVal is the row number to which RowVal member of Instance structure is updated. The valid values are 0 to (XTFT_DISPLAY_HEIGHT - 1).
Returns:
None.
Note:
None.

void XTft_SetPosChar XTft InstancePtr,
u32  ColVal,
u32  RowVal
 

This function changes the column, row position in the Instance structure of driver. It is used to correct the position for the next character to be written if column and row position cross limits.

Parameters:
InstancePtr is a pointer to the XTft instance.
ColVal is the column number to which ColVal member of Instance structure is updated. If ColVal crosses (XTFT_DISPLAY_WIDTH - 1) - XTFT_CHAR_WIDTH, position is moved to next line. The valid values are 0 to (XTFT_DISPLAY_WIDTH - 1).
RowVal is the row number to which RowVal member of Instance structure is updated. If RowVal crosses (XTFT_DISPLAY_HEIGHT - 1)- XTFT_CHAR_HEIGHT, the first line will be deleted. The valid values are 0 to (XTFT_DISPLAY_HEIGHT - 1).
Returns:
None.
Note:
This function differs from the function XTft_SetPos because you cannot move to any position on the screen as we have to check for enough space for a character to be written.

void XTft_Write XTft InstancePtr,
u8  CharValue
 

This function performs one of the following three operations based on the CharValue passed :

  • Move the position to the next line at the same position.
  • Move the position to the next line.
  • Write a particular character and update the column position by the width of the character.

Parameters:
InstancePtr is a pointer to the XTft instance.
CharValue is the ASCII code value of the character to be written.
Returns:
None.
Note:
As the character bitmap array does not support some of the ASCII values, to support some of those which carry significance in display are added in the switch case. If there is a necessity for any other characters, it can be added here.

void XTft_WriteReg XTft InstancePtr,
u32  RegOffset,
u32  Data
 

Write a value to a TFT register. A 32 bit write is performed.

Parameters:
InstancePtr is a pointer to the XTft instance.
RegOffset is the register offset from the base to write to.
Data is the data written to the register.
Returns:
None.
Note:
None.
Copyright @ 1995-2014 Xilinx, Inc. All rights reserved.