AnsweredAssumed Answered

UART receive interrupt callback completing receive

Question asked by Adrian Rockall on Sep 30, 2015
Latest reply on Oct 5, 2015 by Jorge_Gonzalez

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.

Outcomes