コード例 #1
0
ファイル: UART_PM.c プロジェクト: LagunaMatada/GlowTime
/*******************************************************************************
* Function Name: UART_Sleep
********************************************************************************
*
* Summary:
*  Calls SaveConfig function fucntion for selected mode.
*
* Parameters:
*  None
*
* Return:
*  None
*
*******************************************************************************/
void UART_Sleep(void)
{
#if(UART_SCB_MODE_UNCONFIG_CONST_CFG)

    if(0u != UART_scbEnableWake)
    {
        if(UART_SCB_MODE_I2C_RUNTM_CFG)
        {
            UART_I2CSaveConfig();
        }
        else if(UART_SCB_MODE_SPI_RUNTM_CFG)
        {
            UART_SpiSaveConfig();
        }
        else if(UART_SCB_MODE_UART_RUNTM_CFG)
        {
            UART_UartSaveConfig();
        }
        else if(UART_SCB_MODE_EZI2C_RUNTM_CFG)
        {
            UART_EzI2CSaveConfig();
        }
        else
        {
            /* Unknown mode: do nothing */
        }
    }
    else
    {
        UART_backup.enableState = (uint8) UART_GET_CTRL_ENABLED;
        
        if(0u != UART_backup.enableState)
        {
            UART_Stop();
        }
    }
    
    UART_DisableTxPinsInputBuffer();
    
#else
    
    #if defined (UART_I2C_WAKE_ENABLE_CONST) && (UART_I2C_WAKE_ENABLE_CONST)
        UART_I2CSaveConfig();
        
    #elif defined (UART_SPI_WAKE_ENABLE_CONST) && (UART_SPI_WAKE_ENABLE_CONST)
        UART_SpiSaveConfig();
        
    #elif defined (UART_UART_WAKE_ENABLE_CONST) && (UART_UART_WAKE_ENABLE_CONST)
        UART_UartSaveConfig();
        
    #elif defined (UART_EZI2C_WAKE_ENABLE_CONST) && (UART_EZI2C_WAKE_ENABLE_CONST)
        UART_EzI2CSaveConfig();
    
    #else
        
        UART_backup.enableState = (uint8) UART_GET_CTRL_ENABLED;
        
        /* Check enable state */
        if(0u != UART_backup.enableState)
        {
            UART_Stop();
        }
        
    #endif /* defined (UART_SCB_MODE_I2C_CONST_CFG) && (UART_I2C_WAKE_ENABLE_CONST) */
    
    UART_DisableTxPinsInputBuffer();
    
#endif /* (UART_SCB_MODE_UNCONFIG_CONST_CFG) */
}
コード例 #2
0
ファイル: UART_PM.c プロジェクト: Ztuff/E3PRJ3
/*******************************************************************************
* Function Name: UART_Sleep
********************************************************************************
*
* Summary:
*  Prepares the component to enter Deep Sleep.
*  The “Enable wakeup from Sleep Mode” selection has an influence on
*  this function implementation.
*
* Parameters:
*  None
*
* Return:
*  None
*
*******************************************************************************/
void UART_Sleep(void)
{
#if(UART_SCB_MODE_UNCONFIG_CONST_CFG)

    if(UART_SCB_WAKE_ENABLE_CHECK)
    {
        if(UART_SCB_MODE_I2C_RUNTM_CFG)
        {
            UART_I2CSaveConfig();
        }
        else if(UART_SCB_MODE_EZI2C_RUNTM_CFG)
        {
            UART_EzI2CSaveConfig();
        }
#if(!UART_CY_SCBIP_V1_I2C_ONLY)
        else if(UART_SCB_MODE_SPI_RUNTM_CFG)
        {
            UART_SpiSaveConfig();
        }
        else if(UART_SCB_MODE_UART_RUNTM_CFG)
        {
            UART_UartSaveConfig();
        }
#endif /* (!UART_CY_SCBIP_V1_I2C_ONLY) */
        else
        {
            /* Unknown mode: do nothing */
        }
    }
    else
    {
        UART_backup.enableState = (uint8) UART_GET_CTRL_ENABLED;

        if(0u != UART_backup.enableState)
        {
            UART_Stop();
        }
    }

#else

#if (UART_SCB_MODE_I2C_CONST_CFG && UART_I2C_WAKE_ENABLE_CONST)
    UART_I2CSaveConfig();

#elif (UART_SCB_MODE_EZI2C_CONST_CFG && UART_EZI2C_WAKE_ENABLE_CONST)
    UART_EzI2CSaveConfig();

#elif (UART_SCB_MODE_SPI_CONST_CFG && UART_SPI_WAKE_ENABLE_CONST)
    UART_SpiSaveConfig();

#elif (UART_SCB_MODE_UART_CONST_CFG && UART_UART_WAKE_ENABLE_CONST)
    UART_UartSaveConfig();

#else

    UART_backup.enableState = (uint8) UART_GET_CTRL_ENABLED;

    if(0u != UART_backup.enableState)
    {
        UART_Stop();
    }

#endif /* defined (UART_SCB_MODE_I2C_CONST_CFG) && (UART_I2C_WAKE_ENABLE_CONST) */

#endif /* (UART_SCB_MODE_UNCONFIG_CONST_CFG) */
}