Esempio n. 1
0
/*******************************************************************************
* Function Name: PWM_1_RestoreConfig
********************************************************************************
* 
* Summary:
*  Restores the current user configuration of the component.
*
* Parameters:  
*  None
*
* Return: 
*  None
*
* Global variables:
*  PWM_1_backup:  Variables of this global structure are used to  
*  restore the values of non retention registers on wakeup from sleep mode.
*
*******************************************************************************/
void PWM_1_RestoreConfig(void) 
{
        #if(!PWM_1_UsingFixedFunction)
            #if(!PWM_1_PWMModeIsCenterAligned)
                PWM_1_WritePeriod(PWM_1_backup.PWMPeriod);
            #endif /* (!PWM_1_PWMModeIsCenterAligned) */
            PWM_1_WriteCounter(PWM_1_backup.PWMUdb);
            #if (PWM_1_UseStatus)
                PWM_1_STATUS_MASK = PWM_1_backup.InterruptMaskValue;
            #endif /* (PWM_1_UseStatus) */
            
            #if(PWM_1_DeadBandMode == PWM_1__B_PWM__DBM_256_CLOCKS || \
                PWM_1_DeadBandMode == PWM_1__B_PWM__DBM_2_4_CLOCKS)
                PWM_1_WriteDeadTime(PWM_1_backup.PWMdeadBandValue);
            #endif /* deadband count is either 2-4 clocks or 256 clocks */
            
            #if(PWM_1_KillModeMinTime)
                PWM_1_WriteKillTime(PWM_1_backup.PWMKillCounterPeriod);
            #endif /* (PWM_1_KillModeMinTime) */
            
            #if(PWM_1_UseControl)
                PWM_1_WriteControlRegister(PWM_1_backup.PWMControlRegister); 
            #endif /* (PWM_1_UseControl) */
        #endif  /* (!PWM_1_UsingFixedFunction) */
    }
Esempio n. 2
0
/*******************************************************************************
* Function Name: PWM_1_RestoreConfig
********************************************************************************
* 
* Summary:
*  Restores the current user configuration of the component.
*
* Parameters:  
*  None
*
* Return: 
*  None
*
* Global variables:
*  PWM_1_backup:  Variables of this global structure are used to  
*  restore the values of non retention registers on wakeup from sleep mode.
*
*******************************************************************************/
void PWM_1_RestoreConfig(void) 
{
        #if(!PWM_1_UsingFixedFunction)
            #if (CY_UDB_V0)
                /* Interrupt State Backup for Critical Region*/
                uint8 PWM_1_interruptState;
                /* Enter Critical Region*/
                PWM_1_interruptState = CyEnterCriticalSection();
                #if (PWM_1_UseStatus)
                    /* Use the interrupt output of the status register for IRQ output */
                    PWM_1_STATUS_AUX_CTRL |= PWM_1_STATUS_ACTL_INT_EN_MASK;
                    
                    PWM_1_STATUS_MASK = PWM_1_backup.InterruptMaskValue;
                #endif /* (PWM_1_UseStatus) */
                
                #if (PWM_1_Resolution == 8)
                    /* Set FIFO 0 to 1 byte register for period*/
                    PWM_1_AUX_CONTROLDP0 |= (PWM_1_AUX_CTRL_FIFO0_CLR);
                #else /* (PWM_1_Resolution == 16)*/
                    /* Set FIFO 0 to 1 byte register for period */
                    PWM_1_AUX_CONTROLDP0 |= (PWM_1_AUX_CTRL_FIFO0_CLR);
                    PWM_1_AUX_CONTROLDP1 |= (PWM_1_AUX_CTRL_FIFO0_CLR);
                #endif /* (PWM_1_Resolution == 8) */
                /* Exit Critical Region*/
                CyExitCriticalSection(PWM_1_interruptState);
                
                PWM_1_WriteCounter(PWM_1_backup.PWMUdb);
                PWM_1_WritePeriod(PWM_1_backup.PWMPeriod);
                
                #if(PWM_1_UseOneCompareMode)
                    PWM_1_WriteCompare(PWM_1_backup.PWMCompareValue);
                #else
                    PWM_1_WriteCompare1(PWM_1_backup.PWMCompareValue1);
                    PWM_1_WriteCompare2(PWM_1_backup.PWMCompareValue2);
                #endif /* (PWM_1_UseOneCompareMode) */
                
               #if(PWM_1_DeadBandMode == PWM_1__B_PWM__DBM_256_CLOCKS || \
                   PWM_1_DeadBandMode == PWM_1__B_PWM__DBM_2_4_CLOCKS)
                    PWM_1_WriteDeadTime(PWM_1_backup.PWMdeadBandValue);
                #endif /* deadband count is either 2-4 clocks or 256 clocks */
            
                #if ( PWM_1_KillModeMinTime)
                    PWM_1_WriteKillTime(PWM_1_backup.PWMKillCounterPeriod);
                #endif /* ( PWM_1_KillModeMinTime) */
            #endif /* (CY_UDB_V0) */
            
            #if (CY_UDB_V1)
                #if(!PWM_1_PWMModeIsCenterAligned)
                    PWM_1_WritePeriod(PWM_1_backup.PWMPeriod);
                #endif /* (!PWM_1_PWMModeIsCenterAligned) */
                PWM_1_WriteCounter(PWM_1_backup.PWMUdb);
                #if (PWM_1_UseStatus)
                    PWM_1_STATUS_MASK = PWM_1_backup.InterruptMaskValue;
                #endif /* (PWM_1_UseStatus) */
                
                #if(PWM_1_DeadBandMode == PWM_1__B_PWM__DBM_256_CLOCKS || \
                    PWM_1_DeadBandMode == PWM_1__B_PWM__DBM_2_4_CLOCKS)
                    PWM_1_WriteDeadTime(PWM_1_backup.PWMdeadBandValue);
                #endif /* deadband count is either 2-4 clocks or 256 clocks */
                
                #if(PWM_1_KillModeMinTime)
                    PWM_1_WriteKillTime(PWM_1_backup.PWMKillCounterPeriod);
                #endif /* (PWM_1_KillModeMinTime) */
            #endif /* (CY_UDB_V1) */
            
            #if(PWM_1_UseControl)
                PWM_1_WriteControlRegister(PWM_1_backup.PWMControlRegister); 
            #endif /* (PWM_1_UseControl) */
        #endif  /* (!PWM_1_UsingFixedFunction) */
    }