/*
* The following buffers are used in this example to send and receive data
* with the UART.
*/
Xuint8 SendBuffer[TEST_BUFFER_SIZE]; /* Buffer for Transmitting Data */
Xuint8 RecvBuffer[TEST_BUFFER_SIZE]; /* Buffer for Receiving Data */
/*
* Run the UartLite Low level example , specify the BaseAddress that is
* generated in xparameters.h
*/
Status = UartLiteLowLevelExample(UARTLITE_BASEADDR);
if (Status != XST_SUCCESS)
{
return XST_FAILURE;
}
XStatus UartLiteLowLevelExample(Xuint32 UartliteBaseAddress)
{
int Index;
/*
* Initialize the send buffer bytes with a pattern to send and the
* the receive buffer bytes to zero
*/
for (Index = 0; Index < TEST_BUFFER_SIZE; Index++)
{
SendBuffer[Index] = Index + 'B';
RecvBuffer[Index] = 0;
}
/*
* Send the entire transmit buffer.,此处是工作的
*/
for (Index = 0; Index < TEST_BUFFER_SIZE; Index++)
{
XUartLite_SendByte(UartliteBaseAddress, SendBuffer[Index]);
printf("%d***",SendBuffer[Index]);
}
/*
* Receive the entire buffer's worth. Note that the RecvByte function
* blocks waiting for a character.此外为什么没有接收???
*/
for (Index = 0; Index < TEST_BUFFER_SIZE; Index++)
{
RecvBuffer[Index] = XUartLite_RecvByte(UartliteBaseAddress);
printf("%d###",RecvBuffer[Index]);
}
/*
* Check the receive buffer data against the send buffer and verify the
* data was correctly received
*/
for (Index = 0; Index < TEST_BUFFER_SIZE; Index++)
{
if (SendBuffer[Index] != RecvBuffer[Index])
{
return XST_FAILURE;
}
}