//**************************************************************************** // //! Implements Sleep followed by wakeup using WDT timeout //! //! \param none //! //! This function //! 1. Implements Sleep followed by wakeup using WDT //! //! \return None. // //**************************************************************************** void PerformPRCMSleepWDTWakeup() { // // Initialize the WDT // WDT_IF_Init(AppWDTCallBackHandler, (4 * SYS_CLK)); // // Enable the Sleep Clock // MAP_PRCMPeripheralClkEnable(PRCM_WDT, PRCM_SLP_MODE_CLK); // // Enter SLEEP...WaitForInterrupt ARM intrinsic // DBG_PRINT("WDT_SLEEP: Entering Sleep\n\r"); MAP_UtilsDelay(80000); MAP_PRCMSleepEnter(); DBG_PRINT("WDT_SLEEP: Exiting Sleep\n\r"); // // Disable the Sleep Clock // MAP_PRCMPeripheralClkDisable(PRCM_WDT, PRCM_SLP_MODE_CLK); // // Deinitialize the WDT // WDT_IF_DeInit(); // // PowerOff WDT // MAP_PRCMPeripheralClkDisable(PRCM_WDT, PRCM_RUN_MODE_CLK); }
//***************************************************************************** // //! main function demonstrates the use of the watchdog timer to perform system //! reset. //! //! \param None //! //! \return None // //***************************************************************************** void main(void) { tBoolean bRetcode; // // Initialize the board // BoardInit(); // // Pinmuxing for LEDs // PinMuxConfig(); // // configure RED LED // GPIO_IF_LedConfigure(LED1); GPIO_IF_LedOff(MCU_RED_LED_GPIO); // // Enable the peripherals used by this example. // MAP_PRCMPeripheralClkEnable(PRCM_WDT, PRCM_RUN_MODE_CLK); // // Set up the watchdog interrupt handler. // WDT_IF_Init(WatchdogIntHandler, MILLISECONDS_TO_TICKS(WD_PERIOD_MS)); // // Start the timer. Once the timer is started, it cannot be disable. // MAP_WatchdogEnable(WDT_BASE); bRetcode = MAP_WatchdogRunning(WDT_BASE); if(!bRetcode) { WDT_IF_DeInit(); } // // Loop forever while the LED winks as watchdog interrupts are handled. // while(FOREVER) { } }
//***************************************************************************** // //! main function demonstrates the use of the watchdog timer to perform system //! reset. //! //! \param None //! //! \return None // //***************************************************************************** void main(void) { tBoolean bRetcode; // // Initialize the board // BoardInit(); // // Pinmuxing for LEDs // PinMuxConfig(); // // configure RED LED // GPIO_IF_LedConfigure(LED1); GPIO_IF_LedOff(MCU_RED_LED_GPIO); // // Set up the watchdog interrupt handler. // WDT_IF_Init(WatchdogIntHandler, MILLISECONDS_TO_TICKS(WD_PERIOD_MS)); bRetcode = MAP_WatchdogRunning(WDT_BASE); if(!bRetcode) { WDT_IF_DeInit(); } // // Loop forever while the LED winks as watchdog interrupts are handled. // while(FOREVER) { } }
//***************************************************************************** // //! \brief Connecting to a WLAN Accesspoint //! This function connects to the required AP (SSID_NAME). //! This code example assumes the AP doesn't use WIFI security. //! The function will return only once we are connected //! and have acquired IP address //! //! \param[in] None //! //! \return 0 means success, -1 means failure //! //! \note //! //! \warning If the WLAN connection fails or we don't aquire an IP address, //! We will be stuck in this function forever. // //***************************************************************************** int WlanConnect() { int iRetCode = 0; int iRetVal = 0; int iConnect = 0; unsigned char ucQueueMsg = 0; SlSecParams_t secParams; secParams.Key = (signed char *)SECURITY_KEY; secParams.KeyLen = strlen((const char *)secParams.Key); secParams.Type = SECURITY_TYPE; // // Set up the watchdog interrupt handler. // WDT_IF_Init(WatchdogIntHandler, MILLISECONDS_TO_TICKS(WD_PERIOD_MS)); /* Enabling the Sleep clock for the Watch Dog Timer*/ MAP_PRCMPeripheralClkEnable(PRCM_WDT, PRCM_SLP_MODE_CLK); g_ucFeedWatchdog = 1; g_ucWdogCount = 0; while(!(ucQueueMsg & (EVENT_IP_ACQUIRED|CONNECTION_FAILED))) { UART_PRINT("Trying to connect to AP: "); UART_PRINT(SSID_NAME); UART_PRINT("\n\r"); sl_WlanConnect((signed char *)SSID_NAME, strlen((const char *)SSID_NAME), 0, &secParams, 0); iConnect = 0; do{ osi_MsgQRead(&g_tConnection, &ucQueueMsg, OSI_WAIT_FOREVER); switch(ucQueueMsg) { case EVENT_CONNECTION: iConnect = 1; break; case EVENT_IP_ACQUIRED: iRetVal = 0; break; case WDOG_EXPIRED: // // disconnect from the Access Point // if(iConnect) { WlanDisconnect(); } // // stop the simplelink with reqd. timeout value (30 ms) // sl_Stop(SL_STOP_TIMEOUT); UART_PRINT("sl stop\n\r"); MAP_UtilsDelay(8000); // // starting the simplelink // sl_Start(NULL, NULL, NULL); UART_PRINT("sl start\n\r"); break; case EVENT_DISCONNECTION: iConnect = 0; break; case CONNECTION_FAILED: iRetVal = -1; break; default: UART_PRINT("unexpected event\n\r"); break; } }while(ucQueueMsg == (unsigned char)EVENT_CONNECTION); } iRetCode = MAP_WatchdogRunning(WDT_BASE); if(iRetCode) { WDT_IF_DeInit(); MAP_PRCMPeripheralClkDisable(PRCM_WDT, PRCM_RUN_MODE_CLK); } ASSERT_ON_ERROR(iRetVal); return(iRetVal); }