uartlite
Vitis Drivers API Documentation
 All Data Structures Files Functions Variables Typedefs Macros Groups Pages
Overview

Data Structures

struct  XUartLite_Stats
 Statistics for the XUartLite driver. More...
 
struct  XUartLite_Buffer
 Buffer descriptor for send and receive operations. More...
 
struct  XUartLite_Config
 Holds configuration information for the UART Lite device. More...
 
struct  XUartLite
 Driver instance data for the UART Lite. More...
 

Macros

#define XUartLite_UpdateStats(InstancePtr, StatusRegister)
 Updates the statistics of the instance. More...
 
#define XUartLite_WriteReg(BaseAddress, RegOffset, Data)   XUartLite_Out32((BaseAddress) + (RegOffset), (u32)(Data))
 Writes a value to a UartLite register. More...
 
#define XUartLite_ReadReg(BaseAddress, RegOffset)   XUartLite_In32((BaseAddress) + (RegOffset))
 Reads a value from a UartLite register. More...
 
#define XUartLite_SetControlReg(BaseAddress, Mask)   XUartLite_WriteReg((BaseAddress), XUL_CONTROL_REG_OFFSET, (Mask))
 Sets the contents of the control register. More...
 
#define XUartLite_GetStatusReg(BaseAddress)   XUartLite_ReadReg((BaseAddress), XUL_STATUS_REG_OFFSET)
 Returns the contents of the status register. More...
 
#define XUartLite_IsReceiveEmpty(BaseAddress)
 Checks if the receiver has data. More...
 
#define XUartLite_IsTransmitFull(BaseAddress)
 Checks if the transmitter is full. More...
 
#define XUartLite_IsIntrEnabled(BaseAddress)
 Checks if the interrupt is enabled. More...
 
#define XUartLite_EnableIntr(BaseAddress)   XUartLite_SetControlReg((BaseAddress), XUL_CR_ENABLE_INTR)
 Enables the device interrupt. More...
 
#define XUartLite_DisableIntr(BaseAddress)   XUartLite_SetControlReg((BaseAddress), 0)
 Disables the device interrupt. More...
 

Typedefs

typedef void(* XUartLite_Handler )(void *CallBackRef, unsigned int ByteCount)
 Defines the callback function type for send and receive operations. More...
 

Functions

int XUartLite_CfgInitialize (XUartLite *InstancePtr, XUartLite_Config *Config, UINTPTR EffectiveAddr)
 Initializes a XUartLite instance. More...
 
unsigned int XUartLite_Send (XUartLite *InstancePtr, u8 *DataBufferPtr, unsigned int NumBytes)
 Sends the specified buffer of data using the UART. More...
 
unsigned int XUartLite_Recv (XUartLite *InstancePtr, u8 *DataBufferPtr, unsigned int NumBytes)
 Receives a specified number of bytes of data from the UART. More...
 
void XUartLite_ResetFifos (XUartLite *InstancePtr)
 Resets the FIFOs, both transmit and receive, of the UART. More...
 
int XUartLite_IsSending (XUartLite *InstancePtr)
 Determines if the specified UART is sending data. More...
 
unsigned int XUartLite_SendBuffer (XUartLite *InstancePtr)
 Sends a previously specified buffer of data to the UART. More...
 
unsigned int XUartLite_ReceiveBuffer (XUartLite *InstancePtr)
 Receives a previously specified buffer of data from the UART. More...
 
u8 XUartLite_GetSR (XUartLite *InstancePtr)
 Reads the status register and updates the error stats before returning the status register value. More...
 
int XUartLite_Initialize (XUartLite *InstancePtr, UINTPTR BaseAddress)
 Initializes a XUartLite instance. More...
 
XUartLite_Config * XUartLite_LookupConfig (UINTPTR BaseAddress)
 Looks up the device configuration based on the unique device ID or base address. More...
 
void XUartLite_GetStats (XUartLite *InstancePtr, XUartLite_Stats *StatsPtr)
 Returns a snapshot of the current statistics in the structure specified. More...
 
void XUartLite_ClearStats (XUartLite *InstancePtr)
 Zeros the statistics for the given instance. More...
 
int XUartLite_SelfTest (XUartLite *InstancePtr)
 Runs a self-test on the device hardware. More...
 
void XUartLite_EnableInterrupt (XUartLite *InstancePtr)
 Enables the UART interrupt. More...
 
void XUartLite_DisableInterrupt (XUartLite *InstancePtr)
 Disables the UART interrupt. More...
 
void XUartLite_SetRecvHandler (XUartLite *InstancePtr, XUartLite_Handler FuncPtr, void *CallBackRef)
 Sets the receive callback handler. More...
 
void XUartLite_SetSendHandler (XUartLite *InstancePtr, XUartLite_Handler FuncPtr, void *CallBackRef)
 Sets the send callback handler. More...
 
void XUartLite_InterruptHandler (XUartLite *InstancePtr)
 Handles interrupts for the UART Lite driver. More...
 
void XUartLite_SendByte (UINTPTR BaseAddress, u8 Data)
 Sends a single byte using the UART. More...
 
u8 XUartLite_RecvByte (UINTPTR BaseAddress)
 Receives a single byte using the UART. More...
 

Variables

XUartLite_Config XUartLite_ConfigTable [XPAR_XUARTLITE_NUM_INSTANCES]
 Holds the configuration table for UART Lite devices. More...
 
XUartLite_Config XUartLite_ConfigTable []
 Holds the configuration entry for each UART Lite instance. More...
 

DCR bus bridge configuration

Set to 1 if the UartLite device is accessed through a DCR bus connected to a bridge.

#define XPAR_XUARTLITE_USE_DCR_BRIDGE   0
 DCR bus bridge access flag. More...
 

UART Lite register offsets

#define XUL_RX_FIFO_OFFSET   0
 Receive FIFO, read only. More...
 
#define XUL_TX_FIFO_OFFSET   4
 Transmit FIFO, write only. More...
 
#define XUL_STATUS_REG_OFFSET   8
 Status register, read only. More...
 
#define XUL_CONTROL_REG_OFFSET   12
 Control register, write only. More...
 

Control register bit positions

#define XUL_CR_ENABLE_INTR   0x10
 Enable interrupt. More...
 
#define XUL_CR_FIFO_RX_RESET   0x02
 Reset receive FIFO. More...
 
#define XUL_CR_FIFO_TX_RESET   0x01
 Reset transmit FIFO. More...
 

Status register bit positions

#define XUL_SR_PARITY_ERROR   0x80
 Parity error detected. More...
 
#define XUL_SR_FRAMING_ERROR   0x40
 Framing error detected. More...
 
#define XUL_SR_OVERRUN_ERROR   0x20
 Overrun error detected. More...
 
#define XUL_SR_INTR_ENABLED   0x10
 Interrupt enabled. More...
 
#define XUL_SR_TX_FIFO_FULL   0x08
 Transmit FIFO full. More...
 
#define XUL_SR_TX_FIFO_EMPTY   0x04
 Transmit FIFO empty. More...
 
#define XUL_SR_RX_FIFO_FULL   0x02
 Receive FIFO full. More...
 
#define XUL_SR_RX_FIFO_VALID_DATA   0x01
 Data in receive FIFO. More...
 

FIFO and serial line constants

Fixed hardware parameters for the UartLite IP.

#define XUL_FIFO_SIZE   16
 Transmit/receive FIFO size in bytes. More...
 
#define XUL_STOP_BITS   1
 Stop bits, fixed at 1. More...
 

Parity definitions

#define XUL_PARITY_NONE   0
 No parity. More...
 
#define XUL_PARITY_ODD   1
 Odd parity. More...
 
#define XUL_PARITY_EVEN   2
 Even parity. More...
 

I/O access method macros

Define the appropriate I/O access method to memory mapped I/O or DCR.

#define XUartLite_In32   Xil_In32
 Memory-mapped 32-bit input operation. More...
 
#define XUartLite_Out32   Xil_Out32
 Memory-mapped 32-bit output operation. More...
 

Macro Definition Documentation

#define XPAR_XUARTLITE_USE_DCR_BRIDGE   0

DCR bus bridge access flag.

#define XUartLite_DisableIntr (   BaseAddress)    XUartLite_SetControlReg((BaseAddress), 0)

Disables the device interrupt.

The control register cannot be read, so this macro just clears all bits. Since the only other ones are the FIFO reset bits, this works without side effects.

Parameters
[in]BaseAddressBase address of the device.
Note
C-style Signature: void XUartLite_DisableIntr(u32 BaseAddress);
#define XUartLite_EnableIntr (   BaseAddress)    XUartLite_SetControlReg((BaseAddress), XUL_CR_ENABLE_INTR)

Enables the device interrupt.

The control register cannot be read, so this macro just writes the enable interrupt bit and clears all others. Since the only other ones are the FIFO reset bits, this works without side effects.

Parameters
[in]BaseAddressBase address of the device.
Note
C-style Signature: void XUartLite_EnableIntr(u32 BaseAddress);
#define XUartLite_GetStatusReg (   BaseAddress)    XUartLite_ReadReg((BaseAddress), XUL_STATUS_REG_OFFSET)

Returns the contents of the status register.

Use the XUL_SR_* constants defined above to interpret the bit-mask returned.

Parameters
[in]BaseAddressBase address of the device.
Returns
A 32-bit value representing the contents of the status register.
Note
C-style Signature: u32 XUartLite_GetStatusReg(u32 BaseAddress);

Referenced by XUartLite_GetSR().

#define XUartLite_In32   Xil_In32

Memory-mapped 32-bit input operation.

#define XUartLite_IsIntrEnabled (   BaseAddress)
Value:
#define XUL_SR_INTR_ENABLED
Interrupt enabled.
Definition: xuartlite_l.h:104
#define XUartLite_GetStatusReg(BaseAddress)
Returns the contents of the status register.
Definition: xuartlite_l.h:235

Checks if the interrupt is enabled.

Parameters
[in]BaseAddressBase address of the device.
Returns
TRUE if the interrupt is enabled, FALSE otherwise.
Note
C-style Signature: int XUartLite_IsIntrEnabled(u32 BaseAddress);
#define XUartLite_IsReceiveEmpty (   BaseAddress)
Value:
#define XUartLite_GetStatusReg(BaseAddress)
Returns the contents of the status register.
Definition: xuartlite_l.h:235
#define XUL_SR_RX_FIFO_VALID_DATA
Data in receive FIFO.
Definition: xuartlite_l.h:108

Checks if the receiver has data.

Parameters
[in]BaseAddressBase address of the device.
Returns
TRUE if the receiver is empty, FALSE if there is data present.
Note
C-style Signature: int XUartLite_IsReceiveEmpty(u32 BaseAddress);

Referenced by XUartLite_RecvByte().

#define XUartLite_IsTransmitFull (   BaseAddress)
Value:
#define XUartLite_GetStatusReg(BaseAddress)
Returns the contents of the status register.
Definition: xuartlite_l.h:235
#define XUL_SR_TX_FIFO_FULL
Transmit FIFO full.
Definition: xuartlite_l.h:105

Checks if the transmitter is full.

Parameters
[in]BaseAddressBase address of the device.
Returns
TRUE if the transmitter is full, FALSE otherwise.
Note
C-style Signature: int XUartLite_IsTransmitFull(u32 BaseAddress);

Referenced by XUartLite_SendByte().

#define XUartLite_Out32   Xil_Out32

Memory-mapped 32-bit output operation.

#define XUartLite_ReadReg (   BaseAddress,
  RegOffset 
)    XUartLite_In32((BaseAddress) + (RegOffset))

Reads a value from a UartLite register.

A 32 bit read is performed.

Parameters
[in]BaseAddressBase address of the UartLite device.
[in]RegOffsetRegister offset from the base to read from.
Returns
Data read from the register.
Note
C-style signature: u32 XUartLite_ReadReg(u32 BaseAddress, u32 RegOffset)

Referenced by XUartLite_ReceiveBuffer(), and XUartLite_RecvByte().

#define XUartLite_SetControlReg (   BaseAddress,
  Mask 
)    XUartLite_WriteReg((BaseAddress), XUL_CONTROL_REG_OFFSET, (Mask))

Sets the contents of the control register.

Use the XUL_CR_* constants defined above to create the bit-mask to be written to the register.

Parameters
[in]BaseAddressBase address of the device.
[in]MaskThe 32-bit value to write to the control register.
Note
C-style Signature: void XUartLite_SetControlReg(u32 BaseAddress, u32 Mask);
#define XUartLite_UpdateStats (   InstancePtr,
  StatusRegister 
)
Value:
{ \
if ((StatusRegister) & XUL_SR_OVERRUN_ERROR) \
{ \
(InstancePtr)->Stats.ReceiveOverrunErrors++; \
} \
if ((StatusRegister) & XUL_SR_PARITY_ERROR) \
{ \
(InstancePtr)->Stats.ReceiveParityErrors++; \
} \
if ((StatusRegister) & XUL_SR_FRAMING_ERROR) \
{ \
(InstancePtr)->Stats.ReceiveFramingErrors++; \
} \
}
#define XUL_SR_OVERRUN_ERROR
Overrun error detected.
Definition: xuartlite_l.h:103
#define XUL_SR_FRAMING_ERROR
Framing error detected.
Definition: xuartlite_l.h:102
#define XUL_SR_PARITY_ERROR
Parity error detected.
Definition: xuartlite_l.h:101

Updates the statistics of the instance.

Parameters
[in]InstancePtrPointer to the XUartLite instance.
[in]StatusRegisterContents of the UART status register to update the statistics with.
Note
Signature: void XUartLite_UpdateStats(XUartLite *InstancePtr, u32 StatusRegister)

Referenced by XUartLite_GetSR().

#define XUartLite_WriteReg (   BaseAddress,
  RegOffset,
  Data 
)    XUartLite_Out32((BaseAddress) + (RegOffset), (u32)(Data))

Writes a value to a UartLite register.

A 32 bit write is performed.

Parameters
[in]BaseAddressBase address of the UartLite device.
[in]RegOffsetRegister offset from the base to write to.
[in]DataData written to the register.
Note
C-style signature: void XUartLite_WriteReg(u32 BaseAddress, u32 RegOffset, u32 Data)

Referenced by XUartLite_CfgInitialize(), XUartLite_DisableInterrupt(), XUartLite_EnableInterrupt(), XUartLite_ReceiveBuffer(), XUartLite_Recv(), XUartLite_ResetFifos(), XUartLite_Send(), XUartLite_SendBuffer(), and XUartLite_SendByte().

#define XUL_CR_ENABLE_INTR   0x10
#define XUL_CR_FIFO_RX_RESET   0x02

Reset receive FIFO.

Referenced by XUartLite_ResetFifos().

#define XUL_CR_FIFO_TX_RESET   0x01

Reset transmit FIFO.

Referenced by XUartLite_ResetFifos().

#define XUL_FIFO_SIZE   16

Transmit/receive FIFO size in bytes.

Fixed to 16 in the UartLite IP, not configurable, and not used by the driver.

#define XUL_PARITY_EVEN   2

Even parity.

#define XUL_PARITY_NONE   0

No parity.

#define XUL_PARITY_ODD   1

Odd parity.

#define XUL_RX_FIFO_OFFSET   0

Receive FIFO, read only.

Referenced by XUartLite_ReceiveBuffer(), and XUartLite_RecvByte().

#define XUL_SR_FRAMING_ERROR   0x40

Framing error detected.

#define XUL_SR_INTR_ENABLED   0x10

Interrupt enabled.

Referenced by XUartLite_ResetFifos().

#define XUL_SR_OVERRUN_ERROR   0x20

Overrun error detected.

#define XUL_SR_PARITY_ERROR   0x80

Parity error detected.

#define XUL_SR_RX_FIFO_FULL   0x02

Receive FIFO full.

Referenced by XUartLite_InterruptHandler().

#define XUL_SR_RX_FIFO_VALID_DATA   0x01

Data in receive FIFO.

Referenced by XUartLite_InterruptHandler(), and XUartLite_ReceiveBuffer().

#define XUL_SR_TX_FIFO_EMPTY   0x04

Transmit FIFO empty.

Referenced by XUartLite_InterruptHandler(), XUartLite_IsSending(), and XUartLite_SelfTest().

#define XUL_SR_TX_FIFO_FULL   0x08

Transmit FIFO full.

Referenced by XUartLite_SendBuffer().

#define XUL_STATUS_REG_OFFSET   8

Status register, read only.

#define XUL_STOP_BITS   1

Stop bits, fixed at 1.

Baud, parity, and data bits are fixed on a per-instance basis.

#define XUL_TX_FIFO_OFFSET   4

Transmit FIFO, write only.

Referenced by XUartLite_SendBuffer(), and XUartLite_SendByte().

Typedef Documentation

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

Defines the callback function type for send and receive operations.

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,
UINTPTR  EffectiveAddr 
)

Initializes a XUartLite instance.

The receive and transmit FIFOs of the UART are not flushed, so you 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
[out]InstancePtrPointer to the XUartLite instance.
[in]ConfigReference 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.
[in]EffectiveAddrDevice 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.

References XUartLite::IsReady, XUartLite_Buffer::NextBytePtr, XUartLite::ReceiveBuffer, XUartLite::RecvHandler, XUartLite::RegBaseAddress, XUartLite_Buffer::RemainingBytes, XUartLite_Buffer::RequestedBytes, XUartLite::SendBuffer, XUartLite::SendHandler, XUartLite_ClearStats(), XUartLite_WriteReg, and XUL_CONTROL_REG_OFFSET.

Referenced by XUartLite_Initialize().

void XUartLite_DisableInterrupt ( XUartLite *  InstancePtr)

Disables the UART interrupt.

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

Parameters
[in]InstancePtrPointer to the XUartLite instance.

References XUartLite::IsReady, XUartLite::RegBaseAddress, XUartLite_WriteReg, and XUL_CONTROL_REG_OFFSET.

void XUartLite_EnableInterrupt ( XUartLite *  InstancePtr)

Enables the UART interrupt.

An interrupt occurs 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
[in]InstancePtrPointer to the XUartLite instance.

References XUartLite::IsReady, XUartLite::RegBaseAddress, XUartLite_WriteReg, XUL_CONTROL_REG_OFFSET, and XUL_CR_ENABLE_INTR.

Referenced by UartLiteIntrExample().

u8 XUartLite_GetSR ( XUartLite *  InstancePtr)

Reads the status register and updates the error stats before returning the status register value.

The status register is a clear on read register, so the errors if occurred have to be recorded every time the status register is read. This function is designed to be an internal function for the XUartLite component such that it may be called from wherever the status register needs to be read from the other driver functions.

Parameters
[in]InstancePtrPointer to the XUartLite instance.
Returns
The value of status register.

References XUartLite::RegBaseAddress, XUartLite_GetStatusReg, and XUartLite_UpdateStats.

Referenced by XUartLite_InterruptHandler(), XUartLite_IsSending(), XUartLite_ReceiveBuffer(), XUartLite_Recv(), XUartLite_ResetFifos(), XUartLite_SelfTest(), XUartLite_Send(), and XUartLite_SendBuffer().

void XUartLite_GetStats ( XUartLite *  InstancePtr,
XUartLite_Stats *  StatsPtr 
)

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

Parameters
[in]InstancePtrPointer to the XUartLite instance.
[out]StatsPtrPointer to a XUartLiteStats structure to where the statistics are to be copied.

References XUartLite_Stats::CharactersReceived, XUartLite_Stats::CharactersTransmitted, XUartLite::IsReady, XUartLite_Stats::ReceiveFramingErrors, XUartLite_Stats::ReceiveInterrupts, XUartLite_Stats::ReceiveOverrunErrors, XUartLite_Stats::ReceiveParityErrors, XUartLite::Stats, and XUartLite_Stats::TransmitInterrupts.

int XUartLite_Initialize ( XUartLite *  InstancePtr,
UINTPTR  BaseAddress 
)

Initializes a XUartLite instance.

The receive and transmit FIFOs of the UART are not flushed, so they may be flushed if desired. 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
[in]InstancePtrPointer to the XUartLite instance.
[in]BaseAddressBase address of the device.
Returns
  • XST_SUCCESS if everything starts up as expected.
  • XST_DEVICE_NOT_FOUND if the device is not found in the configuration table.
Note
In XSCT/classic flow, DeviceId is used to look up the device configuration.

References XUartLite_Config::RegBaseAddr, XUartLite_CfgInitialize(), and XUartLite_LookupConfig().

Referenced by UartLiteIntrExample(), UartLitePolledExample(), and UartLiteSelfTestExample().

void XUartLite_InterruptHandler ( XUartLite *  InstancePtr)

Handles interrupts for the UART Lite driver.

It must be connected to an interrupt system 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 caller must ensure this occurs.

Parameters
[in]InstancePtrPointer to the instance of the UART that the interrupt is for.

References XUartLite_Buffer::RequestedBytes, XUartLite::SendBuffer, XUartLite_GetSR(), XUL_SR_RX_FIFO_FULL, XUL_SR_RX_FIFO_VALID_DATA, and XUL_SR_TX_FIFO_EMPTY.

Referenced by UartLiteIntrExample().

int XUartLite_IsSending ( XUartLite *  InstancePtr)

Determines if the specified UART is sending data.

If the transmitter register is not empty, it is sending data.

Parameters
[in]InstancePtrPointer to the XUartLite instance.
Returns
A value of TRUE if the UART is sending data, otherwise FALSE.

References XUartLite_GetSR(), and XUL_SR_TX_FIFO_EMPTY.

XUartLite_Config * XUartLite_LookupConfig ( UINTPTR  BaseAddress)

Looks up the device configuration based on the unique device ID or base address.

The XUartLite_ConfigTable[] contains the configuration info for each device in the system.

Parameters
[in]BaseAddressBase address of the device.
Returns
A pointer to the configuration found or NULL if the specified device ID/BaseAddress was not found. See xuartlite.h for the definition of XUartLite_Config.
Note
In XSCT/classic flow, DeviceId is used to look up the device configuration.

References XUartLite_Config::Name, and XUartLite_ConfigTable.

Referenced by UartLiteIntrExample(), and XUartLite_Initialize().

unsigned int XUartLite_ReceiveBuffer ( XUartLite *  InstancePtr)

Receives a previously specified buffer of data from the UART.

The buffer is specified beforehand by setting up the instance variables of the instance. This function is designed to be an internal function for the XUartLite component such that it may be called from a shell function that sets up the buffer or from an interrupt handler.

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

In a polled mode, this function only receives as much data as the UART can buffer, either in the receiver or in the FIFO if present and enabled. 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 starts receiving and then the interrupt handler of the driver continues until the buffer has been received. A callback function, as specified by the application, is called to indicate the completion of receiving the buffer or when any receive errors or timeouts occur.

Parameters
[in,out]InstancePtrPointer to the XUartLite instance.
Returns
The number of bytes received.

References XUartLite_Stats::CharactersReceived, XUartLite_Buffer::NextBytePtr, ReceiveBuffer, XUartLite::ReceiveBuffer, XUartLite::RegBaseAddress, XUartLite_Buffer::RemainingBytes, XUartLite::Stats, XUartLite_GetSR(), XUartLite_ReadReg, XUartLite_WriteReg, XUL_CONTROL_REG_OFFSET, XUL_CR_ENABLE_INTR, XUL_RX_FIFO_OFFSET, and XUL_SR_RX_FIFO_VALID_DATA.

Referenced by XUartLite_Recv().

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

Receives a specified number of bytes of data from the UART.

This function attempts to receive the data and store it into the specified buffer. It is designed for either polled or interrupt driven modes. It is non-blocking such that it returns if no data has already been received by the UART.

In a polled mode, this function only receives 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 starts receiving and then the interrupt handler of the driver continues receiving data until the buffer has been received. A callback function, as specified by the application, is called to indicate the completion of receiving the buffer or when any receive errors or timeouts occur.

Parameters
[in,out]InstancePtrPointer to the XUartLite instance.
[out]DataBufferPtrPointer to buffer to receive data into.
[in]NumBytesNumber of bytes to receive. A value of zero stops 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.

References XUartLite::IsReady, XUartLite_Buffer::NextBytePtr, XUartLite::ReceiveBuffer, XUartLite::RegBaseAddress, XUartLite_Buffer::RemainingBytes, XUartLite_Buffer::RequestedBytes, XUartLite_GetSR(), XUartLite_ReceiveBuffer(), XUartLite_WriteReg, XUL_CONTROL_REG_OFFSET, and XUL_CR_ENABLE_INTR.

Referenced by UartLiteIntrExample(), and UartLitePolledExample().

u8 XUartLite_RecvByte ( UINTPTR  BaseAddress)

Receives a single byte using the UART.

It is blocking in that it waits for the receiver to become non-empty before it reads from the receive register.

Parameters
[in]BaseAddressBase address of the device.
Returns
The byte of data received.

References XUartLite_IsReceiveEmpty, XUartLite_ReadReg, and XUL_RX_FIFO_OFFSET.

Referenced by UartLiteLowLevelExample().

void XUartLite_ResetFifos ( XUartLite *  InstancePtr)

Resets the FIFOs, both transmit and receive, of the UART.

The FIFOs 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
[in]InstancePtrPointer to the XUartLite instance.

References XUartLite::IsReady, XUartLite::RegBaseAddress, XUartLite_GetSR(), XUartLite_WriteReg, XUL_CONTROL_REG_OFFSET, XUL_CR_FIFO_RX_RESET, XUL_CR_FIFO_TX_RESET, and XUL_SR_INTR_ENABLED.

Referenced by XUartLite_SelfTest().

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
[in]InstancePtrPointer 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.

References XUartLite::IsReady, XUartLite_GetSR(), XUartLite_ResetFifos(), and XUL_SR_TX_FIFO_EMPTY.

Referenced by UartLiteIntrExample(), UartLitePolledExample(), and UartLiteSelfTestExample().

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

Sends the specified buffer of data using the UART.

This function operates in either polled or interrupt driven modes. It is non-blocking such that it returns before the data has been sent by the UART. If the UART is busy sending data, it returns and indicates zero bytes were sent.

In a polled mode, this function only sends 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 starts sending the specified buffer and then the interrupt handler of the driver continues sending data until the buffer has been sent. A callback function, as specified by the application, is called to indicate the completion of sending the buffer.

Parameters
[in,out]InstancePtrPointer to the XUartLite instance.
[in]DataBufferPtrPointer to a buffer of data to send.
[in]NumBytesNumber of bytes to send. A value of zero stops a previous send operation that is in progress in interrupt mode. Any data that was already put into the transmit FIFO is 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.

References XUartLite::IsReady, XUartLite_Buffer::NextBytePtr, XUartLite::RegBaseAddress, XUartLite_Buffer::RemainingBytes, XUartLite_Buffer::RequestedBytes, XUartLite::SendBuffer, XUartLite_GetSR(), XUartLite_SendBuffer(), XUartLite_WriteReg, XUL_CONTROL_REG_OFFSET, and XUL_CR_ENABLE_INTR.

Referenced by UartLiteIntrExample(), and UartLitePolledExample().

unsigned int XUartLite_SendBuffer ( XUartLite *  InstancePtr)

Sends a previously specified buffer of data to the UART.

The buffer is specified beforehand by setting up the instance variables of the instance. This function is designed to be an internal function for the XUartLite component such that it may be called from a shell function that sets up the buffer or from an interrupt handler.

It sends the specified buffer of data to the UART in either polled or interrupt driven modes. It is non-blocking such that it returns before the data has been sent by the UART.

In a polled mode, this function only sends as much data as the UART can buffer, either in the transmitter or in the FIFO if present and enabled. The application may need to call it repeatedly to send a buffer.

In interrupt mode, this function starts sending the specified buffer and then the interrupt handler of the driver continues until the buffer has been sent. A callback function, as specified by the application, is called to indicate the completion of sending the buffer.

Parameters
[in,out]InstancePtrPointer to the XUartLite instance.
Returns
The number of bytes actually sent (put into the UART transmitter and/or FIFO).

References XUartLite_Stats::CharactersTransmitted, XUartLite_Buffer::NextBytePtr, XUartLite::RegBaseAddress, XUartLite_Buffer::RemainingBytes, SendBuffer, XUartLite::SendBuffer, XUartLite::Stats, XUartLite_GetSR(), XUartLite_WriteReg, XUL_CONTROL_REG_OFFSET, XUL_CR_ENABLE_INTR, XUL_SR_TX_FIFO_FULL, and XUL_TX_FIFO_OFFSET.

Referenced by XUartLite_Send().

void XUartLite_SendByte ( UINTPTR  BaseAddress,
u8  Data 
)

Sends a single byte using the UART.

It is blocking in that it waits for the transmitter to become non-full before it writes the byte to the transmit register.

Parameters
[in]BaseAddressBase address of the device.
[in]DataByte of data to send.

References XUartLite_IsTransmitFull, XUartLite_WriteReg, and XUL_TX_FIFO_OFFSET.

Referenced by UartLiteLowLevelExample().

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

Sets the receive callback handler.

This function sets the handler called when an event (interrupt) occurs in the driver. The handler allows application-specific processing.

Parameters
[in,out]InstancePtrPointer to the XUartLite instance.
[in]FuncPtrPointer to the callback function.
[in]CallBackRefUpper layer callback reference passed back when the callback function is invoked.
Note
There is no assert on the CallBackRef since the driver does not know what it is (nor should it)

References XUartLite::IsReady, XUartLite::RecvCallBackRef, and XUartLite::RecvHandler.

Referenced by UartLiteIntrExample().

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

Sets the send callback handler.

This function sets the handler called when an event (interrupt) occurs in the driver. The handler allows application-specific processing.

Parameters
[in,out]InstancePtrPointer to the XUartLite instance.
[in]FuncPtrPointer to the callback function.
[in]CallBackRefUpper layer callback reference passed back when the callback function is invoked.
Note
There is no assert on the CallBackRef since the driver does not know what it is (nor should it)

References XUartLite::IsReady, XUartLite::SendCallBackRef, and XUartLite::SendHandler.

Referenced by UartLiteIntrExample().

Variable Documentation

XUartLite_Config XUartLite_ConfigTable[XPAR_XUARTLITE_NUM_INSTANCES]
Initial value:
=
{
{
XPAR_UARTLITE_0_DEVICE_ID,
XPAR_UARTLITE_0_BASEADDR,
XPAR_UARTLITE_0_BAUDRATE,
XPAR_UARTLITE_0_USE_PARITY,
XPAR_UARTLITE_0_ODD_PARITY,
XPAR_UARTLITE_0_DATA_BITS
},
}

Holds the configuration table for UART Lite devices.

Holds the configuration entry for each UART Lite instance.

Referenced by XUartLite_LookupConfig().

XUartLite_Config XUartLite_ConfigTable[]

Holds the configuration entry for each UART Lite instance.

Holds the configuration entry for each UART Lite instance.

Referenced by XUartLite_LookupConfig().