Classes |
struct | XUartPs_Config |
struct | XUartPsBuffer |
struct | XUartPsFormat |
struct | XUartPs |
Defines |
#define | XUARTPS_H |
#define | XUARTPS_MAX_RATE 921600 |
#define | XUARTPS_MIN_RATE 110 |
#define | XUARTPS_DFT_BAUDRATE 115200 |
#define | XUartPs_GetChannelStatus(InstancePtr) Xil_In32(((InstancePtr)->Config.BaseAddress) + XUARTPS_SR_OFFSET) |
#define | XUartPs_GetModeControl(InstancePtr) Xil_In32(((InstancePtr)->Config.BaseAddress) + XUARTPS_CR_OFFSET) |
#define | XUartPs_SetModeControl(InstancePtr, RegisterValue) |
#define | XUartPs_EnableUart(InstancePtr) |
#define | XUartPs_DisableUart(InstancePtr) |
#define | XUartPs_IsTransmitEmpty(InstancePtr) |
|
|
#define | XUARTPS_OPTION_SET_BREAK 0x0080 |
#define | XUARTPS_OPTION_STOP_BREAK 0x0040 |
#define | XUARTPS_OPTION_RESET_TMOUT 0x0020 |
#define | XUARTPS_OPTION_RESET_TX 0x0010 |
#define | XUARTPS_OPTION_RESET_RX 0x0008 |
#define | XUARTPS_OPTION_ASSERT_RTS 0x0004 |
#define | XUARTPS_OPTION_ASSERT_DTR 0x0002 |
#define | XUARTPS_OPTION_SET_FCM 0x0001 |
|
The UART can operate in one of four modes: Normal, Local Loopback, Remote Loopback, or automatic echo.
|
#define | XUARTPS_OPER_MODE_NORMAL 0x00 |
#define | XUARTPS_OPER_MODE_AUTO_ECHO 0x01 |
#define | XUARTPS_OPER_MODE_LOCAL_LOOP 0x02 |
#define | XUARTPS_OPER_MODE_REMOTE_LOOP 0x03 |
|
These constants specify the data format that the driver supports. The data format includes the number of data bits, the number of stop bits and parity.
|
#define | XUARTPS_FORMAT_8_BITS 0 |
#define | XUARTPS_FORMAT_7_BITS 2 |
#define | XUARTPS_FORMAT_6_BITS 3 |
#define | XUARTPS_FORMAT_NO_PARITY 4 |
#define | XUARTPS_FORMAT_MARK_PARITY 3 |
#define | XUARTPS_FORMAT_SPACE_PARITY 2 |
#define | XUARTPS_FORMAT_ODD_PARITY 1 |
#define | XUARTPS_FORMAT_EVEN_PARITY 0 |
#define | XUARTPS_FORMAT_2_STOP_BIT 2 |
#define | XUARTPS_FORMAT_1_5_STOP_BIT 1 |
#define | XUARTPS_FORMAT_1_STOP_BIT 0 |
|
These constants specify the handler events that an application can handle using its specific handler function. Note that these constants are not bit mask, so only one event can be passed to an application at a time.
|
#define | XUARTPS_EVENT_RECV_DATA 1 |
#define | XUARTPS_EVENT_RECV_TOUT 2 |
#define | XUARTPS_EVENT_SENT_DATA 3 |
#define | XUARTPS_EVENT_RECV_ERROR 4 |
#define | XUARTPS_EVENT_MODEM 5 |
Typedefs |
typedef void(* | XUartPs_Handler )(void *CallBackRef, u32 Event, unsigned int EventData) |
Functions |
XUartPs_Config * | XUartPs_LookupConfig (u16 DeviceId) |
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) |
void | XUartPs_SetOptions (XUartPs *InstancePtr, u16 Options) |
u16 | XUartPs_GetOptions (XUartPs *InstancePtr) |
void | XUartPs_SetFifoThreshold (XUartPs *InstancePtr, u8 TriggerLevel) |
u8 | XUartPs_GetFifoThreshold (XUartPs *InstancePtr) |
u16 | XUartPs_GetModemStatus (XUartPs *InstancePtr) |
u32 | XUartPs_IsSending (XUartPs *InstancePtr) |
u8 | XUartPs_GetOperMode (XUartPs *InstancePtr) |
void | XUartPs_SetOperMode (XUartPs *InstancePtr, u8 OperationMode) |
u8 | XUartPs_GetFlowDelay (XUartPs *InstancePtr) |
void | XUartPs_SetFlowDelay (XUartPs *InstancePtr, u8 FlowDelayValue) |
u8 | XUartPs_GetRecvTimeout (XUartPs *InstancePtr) |
void | XUartPs_SetRecvTimeout (XUartPs *InstancePtr, u8 RecvTimeout) |
int | XUartPs_SetDataFormat (XUartPs *InstancePtr, XUartPsFormat *Format) |
void | XUartPs_GetDataFormat (XUartPs *InstancePtr, XUartPsFormat *Format) |
u32 | XUartPs_GetInterruptMask (XUartPs *InstancePtr) |
void | XUartPs_SetInterruptMask (XUartPs *InstancePtr, u32 Mask) |
void | XUartPs_InterruptHandler (XUartPs *InstancePtr) |
void | XUartPs_SetHandler (XUartPs *InstancePtr, XUartPs_Handler FuncPtr, void *CallBackRef) |
int | XUartPs_SelfTest (XUartPs *InstancePtr) |
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.
- Parameters:
-
| 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. |
- Returns:
- XST_SUCCESS if initialization was successful
- XST_UART_BAUD_ERROR if the baud rate is not possible because the inputclock frequency is not divisible with an acceptable amount of error
- Note:
The default configuration for the UART after initialization is:
- 19,200 bps or XPAR_DFT_BAUDRATE if defined
- 8 data bits
- 1 stop bit
- no parity
- FIFO's are enabled with a receive threshold of 8 bytes
- The RX timeout is enabled with a timeout of 1 (4 char times)
All interrupts are disabled.
u16 XUartPs_GetModemStatus |
( |
XUartPs * |
InstancePtr |
) |
|
This function gets the modem status from the specified UART. The modem status indicates any changes of the modem signals. This function allows the modem status to be read in a polled mode. The modem status is updated whenever it is read such that reading it twice may not yield the same results.
- Parameters:
-
| InstancePtr | is a pointer to the XUartPs instance. |
- Returns:
The modem status which are bit masks that are contained in the file xuartps.h and named XUARTPS_MODEM_*.
- Note:
The bit masks used for the modem status are the exact bits of the modem status register with no abstraction.
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.
- Parameters:
-
| 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. |
- 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.
int XUartPs_SelfTest |
( |
XUartPs * |
InstancePtr |
) |
|
This function runs a self-test on the driver and hardware device. This self test performs a local loopback and verifies data can be sent and received.
The time for this test is proportional to the baud rate that has been set prior to calling this function.
The mode and control registers are restored before return.
- Parameters:
-
| InstancePtr | is a pointer to the XUartPs instance |
- Returns:
- XST_SUCCESS if the test was successful
- XST_UART_TEST_FAIL if the test failed looping back the data
- Note:
This function can hang if the hardware is not functioning properly.
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.
- Parameters:
-
| 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. |
- 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.
Sets the data format for the device. The data format includes the baud rate, number of data bits, number of stop bits, and parity. It is the caller's responsibility to ensure that the UART is not sending or receiving data when this function is called.
- Parameters:
-
| InstancePtr | is a pointer to the XUartPs instance. |
| FormatPtr | is a pointer to a format structure containing the data format to be set. |
- Returns:
- XST_SUCCESS if the data format was successfully set.
- XST_UART_BAUD_ERROR indicates the baud rate could not be set because of the amount of error with the baud rate and the input clock frequency.
- XST_INVALID_PARAM if one of the parameters was not valid.
- Note:
The data types in the format type, data bits and parity, are 32 bit fields to prevent a compiler warning. The asserts in this function will cause a warning if these fields are bytes.