/************************************************************************ ** FUNCTION NAME : Hibernate_init ** ** DESCRIPTION : Initialize the hibernation module. ** ** ARGUMENTS : None ** ** RETURN TYPE : None ** ***************************************************************************/ void Hibernate_init(void) { uint32_t ui32Status = 0; Types_FreqHz cpuFreq; //Get the CPU clock frequency(120MHz) set in BIOS BIOS_getCpuFreq(&cpuFreq); //Extract the 32-bit frequency value ui32SysClock = cpuFreq.lo; // Enable the hibernate module. SysCtlPeripheralEnable(SYSCTL_PERIPH_HIBERNATE); // Initialize these variables before they are used. ui32Status = 0; // Check if Hibernation module is already active, which could mean // that the processor is waking from a hibernation. if(HibernateIsActive()) { // Read the status bits to see what caused the wake. Clear the wake // source so that the device can be put into hibernation again. ui32Status = HibernateIntStatus(0); HibernateIntClear(ui32Status); // System console prints to see which caused wakeup. System_printf("Wake Due To : \n"); // Wake was due to the External Wake pin. else if(ui32Status & HIBERNATE_INT_PIN_WAKE) { System_printf(" Wakeup Pin\n"); } } // Configure Hibernate module clock(120MHz). HibernateEnableExpClk(ui32SysClock); // If the wake was not due to the above sources, then it was a system reset. if(!(ui32Status & (HIBERNATE_INT_PIN_WAKE))) { // Configure the module clock source. HibernateClockConfig(HIBERNATE_OSC_LOWDRIVE); // Print that this was a system restart, not wake from hibernation. System_printf(" System restart\n"); } // Enable processor interrupts. IntMasterEnable(); } /************************************************************************ ** FUNCTION NAME : HandleHibernate ** ** DESCRIPTION : Function to put device into Hibernate mode ** ** ARGUMENTS : None ** ** RETURN TYPE : None ** ***************************************************************************/ void HandleHibernate() { uint32_t ui32Status = 0; // Read and clear any status bits that might have been set since last clearing them. ui32Status = HibernateIntStatus(0); HibernateIntClear(ui32Status); // Configure wakeup pin for Hibernate wakeup source. HibernateWakeSet(HIBERNATE_WAKE_PIN); // Request Hibernation. HibernateRequest(); // Wait for a while for hibernate to activate. It should never get past this point. SysCtlDelay(100); }