Other Parts Discussed in Thread: SYSCONFIG, CC2640R2F, CC2340R5
Can I get an example code for Half duplex UART code?
Currently received as junk characters data when Tx from Teraterm input.
I use half duplex board as input to CC2340.
The connection is PC-UART --> Half duplex boards --> CC2340
semStatus = sem_init(&sem, 0, 0);
if (semStatus != 0)
{
/* Error creating semaphore */
while (1) {}
}
/* Create a UART in CALLBACK read mode */
UART2_Params_init(&uartParams);
uartParams.readMode = UART2_Mode_CALLBACK;
uartParams.readCallback = callbackFxn;
uartParams.baudRate = 3000000;
uart = UART2_open(CONFIG_UART2_0, &uartParams);
if (uart == NULL)
{
/* UART2_open() failed */
while (1) {}
}
/* Turn on user LED to indicate successful initialization */
GPIO_write(CONFIG_GPIO_LED_0, CONFIG_GPIO_LED_ON);
/* Pass NULL for bytesWritten since it's not used in this example */
UART2_write(uart, echoPrompt, sizeof(echoPrompt), NULL);
/* Loop forever echoing */
while (1)
{
numBytesRead = 0;
/* Pass NULL for bytesRead since it's not used in this example */
status = UART2_read(uart, &input, sizeof(input), NULL);
printf("status result =%d\n",status);
if (status != UART2_STATUS_SUCCESS)
{
/* UART2_read() failed */
while (1) {}
}
//SysCtlDelay(SysCtlClockGet() / 3); // delay 1 second
/* Do not write until read callback executes */
sem_wait(&sem);
if (numBytesRead > 0)
{
status = UART2_write(uart, &input, sizeof(input), NULL);
if (status != UART2_STATUS_SUCCESS)
{
/* UART2_write() failed */
while (1) {}
}
}


