#include "xstatus.h"
#include "xuartps.h"
#include "xil_io.h"
Defines | |
#define | XUARTPS_MAX_BAUD_ERROR_RATE 3 |
Functions | |
unsigned int | XUartPs_SendBuffer (XUartPs *InstancePtr) |
unsigned int | XUartPs_ReceiveBuffer (XUartPs *InstancePtr) |
int | XUartPs_CfgInitialize (XUartPs *InstancePtr, XUartPs_Config *Config, u32 EffectiveAddr) |
unsigned int | XUartPs_Send (XUartPs *InstancePtr, u8 *BufferPtr, unsigned int NumBytes) |
unsigned int | XUartPs_Recv (XUartPs *InstancePtr, u8 *BufferPtr, unsigned int NumBytes) |
int | XUartPs_SetBaudRate (XUartPs *InstancePtr, u32 BaudRate) |
This file contains the implementation of the interface functions for XUartPs driver. Refer to the header file xuartps.h for more detailed information.
MODIFICATION HISTORY:
Ver Who Date Changes ----- ------ -------- ---------------------------------------------- 1.00 drg/jz 01/13/10 First Release 2.2 hk 06/23/14 SW reset of RX and TX should be done when changing baud rate. CR# 804281.
#define XUARTPS_MAX_BAUD_ERROR_RATE 3 |
int XUartPs_CfgInitialize | ( | XUartPs * | InstancePtr, | |
XUartPs_Config * | Config, | |||
u32 | EffectiveAddr | |||
) |
Initializes a specific XUartPs instance such that it is ready to be used. The data format of the device is setup for 8 data bits, 1 stop bit, and no parity by default. The baud rate is set to a default value specified by Config->DefaultBaudRate if set, otherwise it is set to 19.2K baud. The receive FIFO threshold is set for 8 bytes. The default operating mode of the driver is polled mode.
InstancePtr | is a pointer to the XUartPs instance. | |
Config | is a reference to a structure containing information about a specific XUartPs driver. | |
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, pass in the physical address instead. |
The default configuration for the UART after initialization is:
All interrupts are disabled.
unsigned int XUartPs_ReceiveBuffer | ( | XUartPs * | InstancePtr | ) |
unsigned int XUartPs_Recv | ( | XUartPs * | InstancePtr, | |
u8 * | BufferPtr, | |||
unsigned int | NumBytes | |||
) |
This function attempts to receive a specified number of bytes of data from the device and store it into the specified buffer. This function works for both polled or interrupt driven modes. It is non-blocking.
In a polled mode, this function will only receive the data already in the RX FIFO. The application may need to call it repeatedly to receive the entire buffer. Polled mode is the default mode of operation for the device.
In interrupt mode, this function will start the receiving, if not the entire buffer has been received, the interrupt handler will continue receiving data until the entire buffer has been received. A callback function, as specified by the application, will be called to indicate the completion of the receiving or error conditions.
InstancePtr | is a pointer to the XUartPs 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. |
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.
unsigned int XUartPs_Send | ( | XUartPs * | InstancePtr, | |
u8 * | BufferPtr, | |||
unsigned int | NumBytes | |||
) |
This functions sends the specified buffer using the device in either polled or interrupt driven mode. This function is non-blocking, if the device is busy sending data, it will return and indicate zero bytes were sent. Otherwise, it fills the TX FIFO as much as it can, and return the number of bytes sent.
In a polled mode, this function will only send as much data as TX FIFO can buffer. The application may need to call it repeatedly to send the entire buffer.
In interrupt mode, this function will start sending the specified buffer, then the interrupt handler will continue sending data until the entire buffer has been sent. A callback function, as specified by the application, will be called to indicate the completion of sending.
InstancePtr | is a pointer to the XUartPs 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. |
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.
unsigned int XUartPs_SendBuffer | ( | XUartPs * | InstancePtr | ) |
int XUartPs_SetBaudRate | ( | XUartPs * | InstancePtr, | |
u32 | BaudRate | |||
) |
Sets the baud rate for the device. Checks the input value for validity and also verifies that the requested rate can be configured to within the maximum error range specified by XUARTPS_MAX_BAUD_ERROR_RATE. If the provided rate is not possible, the current setting is unchanged.
InstancePtr | is a pointer to the XUartPs instance | |
BaudRate | to be set |
Copyright © 1995-2014 Xilinx, Inc. All rights reserved.