#include #include "platform.h" #include "xil_printf.h" #include "xstatus.h" #include "ps7_init.h" #include "xscugic.h" #include "xparameters.h" #include "xuartlite.h" #define TEST_BUFFER_SIZE_SEND 5 #define TEST_BUFFER_SIZE_RECV 500 u8 SendBuffer[TEST_BUFFER_SIZE_SEND] = {56, 00, 36, 01, 00}; /* Buffer for Transmit Command */ u8 RecvBuffer[TEST_BUFFER_SIZE_RECV]; /* Buffer for Receiving Data */ XUartLite UartLite; /* Instance of the UartLite Device */ int UartLitePolledExample(u32 DeviceId) { int Status; /* * Initialize the UartLite driver so that it is ready to use. */ Status = XUartLite_Initialize(&UartLite, DeviceId); if (Status != XST_SUCCESS) { xil_printf("UARTLITE DRIVER FAILED"); return XST_FAILURE; } /* * Perform a self-test to ensure that the hardware was built correctly. */ Status = XUartLite_SelfTest(&UartLite); if (Status != XST_SUCCESS) { xil_printf("SELF TEST FAILED"); return XST_FAILURE; } return XST_SUCCESS; } int main() { unsigned char Sent_Count; unsigned int ReceivedCount = 0; int sentloop = 0; int index; int i; init_platform(); //INITIALIZE ps7_post_config(); //ENABLE TO PL UartLitePolledExample(XPAR_UARTLITE_0_DEVICE_ID); //ENABLE UARTLITE xil_printf("Start Looping....\n"); for(index = 0; index < TEST_BUFFER_SIZE_SEND; index++){ SendBuffer[index] = SendBuffer[index]; xil_printf("Send ......[%d] = %u\n" ,sentloop,SendBuffer[index]); sentloop++; Sent_Count = XUartLite_Send(&UartLite,SendBuffer,TEST_BUFFER_SIZE_SEND); xil_printf("Send Count... %u\n", Sent_Count); } if (Sent_Count != TEST_BUFFER_SIZE_SEND){ xil_printf("Sent Failed!"); return XST_FAILURE; } while(1) { ReceivedCount = XUartLite_Recv(&UartLite,RecvBuffer,TEST_BUFFER_SIZE_RECV); xil_printf("Received count %x\n", ReceivedCount); for(i=0; i < ReceivedCount; i++) { xil_printf("Received Buffer[%d] = %x\n" ,ReceivedCount,RecvBuffer); } } cleanup_platform(); return XST_SUCCESS; }