UART receive interrupt callback completing receive

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

UART receive interrupt callback completing receive

ソリューションへジャンプ
2,740件の閲覧回数
adyr
Contributor V

Hi,

 

I am using KSDK 1.2 and KDS 3.0 with the IAR compiler. I have added a UART component and ticked the box to install the receive interrupt.

What I want to do is terminate the blocking receive when a EOT is received (packet based reception). However the interrupt callback has now way to end the reception. The current loop in the UART_DRV_IRQHandler is as follows:

#if FSL_FEATURE_UART_HAS_FIFO
        /* Read out all data from RX FIFO */
        while(UART_HAL_GetRxDatawordCountInFifo(base))
        {
#endif
            /* Get data and put into receive buffer */
            UART_HAL_Getchar(base, uartState->rxBuff);

            /* Invoke callback if there is one */
            if (uartState->rxCallback != NULL)
            {
                uartState->rxCallback(instance, uartState);
            }
            else
            {
                ++uartState->rxBuff;
                --uartState->rxSize;

                /* Check and see if this was the last byte */
                if (uartState->rxSize == 0U)
                {
                    UART_DRV_CompleteReceiveData(instance);
                    #if FSL_FEATURE_UART_HAS_FIFO
                    break;
                    #endif
                }
            }
#if FSL_FEATURE_UART_HAS_FIFO
        }
#endif

 

If I change the inner part of loop to:

            /* Invoke callback if there is one */
            if (uartState->rxCallback != NULL)
            {
                uartState->rxCallback(instance, uartState);
            }
            else
            {
                ++uartState->rxBuff;
                --uartState->rxSize;
   }

   /* Check and see if this was the last byte */
   if (uartState->rxSize == 0U)
   {
    UART_DRV_CompleteReceiveData(instance);
    #if FSL_FEATURE_UART_HAS_FIFO
    break;
    #endif
   }

 

Then the user interrupt call back can terminate the reception by setting uartState->rxSize to 0.

 

I was wondering if Freescale would consider making this change to future KSDK versions so I don't have to modify the KSDK code?

 

Best regards,

Adrian.

ラベル(1)
0 件の賞賛
返信
1 解決策
1,662件の閲覧回数
adyr
Contributor V

OK. More testing has found that my change breaks the nio_serial as that almost uses the fsl_uart_driver but it does not setup uartState->rxSize. It prefers to do it's own thing which is possibly why the Rx loop is different to the Tx loop.

If I change the:

if (uartState->rxSize == 0U)

to

if (uartState->isRxBlocking && (uartState->rxSize == 0U))

Then both are happy as nio_serial does not set the blocking flag either.

元の投稿で解決策を見る

2 返答(返信)
1,663件の閲覧回数
adyr
Contributor V

OK. More testing has found that my change breaks the nio_serial as that almost uses the fsl_uart_driver but it does not setup uartState->rxSize. It prefers to do it's own thing which is possibly why the Rx loop is different to the Tx loop.

If I change the:

if (uartState->rxSize == 0U)

to

if (uartState->isRxBlocking && (uartState->rxSize == 0U))

Then both are happy as nio_serial does not set the blocking flag either.

1,662件の閲覧回数
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello Adrian Rockall:

Thank you for your feedback.

This issue has been reported internally (ticket KPSDK-5144).

The proper modifications could not make it into KSDK v1.3, but a change of the UART driver and callback scheme is planned to avoid these issues in the next version of KSDK.

Regards!

Jorge Gonzalez

0 件の賞賛
返信