Tool/software:
Hello,
I have configured UART 4 to read in callback mode. After setting up this task, I jump over to the tcp task.
I want to capture incoming UART traffic in a software FIFO regardless of what task is running. But, the ISR doesn't fire when I send UART traffic (USB to UART FTDI bridge).
This was working when I wasn't using the TI RTOS, but now that I'm using tasks, the ISR doesn't fire. Can you tell me what I'm doing wrong? Thank you.
void InitRs485BusUartTask
(
Mailbox_Handle* rs485MbPtr ///< Pointer to mailbox handle
)
{
if (rs485MbPtr)
{
AssignMb(&rs485BusSys.uartSysVars_Tx.rs485Handle, rs485MbPtr);
}
const char echoPrompt[] = "\fUART 4 is online!:\r\n";
InitUartParams(&rs485BusSys.uartParams);//, &rs485BusSys.initStatus);
volatile bool mailboxPendSuccess = false;
rs485BusSys.handle = UART_open(Board_UART4, &rs485BusSys.uartParams);
if (rs485BusSys.handle == NULL) {
System_abort("Error opening the UART 4");
}
UART_read(rs485BusSys.handle, rs485BusSys.inputString, 1);
Task_Params_init(&rs485BusSys.uartSysVars_Rx.taskParams);
rs485BusSys.uartSysVars_Rx.taskParams.stackSize = TASKSTACKSIZE;
rs485BusSys.uartSysVars_Rx.taskParams.stack = &rs485BusSys.uartSysVars_Rx.task0Stack;
rs485BusSys.uartSysVars_Rx.taskParams.instance->name = "rs485BusUart_Rx";
rs485BusSys.uartSysVars_Rx.taskParams.priority = UART_RX_TASK_PRIORITY;//1; //TODO need to give thought to the priority of this task. Currently, this task is "running" and tcp is "ready"
Task_construct(&rs485BusSys.uartSysVars_Rx.task0Struct, (Task_FuncPtr)rs485BusUartFxn_Rx, &rs485BusSys.uartSysVars_Rx.taskParams, NULL);
System_printf("Starting the UART Echo example\nSystem provider is set to "
"SysMin. Halt the target to view any SysMin contents in "
"ROV.\n");
/* SysMin will only print to the console when you call flush or exit */
System_flush();
}
//=============================================================================
/**
@return
- Void
Task that handles the reception side of the UART. This receives messages in
from the RS-485 bus to the UART.
*/
Void rs485BusUartFxn_Rx
(
UArg arg0, ///< TI RTOS argument 0
UArg arg1 ///< TI RTOS argument 1
)
{
//const char echoPrompt[] = "\fUART 4 is online!:\r\n";
//InitUartParams(&rs485BusSys.uartParams, &rs485BusSys.initStatus);
volatile bool mailboxPendSuccess = false;
volatile int32_t readRtnVal = 0;
int32_t fifoSize = 0;
static uint8_t rxBuffer[GENERIC_TEST_FIFO_SIZE];
/* Loop forever echoing */
while (1)//0 < (fifoSize = GetSizeGenericFifo(&rs485BusSys.rxFifo)))
{
fifoSize = GetSizeGenericFifo(&rs485BusSys.rxFifo);
if (0 < fifoSize)
{
PopGenericFifo(&rs485BusSys.rxFifo, rxBuffer);
//Post this to the RS485 to Parse mailbox
//Put the task to sleep
}
//readRtnVal = UART_read(rs485BusSys.handle, rs485BusSys.inputString, RS485_BUFFER_SIZE);
//else
//{
//Task_sleep(1);
//}
}
}
//=============================================================================
/**
@return
- void
Callback function to address incoming UART traffic for the RS485 bus.
*/
static void Rs485UartReadCallback
(
UART_Handle handle, ///< Rs485 UART handle
void *rxBuf, ///< Receive buffer
size_t size ///< Size of received message within the buffer
)
{
if ((size) && (rxBuf) && (handle))
{
if (RS485_BUFFER_SIZE == size)
{
PushGenericFifo(&rs485BusSys.rxFifo, rxBuf);
}
}
}