Error in FreeRTOS UART Example Application?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Error in FreeRTOS UART Example Application?

Jump to solution
1,059 Views
myke_predko
Senior Contributor III

I'm following the TWRK21F "freertos_uart" example application and I just noticed that in the code, the setup/initial transmit APIs are written as:

if (0 > UART_RTOS_Init(&handle, &t_handle, &uart_config))
{
vTaskSuspend(NULL);
}

/* Send introduction message. */
if (0 > UART_RTOS_Send(&handle, (uint8_t *)to_send, strlen(to_send)))
{
vTaskSuspend(NULL);
}

In this code, the "vTaskSuspend(NULL); statements will only execute IFF the return value is less than zero (ie negative).  

When I look at the source code (in fsl_uart_freertos.c), the return values are defined (in fsl_common.h) as:

enum _generic_status
{
kStatus_Success = MAKE_STATUS(kStatusGroup_Generic, 0),
kStatus_Fail = MAKE_STATUS(kStatusGroup_Generic, 1),
kStatus_ReadOnly = MAKE_STATUS(kStatusGroup_Generic, 2),
kStatus_OutOfRange = MAKE_STATUS(kStatusGroup_Generic, 3),
kStatus_InvalidArgument = MAKE_STATUS(kStatusGroup_Generic, 4),
kStatus_Timeout = MAKE_STATUS(kStatusGroup_Generic, 5),
kStatus_NoTransferInProgress = MAKE_STATUS(kStatusGroup_Generic, 6),
};

As the return values will never be less than zero, won't the return tests for the APIs never become active? 

Shouldn't the first block of code be something like one of the two checks below?

if (0 != UART_RTOS_Init(&handle, &t_handle, &uart_config))  //  Not Equal to Zero
{
vTaskSuspend(NULL);
}

/* Send introduction message. */
if (UART_RTOS_Send(&handle, (uint8_t *)to_send, strlen(to_send)))  //  More Efficient way of detecting != Zero
{
vTaskSuspend(NULL);
}

0 Kudos
Reply
1 Solution
965 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi  Myke:

Thank you very much for your feedback. I will report this to the software team.

Regards

Daniel

View solution in original post

0 Kudos
Reply
1 Reply
966 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi  Myke:

Thank you very much for your feedback. I will report this to the software team.

Regards

Daniel

0 Kudos
Reply