AT example.cydsn/Generated_Source/PSoC5/UART.c
void UART_SendBreak(uint8 retMode) 
    {

        /* If not Initialized then skip this function*/
        if(UART_initVar != 0u)
        {
            /*Set the Counter to 13-bits and transmit a 00 byte*/
            /*When that is done then reset the counter value back*/
            uint8 tmpStat;

            #if(UART_HD_ENABLED) /* Half Duplex mode*/

                if( (retMode == UART_SEND_BREAK) ||
                    (retMode == UART_SEND_WAIT_REINIT ) )
                {
                    /* CTRL_HD_SEND_BREAK - sends break bits in HD mode*/
                    UART_WriteControlRegister(UART_ReadControlRegister() |
                                                          UART_CTRL_HD_SEND_BREAK);
                    /* Send zeros*/
                    UART_TXDATA_REG = 0u;

                    do /*wait until transmit starts*/
                    {
                        tmpStat = UART_TXSTATUS_REG;
                    }while((tmpStat & UART_TX_STS_FIFO_EMPTY) != 0u);
                }

                if( (retMode == UART_WAIT_FOR_COMPLETE_REINIT) ||
                    (retMode == UART_SEND_WAIT_REINIT) )
                {
                    do /*wait until transmit complete*/
                    {
                        tmpStat = UART_TXSTATUS_REG;
                    }while(((uint8)~tmpStat & UART_TX_STS_COMPLETE) != 0u);
                }

                if( (retMode == UART_WAIT_FOR_COMPLETE_REINIT) ||
                    (retMode == UART_REINIT) ||
                    (retMode == UART_SEND_WAIT_REINIT) )
                {
                    UART_WriteControlRegister(UART_ReadControlRegister() &
                                                  (uint8)~UART_CTRL_HD_SEND_BREAK);
                }

            #else /* UART_HD_ENABLED Full Duplex mode */

                static uint8 tx_period;

                if( (retMode == UART_SEND_BREAK) ||
                    (retMode == UART_SEND_WAIT_REINIT) )
                {
                    /* CTRL_HD_SEND_BREAK - skip to send parity bit at Break signal in Full Duplex mode*/
                    #if( (UART_PARITY_TYPE != UART__B_UART__NONE_REVB) || \
                                        (UART_PARITY_TYPE_SW != 0u) )
                        UART_WriteControlRegister(UART_ReadControlRegister() |
                                                              UART_CTRL_HD_SEND_BREAK);
                    #endif /* End UART_PARITY_TYPE != UART__B_UART__NONE_REVB  */

                    #if(UART_TXCLKGEN_DP)
                        tx_period = UART_TXBITCLKTX_COMPLETE_REG;
                        UART_TXBITCLKTX_COMPLETE_REG = UART_TXBITCTR_BREAKBITS;
                    #else
                        tx_period = UART_TXBITCTR_PERIOD_REG;
                        UART_TXBITCTR_PERIOD_REG = UART_TXBITCTR_BREAKBITS8X;
                    #endif /* End UART_TXCLKGEN_DP */

                    /* Send zeros*/
                    UART_TXDATA_REG = 0u;

                    do /* wait until transmit starts */
                    {
                        tmpStat = UART_TXSTATUS_REG;
                    }while((tmpStat & UART_TX_STS_FIFO_EMPTY) != 0u);
                }

                if( (retMode == UART_WAIT_FOR_COMPLETE_REINIT) ||
                    (retMode == UART_SEND_WAIT_REINIT) )
                {
                    do /*wait until transmit complete*/
                    {
                        tmpStat = UART_TXSTATUS_REG;
                    }while(((uint8)~tmpStat & UART_TX_STS_COMPLETE) != 0u);
                }

                if( (retMode == UART_WAIT_FOR_COMPLETE_REINIT) ||
                    (retMode == UART_REINIT) ||
                    (retMode == UART_SEND_WAIT_REINIT) )
                {

                    #if(UART_TXCLKGEN_DP)
                        UART_TXBITCLKTX_COMPLETE_REG = tx_period;
                    #else
                        UART_TXBITCTR_PERIOD_REG = tx_period;
                    #endif /* End UART_TXCLKGEN_DP */

                    #if( (UART_PARITY_TYPE != UART__B_UART__NONE_REVB) || \
                         (UART_PARITY_TYPE_SW != 0u) )
                        UART_WriteControlRegister(UART_ReadControlRegister() &
                                                      (uint8)~UART_CTRL_HD_SEND_BREAK);
                    #endif /* End UART_PARITY_TYPE != NONE */
                }
            #endif    /* End UART_HD_ENABLED */
        }
    }
/*******************************************************************************
    * Function Name: UART_SendBreak
    ********************************************************************************
    *
    * Summary:
    *  Write a Break command to the UART
    *
    * Parameters:
    *  uint8 retMode:  Wait mode,
    *   0 - Initialize registers for Break, sends the Break signal and return
    *       imediately.
    *   1 - Wait until Break sending is complete, reinitialize registers to normal
    *       transmission mode then return.
    *   2 - Reinitialize registers to normal transmission mode then return.
    *   3 - both steps: 0 and 1
    *       init registers for Break, send Break signal
    *       wait until Break sending is complete, reinit registers to normal
    *       transmission mode then return.
    *
    * Return:
    *  None.
    *
    * Global Variables:
    *  UART_initVar - checked to identify that the component has been
    *     initialized.
    *  tx_period - static variable, used for keeping TX period configuration.
    *
    * Reentrant:
    *  No.
    *
    * Theory:
    *  SendBreak function initializes registers to send 13-bit break signal. It is
    *  important to return the registers configuration to normal for continue 8-bit
    *  operation.
    *  Trere are 3 variants for this API usage:
    *  1) SendBreak(3) - function will send the Break signal and take care on the
    *     configuration returning. Funcition will block CPU untill transmition
    *     complete.
    *  2) User may want to use bloking time if UART configured to the low speed
    *     operation
    *     Emample for this case:
    *     SendBreak(0);     - init Break signal transmition
    *         Add your code here to use CPU time
    *     SendBreak(1);     - complete Break operation
    *  3) Same to 2) but user may want to init and use the interrupt for complete
    *     break operation.
    *     Example for this case:
    *     Init TX interrupt whith "TX - On TX Complete" parameter
    *     SendBreak(0);     - init Break signal transmition
    *         Add your code here to use CPU time
    *     When interrupt appear with UART_TX_STS_COMPLETE status:
    *     SendBreak(2);     - complete Break operation
    *
    * Side Effects:
    *   Uses static variable to keep registers configuration.
    *
    *******************************************************************************/
Function Name: UART_SendBreak
Summary:
Write a Break command to the UART

uint8 retMode:  Wait mode,
0 - Initialize registers for Break, sends the Break signal and return
imediately.
1 - Wait until Break sending is complete, reinitialize registers to normal
transmission mode then return.
2 - Reinitialize registers to normal transmission mode then return.
3 - both steps: 0 and 1
init registers for Break, send Break signal
wait until Break sending is complete, reinit registers to normal
transmission mode then return.

None.

Global Variables:
UART_initVar - checked to identify that the component has been
initialized.
tx_period - static variable, used for keeping TX period configuration.

No.

SendBreak function initializes registers to send 13-bit break signal. It is
important to return the registers configuration to normal for continue 8-bit
operation.
Trere are 3 variants for this API usage:
1) SendBreak(3) - function will send the Break signal and take care on the
configuration returning. Funcition will block CPU untill transmition
complete.
2) User may want to use bloking time if UART configured to the low speed
operation
Emample for this case:
SendBreak(0);     - init Break signal transmition
Add your code here to use CPU time
SendBreak(1);     - complete Break operation
3) Same to 2) but user may want to init and use the interrupt for complete
break operation.
Example for this case:
Init TX interrupt whith "TX - On TX Complete" parameter
SendBreak(0);     - init Break signal transmition
Add your code here to use CPU time
When interrupt appear with UART_TX_STS_COMPLETE status:
SendBreak(2);     - complete Break operation

Side Effects:
Uses static variable to keep registers configuration.
Function Name : UART_SendBreak Summary : Write a Break command to the UART uint8 retMode : Wait mode 0 - Initialize registers for Break sends the Break signal and return imediately . 1 - Wait until Break sending is complete reinitialize registers to normal transmission mode then return . 2 - Reinitialize registers to normal transmission mode then return . 3 - both steps : 0 and 1 init registers for Break send Break signal wait until Break sending is complete reinit registers to normal transmission mode then return . None . Global Variables : UART_initVar - checked to identify that the component has been initialized . tx_period - static variable used for keeping TX period configuration . No . SendBreak function initializes registers to send 13 - bit break signal . It is important to return the registers configuration to normal for continue 8 - bit operation . Trere are 3 variants for this API usage : 1 ) SendBreak ( 3 ) - function will send the Break signal and take care on the configuration returning . Funcition will block CPU untill transmition complete . 2 ) User may want to use bloking time if UART configured to the low speed operation Emample for this case : SendBreak ( 0 ) ; - init Break signal transmition Add your code here to use CPU time SendBreak ( 1 ) ; - complete Break operation 3 ) Same to 2 ) but user may want to init and use the interrupt for complete break operation . Example for this case : Init TX interrupt whith " TX - On TX Complete " parameter SendBreak ( 0 ) ; - init Break signal transmition Add your code here to use CPU time When interrupt appear with UART_TX_STS_COMPLETE status : SendBreak ( 2 ) ; - complete Break operation Side Effects : Uses static variable to keep registers configuration .
void UART_SendBreak(uint8 retMode) 
    {
        if(UART_initVar != 0u)
        {
            uint8 tmpStat;
            #if(UART_HD_ENABLED) 
                if( (retMode == UART_SEND_BREAK) ||
                    (retMode == UART_SEND_WAIT_REINIT ) )
                {
                    UART_WriteControlRegister(UART_ReadControlRegister() |
                                                          UART_CTRL_HD_SEND_BREAK);
                    UART_TXDATA_REG = 0u;
                    do 
                    {
                        tmpStat = UART_TXSTATUS_REG;
                    }while((tmpStat & UART_TX_STS_FIFO_EMPTY) != 0u);
                }
                if( (retMode == UART_WAIT_FOR_COMPLETE_REINIT) ||
                    (retMode == UART_SEND_WAIT_REINIT) )
                {
                    do 
                    {
                        tmpStat = UART_TXSTATUS_REG;
                    }while(((uint8)~tmpStat & UART_TX_STS_COMPLETE) != 0u);
                }
                if( (retMode == UART_WAIT_FOR_COMPLETE_REINIT) ||
                    (retMode == UART_REINIT) ||
                    (retMode == UART_SEND_WAIT_REINIT) )
                {
                    UART_WriteControlRegister(UART_ReadControlRegister() &
                                                  (uint8)~UART_CTRL_HD_SEND_BREAK);
                }
            #else 
                static uint8 tx_period;
                if( (retMode == UART_SEND_BREAK) ||
                    (retMode == UART_SEND_WAIT_REINIT) )
                {
                    #if( (UART_PARITY_TYPE != UART__B_UART__NONE_REVB) || \
                                        (UART_PARITY_TYPE_SW != 0u) )
                        UART_WriteControlRegister(UART_ReadControlRegister() |
                                                              UART_CTRL_HD_SEND_BREAK);
                    #endif 
                    #if(UART_TXCLKGEN_DP)
                        tx_period = UART_TXBITCLKTX_COMPLETE_REG;
                        UART_TXBITCLKTX_COMPLETE_REG = UART_TXBITCTR_BREAKBITS;
                    #else
                        tx_period = UART_TXBITCTR_PERIOD_REG;
                        UART_TXBITCTR_PERIOD_REG = UART_TXBITCTR_BREAKBITS8X;
                    #endif 
                    UART_TXDATA_REG = 0u;
                    do 
                    {
                        tmpStat = UART_TXSTATUS_REG;
                    }while((tmpStat & UART_TX_STS_FIFO_EMPTY) != 0u);
                }
                if( (retMode == UART_WAIT_FOR_COMPLETE_REINIT) ||
                    (retMode == UART_SEND_WAIT_REINIT) )
                {
                    do 
                    {
                        tmpStat = UART_TXSTATUS_REG;
                    }while(((uint8)~tmpStat & UART_TX_STS_COMPLETE) != 0u);
                }
                if( (retMode == UART_WAIT_FOR_COMPLETE_REINIT) ||
                    (retMode == UART_REINIT) ||
                    (retMode == UART_SEND_WAIT_REINIT) )
                {
                    #if(UART_TXCLKGEN_DP)
                        UART_TXBITCLKTX_COMPLETE_REG = tx_period;
                    #else
                        UART_TXBITCTR_PERIOD_REG = tx_period;
                    #endif 
                    #if( (UART_PARITY_TYPE != UART__B_UART__NONE_REVB) || \
                         (UART_PARITY_TYPE_SW != 0u) )
                        UART_WriteControlRegister(UART_ReadControlRegister() &
                                                      (uint8)~UART_CTRL_HD_SEND_BREAK);
                    #endif 
                }
            #endif    
        }
    }
void UART_SendBreak ( uint8 retMode ) { if ( UART_initVar != 0u ) { uint8 tmpStat ; #if ( UART_HD_ENABLED ) if ( ( retMode == UART_SEND_BREAK ) || ( retMode == UART_SEND_WAIT_REINIT ) ) { UART_WriteControlRegister ( UART_ReadControlRegister ( ) | UART_CTRL_HD_SEND_BREAK ) ; UART_TXDATA_REG = 0u ; do { tmpStat = UART_TXSTATUS_REG ; } while ( ( tmpStat & UART_TX_STS_FIFO_EMPTY ) != 0u ) ; } if ( ( retMode == UART_WAIT_FOR_COMPLETE_REINIT ) || ( retMode == UART_SEND_WAIT_REINIT ) ) { do { tmpStat = UART_TXSTATUS_REG ; } while ( ( ( uint8 ) ~ tmpStat & UART_TX_STS_COMPLETE ) != 0u ) ; } if ( ( retMode == UART_WAIT_FOR_COMPLETE_REINIT ) || ( retMode == UART_REINIT ) || ( retMode == UART_SEND_WAIT_REINIT ) ) { UART_WriteControlRegister ( UART_ReadControlRegister ( ) & ( uint8 ) ~ UART_CTRL_HD_SEND_BREAK ) ; } #else static uint8 tx_period ; if ( ( retMode == UART_SEND_BREAK ) || ( retMode == UART_SEND_WAIT_REINIT ) ) { #if ( ( UART_PARITY_TYPE != UART__B_UART__NONE_REVB ) || ( UART_PARITY_TYPE_SW != 0u ) ) UART_WriteControlRegister ( UART_ReadControlRegister ( ) | UART_CTRL_HD_SEND_BREAK ) ; #endif #if ( UART_TXCLKGEN_DP ) tx_period = UART_TXBITCLKTX_COMPLETE_REG ; UART_TXBITCLKTX_COMPLETE_REG = UART_TXBITCTR_BREAKBITS ; #else tx_period = UART_TXBITCTR_PERIOD_REG ; UART_TXBITCTR_PERIOD_REG = UART_TXBITCTR_BREAKBITS8X ; #endif UART_TXDATA_REG = 0u ; do { tmpStat = UART_TXSTATUS_REG ; } while ( ( tmpStat & UART_TX_STS_FIFO_EMPTY ) != 0u ) ; } if ( ( retMode == UART_WAIT_FOR_COMPLETE_REINIT ) || ( retMode == UART_SEND_WAIT_REINIT ) ) { do { tmpStat = UART_TXSTATUS_REG ; } while ( ( ( uint8 ) ~ tmpStat & UART_TX_STS_COMPLETE ) != 0u ) ; } if ( ( retMode == UART_WAIT_FOR_COMPLETE_REINIT ) || ( retMode == UART_REINIT ) || ( retMode == UART_SEND_WAIT_REINIT ) ) { #if ( UART_TXCLKGEN_DP ) UART_TXBITCLKTX_COMPLETE_REG = tx_period ; #else UART_TXBITCTR_PERIOD_REG = tx_period ; #endif #if ( ( UART_PARITY_TYPE != UART__B_UART__NONE_REVB ) || ( UART_PARITY_TYPE_SW != 0u ) ) UART_WriteControlRegister ( UART_ReadControlRegister ( ) & ( uint8 ) ~ UART_CTRL_HD_SEND_BREAK ) ; #endif } #endif } }
Function Name: UART_SendBreak
 Summary:
  Write a Break command to the UART
Function Name : UART_SendBreak Summary : Write a Break command to the UART
/* If not Initialized then skip this function*/ /*Set the Counter to 13-bits and transmit a 00 byte*/ /*When that is done then reset the counter value back*/ /* Half Duplex mode*/ /* CTRL_HD_SEND_BREAK - sends break bits in HD mode*/ /* Send zeros*/ /*wait until transmit starts*/ /*wait until transmit complete*/ /* UART_HD_ENABLED Full Duplex mode */ /* CTRL_HD_SEND_BREAK - skip to send parity bit at Break signal in Full Duplex mode*/ /* End UART_PARITY_TYPE != UART__B_UART__NONE_REVB  */ /* End UART_TXCLKGEN_DP */ /* Send zeros*/ /* wait until transmit starts */ /*wait until transmit complete*/ /* End UART_TXCLKGEN_DP */ /* End UART_PARITY_TYPE != NONE */ /* End UART_HD_ENABLED */