### Xilinx Processor IP Library

<hl>Software Drivers</hl>

Main Page | Data Structures | File List | Data Fields | Globals

# xuartlite.h File Reference

## Detailed Description

## Data Structures

struct | XUartLite_Stats
struct | XUartLite_Buffer
struct | XUartLite_Config
struct | XUartLite

## Typedefs

typedef void(* | XUartLite_Handler )(void *CallBackRef, unsigned int ByteCount)

## Functions

int | XUartLite_Initialize (XUartLite *InstancePtr, u16 DeviceId)
int | XUartLite_CfgInitialize (XUartLite *InstancePtr, XUartLite_Config *Config, u32 EffectiveAddr)
void | XUartLite_ResetFifos (XUartLite *InstancePtr)
unsigned int | XUartLite_Send (XUartLite *InstancePtr, u8 *DataBufferPtr, unsigned int NumBytes)
unsigned int | XUartLite_Recv (XUartLite *InstancePtr, u8 *DataBufferPtr, unsigned int NumBytes)
int | XUartLite_IsSending (XUartLite *InstancePtr)
void | XUartLite_GetStats (XUartLite *InstancePtr, XUartLite_Stats *StatsPtr)
void | XUartLite_ClearStats (XUartLite *InstancePtr)
int | XUartLite_SelfTest (XUartLite *InstancePtr)
void | XUartLite_EnableInterrupt (XUartLite *InstancePtr)
void | XUartLite_DisableInterrupt (XUartLite *InstancePtr)
void | XUartLite_SetRecvHandler (XUartLite *InstancePtr, XUartLite_Handler FuncPtr, void *CallBackRef)
void | XUartLite_SetSendHandler (XUartLite *InstancePtr, XUartLite_Handler FuncPtr, void *CallBackRef)
void | XUartLite_InterruptHandler (XUartLite *InstancePtr)

## Typedef Documentation

typedef void(* XUartLite_Handler)(void *CallBackRef, unsigned int ByteCount)

| Callback function. The first argument is a callback reference passed in by the upper layer when setting the callback functions, and passed back to the upper layer when the callback is invoked. The second argument is the ByteCount which is the number of bytes that actually moved from/to the buffer provided in the _Send/_Receive call.

## Function Documentation

int XUartLite_CfgInitialize | ( | XUartLite * | InstancePtr,
|  | XUartLite_Config * | Config,
|  | u32 | EffectiveAddr
| ) |

Initialize a XUartLite instance. The receive and transmit FIFOs of the UART are not flushed, so the user may want to flush them. The hardware device does not have any way to disable the receiver such that any valid data may be present in the receive FIFO. This function disables the UART interrupt. The baudrate and format of the data are fixed in the hardware at hardware build time.

Parameters:

  | InstancePtr | is a pointer to the XUartLite instance.
  | Config | is a reference to a structure containing information about a specific UART Lite device. This function initializes an InstancePtr object for a specific device specified by the contents of Config. This function can initialize multiple instance objects with the use of multiple calls giving different Config information on each call.

  EffectiveAddr

  is the device base address in the virtual memory address space. The caller is responsible for keeping the address mapping from EffectiveAddr to the device physical base address unchanged once this function is invoked. Unexpected errors may occur if the address mapping changes after this function is called. If address translation is not used, use Config->BaseAddress for this parameters, passing the physical address instead.

Returns:
  - XST_SUCCESS if everything starts up as expected.

Note:
  The Config pointer argument is not used by this function, but is provided to keep the function signature consistent with other drivers.

void XUartLite_ClearStats | ( | XUartLite * | InstancePtr | ) |

This function zeros the statistics for the given instance.

Parameters:

  | InstancePtr | is a pointer to the XUartLite instance.

Returns:
  None.

Note:
  None.

void XUartLite_DisableInterrupt | ( | XUartLite * | InstancePtr | ) |

This function disables the UART interrupt. After calling this function, data may still be received by the UART but no interrupt will be generated since the hardware device has no way to disable the receiver.

Parameters:

  | InstancePtr | is a pointer to the XUartLite instance.

Returns:
  None.

Note:
  None.

void XUartLite_EnableInterrupt | ( | XUartLite * | InstancePtr | ) |

This function enables the UART interrupt such that an interrupt will occur when data is received or data has been transmitted. The device contains 16 byte receive and transmit FIFOs such that an interrupt is generated anytime there is data in the receive FIFO and when the transmit FIFO transitions from not empty to empty.

Parameters:

  | InstancePtr | is a pointer to the XUartLite instance.

Returns:
  None.

Note:
  None.

void XUartLite_GetStats | ( | XUartLite * | InstancePtr,
|  | XUartLite_Stats * | StatsPtr
| ) |

Returns a snapshot of the current statistics in the structure specified.

Parameters:

  | InstancePtr | is a pointer to the XUartLite instance.
  | StatsPtr | is a pointer to a XUartLiteStats structure to where the statistics are to be copied.

Returns:
  None.

Note:
  None.

int XUartLite_Initialize | ( | XUartLite * | InstancePtr,
|  | u16 | DeviceId
| ) |

Initialize a XUartLite instance. The receive and transmit FIFOs of the UART are not flushed, so the user may want to flush them. The hardware device does not have any way to disable the receiver such that any valid data may be present in the receive FIFO. This function disables the UART interrupt. The baudrate and format of the data are fixed in the hardware at hardware build time.

Parameters:

  | InstancePtr | is a pointer to the XUartLite instance.
  | DeviceId | is the unique id of the device controlled by this XUartLite instance. Passing in a device id associates the generic XUartLite instance to a specific device, as chosen by the caller or application developer.

Returns:
  - XST_SUCCESS if everything starts up as expected.
  - XST_DEVICE_NOT_FOUND if the device is not found in the configuration table.

Note:
  None.

void XUartLite_InterruptHandler | ( | XUartLite * | InstancePtr | ) |

This function is the interrupt handler for the UART lite driver. It must be connected to an interrupt system by the user such that it is called when an interrupt for any UART lite occurs. This function does not save or restore the processor context such that the user must ensure this occurs.

Parameters:

  | InstancePtr | contains a pointer to the instance of the UART that the interrupt is for.

Returns:
  None.

Note:
  None.

int XUartLite_IsSending | ( | XUartLite * | InstancePtr | ) |

This function determines if the specified UART is sending data. If the transmitter register is not empty, it is sending data.

Parameters:

  | InstancePtr | is a pointer to the XUartLite instance.

Returns:
  A value of TRUE if the UART is sending data, otherwise FALSE.

Note:
  None.

unsigned int XUartLite_Recv | ( | XUartLite * | InstancePtr,
|  | u8 * | DataBufferPtr,
|  | unsigned int | NumBytes
| ) |

This function will attempt to receive a specified number of bytes of data from the UART and store it into the specified buffer. This function is designed for either polled or interrupt driven modes. It is non-blocking such that it will return if no data has already received by the UART.

In a polled mode, this function will only receive as much data as the UART can buffer in the FIFO. The application may need to call it repeatedly to receive a buffer. Polled mode is the default mode of operation for the driver.

In interrupt mode, this function will start receiving and then the interrupt handler of the driver will continue receiving data until the buffer has been received. A callback function, as specified by the application, will be called to indicate the completion of receiving the buffer or when any receive errors or timeouts occur. Interrupt mode must be enabled using the SetOptions function.

Parameters:

  | InstancePtr | is a pointer to the XUartLite instance.
  | BufferPtr | is pointer to buffer for data to be received into
  | NumBytes | is the number of bytes to be received. A value of zero will stop a previous receive operation that is in progress in interrupt mode.

Returns:
  The number of bytes received.

Note:
  The number of bytes is not asserted so that this function may be called with a value of zero to stop an operation that is already in progress.

void XUartLite_ResetFifos | ( | XUartLite * | InstancePtr | ) |

This function resets the FIFOs, both transmit and receive, of the UART such that they are emptied. Since the UART does not have any way to disable it from receiving data, it may be necessary for the application to reset the FIFOs to get rid of any unwanted data.

Parameters:

  | InstancePtr | is a pointer to the XUartLite instance .

Returns:
  None.

Note:
  None.

int XUartLite_SelfTest | ( | XUartLite * | InstancePtr | ) |

Runs a self-test on the device hardware. Since there is no way to perform a loopback in the hardware, this test can only check the state of the status register to verify it is correct. This test assumes that the hardware device is still in its reset state, but has been initialized with the Initialize function.

Parameters:

  | InstancePtr | is a pointer to the XUartLite instance.

Returns:
  - XST_SUCCESS if the self-test was successful.
  - XST_FAILURE if the self-test failed, the status register value was not correct

Note:
  None.

unsigned int XUartLite_Send | ( | XUartLite * | InstancePtr,
|  | u8 * | DataBufferPtr,
|  | unsigned int | NumBytes
| ) |

This functions sends the specified buffer of data using the UART in either polled or interrupt driven modes. This function is non-blocking such that it will return before the data has been sent by the UART. If the UART is busy sending data, it will return and indicate zero bytes were sent.

In a polled mode, this function will only send as much data as the UART can buffer in the FIFO. The application may need to call it repeatedly to send a buffer.

In interrupt mode, this function will start sending the specified buffer and then the interrupt handler of the driver will continue sending data until the buffer has been sent. A callback function, as specified by the application, will be called to indicate the completion of sending the buffer.

Parameters:

  | InstancePtr | is a pointer to the XUartLite instance.
  | BufferPtr | is pointer to a buffer of data to be sent.
  | NumBytes | contains the number of bytes to be sent. A value of zero will stop a previous send operation that is in progress in interrupt mode. Any data that was already put into the transmit FIFO will be sent.

Returns:
  The number of bytes actually sent.

Note:
  The number of bytes is not asserted so that this function may be called with a value of zero to stop an operation that is already in progress.

void XUartLite_SetRecvHandler | ( | XUartLite * | InstancePtr,
|  | XUartLite_Handler | FuncPtr,
|  | void * | CallBackRef
| ) |

This function sets the handler that will be called when an event (interrupt) occurs in the driver. The purpose of the handler is to allow application specific processing to be performed.

Parameters:

  | InstancePtr | is a pointer to the XUartLite instance.
  | FuncPtr | is the pointer to the callback function.
  | CallBackRef | is the upper layer callback reference passed back when the callback function is invoked.

Returns:
  None.

Note:
  There is no assert on the CallBackRef since the driver doesn't know what it is (nor should it)

void XUartLite_SetSendHandler | ( | XUartLite * | InstancePtr,
|  | XUartLite_Handler | FuncPtr,
|  | void * | CallBackRef
| ) |

This function sets the handler that will be called when an event (interrupt) occurs in the driver. The purpose of the handler is to allow application specific processing to be performed.

Parameters:

  | InstancePtr | is a pointer to the XUartLite instance .
  | FuncPtr | is the pointer to the callback function.
  | CallBackRef | is the upper layer callback reference passed back when the callback function is invoked.

Returns:
  None.

Note:
  There is no assert on the CallBackRef since the driver doesn't know what it is (nor should it)

Copyright © 1995-2009 Xilinx, Inc. All rights reserved.