/******************************************************************************* * Function Name: I2C_Enable ******************************************************************************** * * Summary: * Enables I2C operations. * * Parameters: * None. * * Return: * None. * * Global variables: * None. * *******************************************************************************/ void I2C_Enable(void) { #if (I2C_FF_IMPLEMENTED) uint8 intState; /* Enable power to block */ intState = CyEnterCriticalSection(); I2C_ACT_PWRMGR_REG |= I2C_ACT_PWR_EN; I2C_STBY_PWRMGR_REG |= I2C_STBY_PWR_EN; CyExitCriticalSection(intState); #else #if (I2C_MODE_SLAVE_ENABLED) /* Enable bit counter */ uint8 intState = CyEnterCriticalSection(); I2C_COUNTER_AUX_CTL_REG |= I2C_CNT7_ENABLE; CyExitCriticalSection(intState); #endif /* (I2C_MODE_SLAVE_ENABLED) */ /* Enable slave or master bits */ I2C_CFG_REG |= I2C_ENABLE_MS; #endif /* (I2C_FF_IMPLEMENTED) */ #if (I2C_TIMEOUT_ENABLED) I2C_TimeoutEnable(); #endif /* (I2C_TIMEOUT_ENABLED) */ }
/******************************************************************************* * Function Name: I2C_Enable ******************************************************************************** * * Summary: * Enables I2C operations. * * Parameters: * None * * Return: * None * * Global variables: * None * *******************************************************************************/ void I2C_Enable(void) { #if(I2C_FF_IMPLEMENTED) uint8 enableInterrupts; /* Enable power to I2C FF block */ enableInterrupts = CyEnterCriticalSection(); I2C_ACT_PWRMGR_REG |= I2C_ACT_PWR_EN; I2C_STBY_PWRMGR_REG |= I2C_STBY_PWR_EN; CyExitCriticalSection(enableInterrupts); #else #if(I2C_MODE_SLAVE_ENABLED) uint8 enableInterrupts; #endif /* (I2C_MODE_SLAVE_ENABLED) */ #if(I2C_MODE_SLAVE_ENABLED) /* Enable slave bit counter */ enableInterrupts = CyEnterCriticalSection(); I2C_COUNTER_AUX_CTL_REG |= I2C_CNT7_ENABLE; /* aux_ctl */ CyExitCriticalSection(enableInterrupts); #endif /* (I2C_MODE_SLAVE_ENABLED) */ I2C_CFG_REG |= I2C_ENABLE_MS; #endif /* (I2C_FF_IMPLEMENTED) */ #if(I2C_TIMEOUT_ENABLED) I2C_TimeoutEnable(); #endif /* (I2C_TIMEOUT_ENABLED) */ }
/******************************************************************************* * Function Name: I2C_Wakeup ******************************************************************************** * * Summary: * Wakeup on address match enabled: enables I2C Master (if was enabled before go * to sleep) and disables I2C backup regulator. * Wakeup on address match disabled: Restores I2C configuration and * non-retention register values. Restores Active mode power template bits or * clock gating as appropriate. * The I2C interrupt remains disabled after function call. * * Parameters: * None * * Return: * None * * Reentrant: * No * *******************************************************************************/ void I2C_Wakeup(void) { I2C_RestoreConfig(); /* Restore I2C register settings */ /* Restore component enable state */ if(0u != I2C_backup.enableState) { I2C_Enable(); I2C_EnableInt(); } else { #if(I2C_TIMEOUT_ENABLED) I2C_TimeoutEnable(); #endif /* (I2C_TIMEOUT_ENABLED) */ } }