/******************************************************************************* * Function Name: PWM_RestoreConfig ******************************************************************************** * * Summary: * Restores the current user configuration of the component. * * Parameters: * None * * Return: * None * * Global variables: * PWM_backup: Variables of this global structure are used to * restore the values of non retention registers on wakeup from sleep mode. * *******************************************************************************/ void PWM_RestoreConfig(void) { #if(!PWM_UsingFixedFunction) #if(!PWM_PWMModeIsCenterAligned) PWM_WritePeriod(PWM_backup.PWMPeriod); #endif /* (!PWM_PWMModeIsCenterAligned) */ PWM_WriteCounter(PWM_backup.PWMUdb); #if (PWM_UseStatus) PWM_STATUS_MASK = PWM_backup.InterruptMaskValue; #endif /* (PWM_UseStatus) */ #if(PWM_DeadBandMode == PWM__B_PWM__DBM_256_CLOCKS || \ PWM_DeadBandMode == PWM__B_PWM__DBM_2_4_CLOCKS) PWM_WriteDeadTime(PWM_backup.PWMdeadBandValue); #endif /* deadband count is either 2-4 clocks or 256 clocks */ #if(PWM_KillModeMinTime) PWM_WriteKillTime(PWM_backup.PWMKillCounterPeriod); #endif /* (PWM_KillModeMinTime) */ #if(PWM_UseControl) PWM_WriteControlRegister(PWM_backup.PWMControlRegister); #endif /* (PWM_UseControl) */ #endif /* (!PWM_UsingFixedFunction) */ }
/******************************************************************************* * Function Name: PWM_RestoreConfig ******************************************************************************** * * Summary: * Restores the current user configuration of the component. * * Parameters: * void * * Return: * void * * Global variables: * PWM_backup: Variables of this global structure are used to * restore the values of non retention registers on wakeup from sleep mode. * *******************************************************************************/ void PWM_RestoreConfig(void) { #if(!PWM_UsingFixedFunction) #if (CY_PSOC5A) /* Interrupt State Backup for Critical Region*/ uint8 PWM_interruptState; /* Enter Critical Region*/ PWM_interruptState = CyEnterCriticalSection(); #if (PWM_UseStatus) /* Use the interrupt output of the status register for IRQ output */ PWM_STATUS_AUX_CTRL |= PWM_STATUS_ACTL_INT_EN_MASK; PWM_STATUS_MASK = PWM_backup.InterruptMaskValue; #endif /* (PWM_UseStatus) */ #if (PWM_Resolution == 8) /* Set FIFO 0 to 1 byte register for period*/ PWM_AUX_CONTROLDP0 |= (PWM_AUX_CTRL_FIFO0_CLR); #else /* (PWM_Resolution == 16)*/ /* Set FIFO 0 to 1 byte register for period */ PWM_AUX_CONTROLDP0 |= (PWM_AUX_CTRL_FIFO0_CLR); PWM_AUX_CONTROLDP1 |= (PWM_AUX_CTRL_FIFO0_CLR); #endif /* (PWM_Resolution == 8) */ /* Exit Critical Region*/ CyExitCriticalSection(PWM_interruptState); PWM_WriteCounter(PWM_backup.PWMUdb); PWM_WritePeriod(PWM_backup.PWMPeriod); #if(PWM_UseOneCompareMode) PWM_WriteCompare(PWM_backup.PWMCompareValue); #else PWM_WriteCompare1(PWM_backup.PWMCompareValue1); PWM_WriteCompare2(PWM_backup.PWMCompareValue2); #endif /* (PWM_UseOneCompareMode) */ #if(PWM_DeadBandMode == PWM__B_PWM__DBM_256_CLOCKS || \ PWM_DeadBandMode == PWM__B_PWM__DBM_2_4_CLOCKS) PWM_WriteDeadTime(PWM_backup.PWMdeadBandValue); #endif /* deadband count is either 2-4 clocks or 256 clocks */ #if ( PWM_KillModeMinTime) PWM_WriteKillTime(PWM_backup.PWMKillCounterPeriod); #endif /* ( PWM_KillModeMinTime) */ #endif /* (CY_PSOC5A) */ #if (CY_PSOC3 || CY_PSOC5LP) #if(!PWM_PWMModeIsCenterAligned) PWM_WritePeriod(PWM_backup.PWMPeriod); #endif /* (!PWM_PWMModeIsCenterAligned) */ PWM_WriteCounter(PWM_backup.PWMUdb); #if (PWM_UseStatus) PWM_STATUS_MASK = PWM_backup.InterruptMaskValue; #endif /* (PWM_UseStatus) */ #if(PWM_DeadBandMode == PWM__B_PWM__DBM_256_CLOCKS || \ PWM_DeadBandMode == PWM__B_PWM__DBM_2_4_CLOCKS) PWM_WriteDeadTime(PWM_backup.PWMdeadBandValue); #endif /* deadband count is either 2-4 clocks or 256 clocks */ #if(PWM_KillModeMinTime) PWM_WriteKillTime(PWM_backup.PWMKillCounterPeriod); #endif /* (PWM_KillModeMinTime) */ #endif /* (CY_PSOC3 || CY_PSOC5LP) */ #if(PWM_UseControl) PWM_WriteControlRegister(PWM_backup.PWMControlRegister); #endif /* (PWM_UseControl) */ #endif /* (!PWM_UsingFixedFunction) */ }