AT example.cydsn/Generated_Source/PSoC5/UART.c
uint8 UART_GetChar(void) 
    {
        uint8 rxData = 0u;
        uint8 rxStatus;

        #if(UART_RXBUFFERSIZE > UART_FIFO_LENGTH)
            uint8 loc_rxBufferRead;
            uint8 loc_rxBufferWrite;
            /* Protect variables that could change on interrupt. */
            /* Disable Rx interrupt. */
            #if(UART_RX_INTERRUPT_ENABLED)
                UART_DisableRxInt();
            #endif /* UART_RX_INTERRUPT_ENABLED */
            loc_rxBufferRead = UART_rxBufferRead;
            loc_rxBufferWrite = UART_rxBufferWrite;

            if( (UART_rxBufferLoopDetect != 0u) || (loc_rxBufferRead != loc_rxBufferWrite) )
            {
                rxData = UART_rxBuffer[loc_rxBufferRead];
                loc_rxBufferRead++;
                if(loc_rxBufferRead >= UART_RXBUFFERSIZE)
                {
                    loc_rxBufferRead = 0u;
                }
                /* Update the real pointer */
                UART_rxBufferRead = loc_rxBufferRead;

                if(UART_rxBufferLoopDetect > 0u )
                {
                    UART_rxBufferLoopDetect = 0u;
                    #if( (UART_RX_INTERRUPT_ENABLED) && (UART_FLOW_CONTROL != 0u) )
                        /* When Hardware Flow Control selected - return RX mask */
                        #if( UART_HD_ENABLED )
                            if((UART_CONTROL_REG & UART_CTRL_HD_SEND) == 0u)
                            {   /* In Half duplex mode return RX mask only if
                                *  RX configuration set, otherwise
                                *  mask will be returned in LoadRxConfig() API.
                                */
                                UART_RXSTATUS_MASK_REG  |= UART_RX_STS_FIFO_NOTEMPTY;
                            }
                        #else
                            UART_RXSTATUS_MASK_REG  |= UART_RX_STS_FIFO_NOTEMPTY;
                        #endif /* end UART_HD_ENABLED */
                    #endif /* UART_RX_INTERRUPT_ENABLED and Hardware flow control*/
                }

            }
            else
            {   rxStatus = UART_RXSTATUS_REG;
                if((rxStatus & UART_RX_STS_FIFO_NOTEMPTY) != 0u)
                {   /* Read received data from FIFO*/
                    rxData = UART_RXDATA_REG;
                    /*Check status on error*/
                    if((rxStatus & (UART_RX_STS_BREAK | UART_RX_STS_PAR_ERROR |
                                   UART_RX_STS_STOP_ERROR | UART_RX_STS_OVERRUN)) != 0u)
                    {
                        rxData = 0u;
                    }
                }
            }

            /* Enable Rx interrupt. */
            #if(UART_RX_INTERRUPT_ENABLED)
                UART_EnableRxInt();
            #endif /* UART_RX_INTERRUPT_ENABLED */

        #else /* UART_RXBUFFERSIZE > UART_FIFO_LENGTH */

            rxStatus =UART_RXSTATUS_REG;
            if((rxStatus & UART_RX_STS_FIFO_NOTEMPTY) != 0u)
            {   /* Read received data from FIFO*/
                rxData = UART_RXDATA_REG;
                /*Check status on error*/
                if((rxStatus & (UART_RX_STS_BREAK | UART_RX_STS_PAR_ERROR |
                               UART_RX_STS_STOP_ERROR | UART_RX_STS_OVERRUN)) != 0u)
                {
                    rxData = 0u;
                }
            }
        #endif /* UART_RXBUFFERSIZE > UART_FIFO_LENGTH */

        return(rxData);
    }
/*******************************************************************************
    * Function Name: UART_GetChar
    ********************************************************************************
    *
    * Summary:
    *  Reads UART RX buffer immediately, if data is not available or an error
    *  condition exists, zero is returned; otherwise, character is read and
    *  returned.
    *
    * Parameters:
    *  None.
    *
    * Return:
    *  Character read from UART RX buffer. ASCII characters from 1 to 255 are valid.
    *  A returned zero signifies an error condition or no data available.
    *
    * Global Variables:
    *  UART_rxBuffer - RAM buffer pointer for save received data.
    *  UART_rxBufferWrite - cyclic index for write to rxBuffer,
    *     checked to identify new data.
    *  UART_rxBufferRead - cyclic index for read from rxBuffer,
    *     incremented after each byte has been read from buffer.
    *  UART_rxBufferLoopDetect - creared if loop condition was detected
    *     in RX ISR.
    *
    * Reentrant:
    *  No.
    *
    *******************************************************************************/
Function Name: UART_GetChar
Summary:
Reads UART RX buffer immediately, if data is not available or an error
condition exists, zero is returned; otherwise, character is read and
returned.

None.

Character read from UART RX buffer. ASCII characters from 1 to 255 are valid.
A returned zero signifies an error condition or no data available.

Global Variables:
UART_rxBuffer - RAM buffer pointer for save received data.
UART_rxBufferWrite - cyclic index for write to rxBuffer,
checked to identify new data.
UART_rxBufferRead - cyclic index for read from rxBuffer,
incremented after each byte has been read from buffer.
UART_rxBufferLoopDetect - creared if loop condition was detected
in RX ISR.

No.
Function Name : UART_GetChar Summary : Reads UART RX buffer immediately if data is not available or an error condition exists zero is returned ; otherwise character is read and returned . None . Character read from UART RX buffer . ASCII characters from 1 to 255 are valid . A returned zero signifies an error condition or no data available . Global Variables : UART_rxBuffer - RAM buffer pointer for save received data . UART_rxBufferWrite - cyclic index for write to rxBuffer checked to identify new data . UART_rxBufferRead - cyclic index for read from rxBuffer incremented after each byte has been read from buffer . UART_rxBufferLoopDetect - creared if loop condition was detected in RX ISR . No .
uint8 UART_GetChar(void) 
    {
        uint8 rxData = 0u;
        uint8 rxStatus;
        #if(UART_RXBUFFERSIZE > UART_FIFO_LENGTH)
            uint8 loc_rxBufferRead;
            uint8 loc_rxBufferWrite;
            #if(UART_RX_INTERRUPT_ENABLED)
                UART_DisableRxInt();
            #endif 
            loc_rxBufferRead = UART_rxBufferRead;
            loc_rxBufferWrite = UART_rxBufferWrite;
            if( (UART_rxBufferLoopDetect != 0u) || (loc_rxBufferRead != loc_rxBufferWrite) )
            {
                rxData = UART_rxBuffer[loc_rxBufferRead];
                loc_rxBufferRead++;
                if(loc_rxBufferRead >= UART_RXBUFFERSIZE)
                {
                    loc_rxBufferRead = 0u;
                }
                UART_rxBufferRead = loc_rxBufferRead;
                if(UART_rxBufferLoopDetect > 0u )
                {
                    UART_rxBufferLoopDetect = 0u;
                    #if( (UART_RX_INTERRUPT_ENABLED) && (UART_FLOW_CONTROL != 0u) )
                        #if( UART_HD_ENABLED )
                            if((UART_CONTROL_REG & UART_CTRL_HD_SEND) == 0u)
                            {   
                                UART_RXSTATUS_MASK_REG  |= UART_RX_STS_FIFO_NOTEMPTY;
                            }
                        #else
                            UART_RXSTATUS_MASK_REG  |= UART_RX_STS_FIFO_NOTEMPTY;
                        #endif 
                    #endif 
                }
            }
            else
            {   rxStatus = UART_RXSTATUS_REG;
                if((rxStatus & UART_RX_STS_FIFO_NOTEMPTY) != 0u)
                {   
                    rxData = UART_RXDATA_REG;
                    if((rxStatus & (UART_RX_STS_BREAK | UART_RX_STS_PAR_ERROR |
                                   UART_RX_STS_STOP_ERROR | UART_RX_STS_OVERRUN)) != 0u)
                    {
                        rxData = 0u;
                    }
                }
            }
            #if(UART_RX_INTERRUPT_ENABLED)
                UART_EnableRxInt();
            #endif 
        #else 
            rxStatus =UART_RXSTATUS_REG;
            if((rxStatus & UART_RX_STS_FIFO_NOTEMPTY) != 0u)
            {   
                rxData = UART_RXDATA_REG;
                if((rxStatus & (UART_RX_STS_BREAK | UART_RX_STS_PAR_ERROR |
                               UART_RX_STS_STOP_ERROR | UART_RX_STS_OVERRUN)) != 0u)
                {
                    rxData = 0u;
                }
            }
        #endif 
        return(rxData);
    }
uint8 UART_GetChar ( void ) { uint8 rxData = 0u ; uint8 rxStatus ; #if ( UART_RXBUFFERSIZE > UART_FIFO_LENGTH ) uint8 loc_rxBufferRead ; uint8 loc_rxBufferWrite ; #if ( UART_RX_INTERRUPT_ENABLED ) UART_DisableRxInt ( ) ; #endif loc_rxBufferRead = UART_rxBufferRead ; loc_rxBufferWrite = UART_rxBufferWrite ; if ( ( UART_rxBufferLoopDetect != 0u ) || ( loc_rxBufferRead != loc_rxBufferWrite ) ) { rxData = UART_rxBuffer [ loc_rxBufferRead ] ; loc_rxBufferRead ++ ; if ( loc_rxBufferRead >= UART_RXBUFFERSIZE ) { loc_rxBufferRead = 0u ; } UART_rxBufferRead = loc_rxBufferRead ; if ( UART_rxBufferLoopDetect > 0u ) { UART_rxBufferLoopDetect = 0u ; #if ( ( UART_RX_INTERRUPT_ENABLED ) && ( UART_FLOW_CONTROL != 0u ) ) #if ( UART_HD_ENABLED ) if ( ( UART_CONTROL_REG & UART_CTRL_HD_SEND ) == 0u ) { UART_RXSTATUS_MASK_REG |= UART_RX_STS_FIFO_NOTEMPTY ; } #else UART_RXSTATUS_MASK_REG |= UART_RX_STS_FIFO_NOTEMPTY ; #endif #endif } } else { rxStatus = UART_RXSTATUS_REG ; if ( ( rxStatus & UART_RX_STS_FIFO_NOTEMPTY ) != 0u ) { rxData = UART_RXDATA_REG ; if ( ( rxStatus & ( UART_RX_STS_BREAK | UART_RX_STS_PAR_ERROR | UART_RX_STS_STOP_ERROR | UART_RX_STS_OVERRUN ) ) != 0u ) { rxData = 0u ; } } } #if ( UART_RX_INTERRUPT_ENABLED ) UART_EnableRxInt ( ) ; #endif #else rxStatus = UART_RXSTATUS_REG ; if ( ( rxStatus & UART_RX_STS_FIFO_NOTEMPTY ) != 0u ) { rxData = UART_RXDATA_REG ; if ( ( rxStatus & ( UART_RX_STS_BREAK | UART_RX_STS_PAR_ERROR | UART_RX_STS_STOP_ERROR | UART_RX_STS_OVERRUN ) ) != 0u ) { rxData = 0u ; } } #endif return ( rxData ) ; }
Function Name: UART_GetChar
 Summary:
  Reads UART RX buffer immediately, if data is not available or an error
  condition exists, zero is returned; otherwise, character is read and
  returned.
Function Name : UART_GetChar Summary : Reads UART RX buffer immediately if data is not available or an error condition exists zero is returned ; otherwise character is read and returned .
/* Protect variables that could change on interrupt. */ /* Disable Rx interrupt. */ /* UART_RX_INTERRUPT_ENABLED */ /* Update the real pointer */ /* When Hardware Flow Control selected - return RX mask */ /* In Half duplex mode return RX mask only if
                                *  RX configuration set, otherwise
                                *  mask will be returned in LoadRxConfig() API.
                                */ /* end UART_HD_ENABLED */ /* UART_RX_INTERRUPT_ENABLED and Hardware flow control*/ /* Read received data from FIFO*/ /*Check status on error*/ /* Enable Rx interrupt. */ /* UART_RX_INTERRUPT_ENABLED */ /* UART_RXBUFFERSIZE > UART_FIFO_LENGTH */ /* Read received data from FIFO*/ /*Check status on error*/ /* UART_RXBUFFERSIZE > UART_FIFO_LENGTH */