Other Parts Discussed in Thread: TMDSCNCD263, TMDSHSECDOCK
Tool/software:
I am using this TMDSCNCD263 board and this is the IO Extender TMDSHSECDOCK.
I have one requirement in my project like I need to give input on UART then i have to receive that input data on same UART after that i need to transmit that received data using UART FIFO and after some delay i have to read the UART FIFO and print on the console. My Data is 64bytes
Here is my code
#include <string.h>
#include <kernel/dpl/DebugP.h>
#include "ti_drivers_config.h"
#include "ti_drivers_open_close.h"
#include "ti_board_open_close.h"
#include <time.h>
#define APP_UART_BUFSIZE (200U)
#define APP_UART_RECEIVE_BUFSIZE (64U)
uint8_t gUartBuffer[APP_UART_BUFSIZE];
uint8_t gUartReceiveBuffer[APP_UART_RECEIVE_BUFSIZE];
volatile uint32_t gNumBytesRead = 0U, gNumBytesWritten = 0U;
#define APP_UART_ASSERT_ON_FAILURE(transferOK, transaction) \
do { \
if((SystemP_SUCCESS != (transferOK)) || (UART_TRANSFER_STATUS_SUCCESS != transaction.status)) \
{ \
DebugP_assert(FALSE); /* UART TX/RX failed!! */ \
} \
} while(0)
void delay_ms(int milliseconds)
{
clock_t start_time = clock();
while (clock() < start_time + milliseconds * (CLOCKS_PER_SEC / 1000));
}
void uart_echo(void *args)
{
int32_t transferOK;
UART_Transaction trans;
Drivers_open();
Board_driversOpen();
DebugP_log("[UART] Echo example started ...\r\n");
UART_Transaction_init(&trans);
/* Send entry string */
gNumBytesWritten = 0U;
trans.buf = &gUartBuffer[0U];
strncpy((char *)trans.buf, "This is uart echo test blocking mode\r\nPlease input 64 bytes...\r\n", APP_UART_BUFSIZE);
trans.count = strlen((char *)trans.buf);
transferOK = UART_write(gUartHandle[CONFIG_UART_CONSOLE], &trans);
APP_UART_ASSERT_ON_FAILURE(transferOK, trans);
/* Read 64 bytes from UART console */
gNumBytesRead = 0U;
trans.buf = &gUartReceiveBuffer[0U];
trans.count = APP_UART_RECEIVE_BUFSIZE;
transferOK = UART_read(gUartHandle[CONFIG_UART_CONSOLE], &trans);
APP_UART_ASSERT_ON_FAILURE(transferOK, trans);
gNumBytesRead = trans.count;
/* Transmit the received data back */
DebugP_log("Transmitting %d bytes back: %.*s\r\n", gNumBytesRead, gNumBytesRead, gUartReceiveBuffer);
gNumBytesWritten = 0U;
trans.buf = &gUartReceiveBuffer[0U];
trans.count = gNumBytesRead;
transferOK = UART_write(gUartHandle[CONFIG_UART_CONSOLE], &trans);
if (transferOK != SystemP_SUCCESS) {
DebugP_log("UART write error occurred!\r\n");
} else {
DebugP_log("Successfully transmitted %d bytes\r\n", gNumBytesRead);
}
APP_UART_ASSERT_ON_FAILURE(transferOK, trans);
/* Delay for a short time to allow data transmission to complete */
ClockP_usleep(100000);
/* Prepare buffer for echoed data */
gNumBytesRead = 0U;
trans.buf = &gUartReceiveBuffer[0U];
trans.count = APP_UART_RECEIVE_BUFSIZE; // Adjust to the maximum size expected
/* Read the echoed data */
transferOK = UART_read(gUartHandle[CONFIG_UART_CONSOLE], &trans);
if (!transferOK) {
DebugP_log("UART read error occurred!\r\n");
} else {
gNumBytesRead = trans.count;
DebugP_log("Echoed %d bytes: %.*s\r\n", gNumBytesRead, gNumBytesRead, gUartReceiveBuffer);
}
/* Send exit string */
DebugP_log("All tests have passed!!\r\n");
Board_driversClose();
Drivers_close();
}
I can easily received the input data on uart but i am not sure after receiving data it transmitting back on same uart with FIFO or not. If it is using FIFO the i am not able to read back the data using FIFO
Can any help in in this regards