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
743 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
1 Solution
649 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
1 Reply
650 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