Part Number: CC3220SF
Tool/software: Code Composer Studio
Hello
I'm currently working on CC3220SF and want to use 2 UART port at the same time.
When i used UART_readPolling(from network_terminal example), only 1 port works and other one never worked.
So I tried to user UART_read instead, i cannot even read both them.
After trying some experipent using uartecho example, I found that UART_read only works when i call it directly from thead, but not in other funcion.
How can I read properly in function and how can I do other stuff while waiting data come in UART?
here's my code snippet.
int getCommand(UART_Handle huart, void *pBuffer, int bufSize)
{
char now, prev = 0;
for(;;)
{
UART_read(huart, &now, 1);
UART_write(huart, &now, 1);
if((prev == 'A') &&(now == 'T'))
{
break;
}
else
{
prev = now;
}
}
return 0;
}
void *consoleThread(void *arg)
{
char cmdBuf[400];
char now, prev = 0;
/* Loop forever echoing */
while (1)
{
getCommand(uartConsoleHanlde, cmdBuf, 400);
/* this works. but not one above this
for(;;)
{
UART_read(uartConsoleHanlde, &now, 1);
UART_write(uartConsoleHanlde, &now, 1);
if((prev == 'A') &&(now == 'T'))
{
break;
}
else
{
prev = now;
}
}*/
}
}
void *mainThread(void *arg0)
{
long RetVal;
pthread_t thread;
pthread_attr_t pAttrs;
UART_Params uartParams;
/* Call driver init functions */
GPIO_init();
UART_init();
UART_Params_init(&uartParams);
uartParams.writeDataMode = UART_DATA_BINARY;
uartParams.readDataMode = UART_DATA_BINARY;
uartParams.readReturnMode = UART_RETURN_FULL;
uartParams.readEcho = UART_ECHO_OFF;
uartParams.baudRate = 115200;
uartNootHanlde = UART_open(CONFIG_UART_0, &uartParams);
if (uartNootHanlde == NULL) {
while (1);
}
UART_Params_init(&uartParams);
uartParams.writeDataMode = UART_DATA_BINARY;
uartParams.readDataMode = UART_DATA_BINARY;
uartParams.readReturnMode = UART_RETURN_FULL;
uartParams.readEcho = UART_ECHO_OFF;
uartParams.baudRate = 115200;
uartConsoleHanlde = UART_open(CONFIG_UART_1, &uartParams);
if (uartConsoleHanlde == NULL) {
while (1);
}
/* command receive threads */
pthread_attr_init(&pAttrs);
RetVal = pthread_create(&thread, &pAttrs, nootThread, NULL);
/* command receive threads */
pthread_attr_init(&pAttrs);
RetVal = pthread_create(&thread, &pAttrs, consoleThread, NULL);
return NULL;
}
Thanks.