Error in FreeRTOS UART Example Application?

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Error in FreeRTOS UART Example Application?

ソリューションへジャンプ
1,592件の閲覧回数
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 件の賞賛
返信
1 解決策
1,498件の閲覧回数
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 件の賞賛
返信
1 返信
1,499件の閲覧回数
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 件の賞賛
返信