Я использую ZedBoard, на котором есть программируемая SoC Zynq-7000. Я пробую один из приведенных примеров (можно импортировать из Xilinx SDK), он называется xuartps_intr_example.c
Этот файл содержит драйвер UART, который используется в режиме прерывания. Приложение отправляет данные и ожидает получить те же данные через устройство в режиме локальной петли.
Я хотел бы адаптировать этот код таким образом, чтобы я мог отправлять данные на свой ZedBoard с терминала или какой-либо программы, реализующей последовательную связь. Я пробовал использовать функцию XUartPs_Recv для получения данных извне и отправки данных с разных терминалов на моем ПК (отключив консоль в Xilinx SDK, иначе последовательный порт недоступен), но плата не работает. получать что-нибудь. С другой стороны, отправка данных с ZedBoard на мой компьютер работает правильно, и я могу видеть сообщения, поступающие с доски на разных терминалах.
Я приложил исходный код, который мне непонятен и который, как мне кажется, вызывает у меня проблемы. Моим вопросам предшествует знак решетки:
XUartPs_SetInterruptMask(UartInstPtr, IntrMask);
XUartPs_SetOperMode(UartInstPtr, XUARTPS_OPER_MODE_LOCAL_LOOP);
#WHAT IS LOCAL LOOPBACK MODE?? DOES THIS PREVENT THE BOARD FROM RECEIVING
DATA COMING FROM MY PC?
/*
* Set the receiver timeout. If it is not set, and the last few bytes
* of data do not trigger the over-water or full interrupt, the bytes
* will not be received. By default it is disabled.
*
* The setting of 8 will timeout after 8 x 4 = 32 character times.
* Increase the time out value if baud rate is high, decrease it if
* baud rate is low.
*/
XUartPs_SetRecvTimeout(UartInstPtr, 8);
/*
* Initialize the send buffer bytes with a pattern and the
* the receive buffer bytes to zero to allow the receive data to be
* verified
*/
for (Index = 0; Index < TEST_BUFFER_SIZE; Index++) {
SendBuffer[Index] = (Index % 26) + 'A';
RecvBuffer[Index] = 0;
}
/*
* Start receiving data before sending it since there is a loopback,
* ignoring the number of bytes received as the return value since we
* know it will be zero
*/
XUartPs_Recv(UartInstPtr, RecvBuffer, TEST_BUFFER_SIZE);
/*
* Send the buffer using the UART and ignore the number of bytes sent
* as the return value since we are using it in interrupt mode.
*/
XUartPs_Send(UartInstPtr, SendBuffer, TEST_BUFFER_SIZE);
#HOW DOES THIS ACTUALLY WORK? WHY DO WE START RECEIVING BEFORE WE SEND ANY
BYTES?
/*
* Wait for the entire buffer to be received, letting the interrupt
* processing work in the background, this function may get locked
* up in this loop if the interrupts are not working correctly.
*/
while (1) {
if ((TotalSentCount == TEST_BUFFER_SIZE) &&
(TotalReceivedCount == TEST_BUFFER_SIZE)) {
break;
}
}
/* Verify the entire receive buffer was successfully received */
for (Index = 0; Index < TEST_BUFFER_SIZE; Index++) {
if (RecvBuffer[Index] != SendBuffer[Index]) {
BadByteCount++;
}
}
/* Set the UART in Normal Mode */
XUartPs_SetOperMode(UartInstPtr, XUARTPS_OPER_MODE_NORMAL);
#WHAT DOES SETTING THE UART IN NORMAL MODE MEAN??
Кроме того, я хотел бы знать, возможна ли отправка данных через SDK Terminal (Xilinx SDK) на ZedBoard. На данный момент все попытки безуспешны.
заранее спасибо
Христианин