예제 #1
0
파일: main.c 프로젝트: bigcat26/cc3200-sdk
//****************************************************************************
//
//! 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);
}
예제 #2
0
파일: main.c 프로젝트: Balu1991/Wifly_Light
//*****************************************************************************
//
//!	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)
    {

    }
}
예제 #3
0
//*****************************************************************************
//
//!    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)
    {

    }
}
예제 #4
0
//****************************************************************************
//                            MAIN FUNCTION
//****************************************************************************
void main()
{
    long retVal = -1;
    unsigned long ulResetCause;
    unsigned long ulDestinationIP;

    //
    // Board Initialization
    //
    BoardInit();

    //
    // Configure the pinmux settings for the peripherals exercised
    //
    PinMuxConfig();

    //
    // Configuring UART
    //
    InitTerm();

    //
    // Initialize WDT
    //
    WDT_IF_Init(NULL,80000000 * 10);

    //
    // Get the reset cause
    //
    ulResetCause = PRCMSysResetCauseGet();

    //
    // If watchdog triggered reset request hibernate
    // to clean boot the system
    //
    if( ulResetCause == PRCM_WDT_RESET )
    {
        HIBEntrePreamble();
        MAP_PRCMOCRRegisterWrite(0,1);
        MAP_PRCMHibernateWakeupSourceEnable(PRCM_HIB_SLOW_CLK_CTR);
        MAP_PRCMHibernateIntervalSet(330);
        MAP_PRCMHibernateEnter();
    }

    //
    // uDMA Initialization
    //
    UDMAInit();

    //
    // Display banner
    //
    DisplayBanner(APPLICATION_NAME);

    if( ulResetCause == PRCM_HIB_EXIT &&  (MAP_PRCMOCRRegisterRead(0) & 1) == 1 )
    {
        UART_PRINT("Reset Cause        : Watchdog Reset\n\r");
    }
    else
    {
        UART_PRINT("Reset Cause        : Power On\n\r");

        //
        // Initialize the variables.
        //
        InitializeAppVariables();

        //
        // Following function configure the device to default state by cleaning
        // the persistent settings stored in NVMEM (viz. connection profiles &
        // policies, power policy etc)
        //
        // Applications may choose to skip this step if the developer is sure
        // that the device is in its desired state at start of applicaton
        //
        // Note that all profiles and persistent settings that were done on the
        // device will be lost
        //
        retVal = ConfigureSimpleLinkToDefaultState();

        if(retVal < 0)
        {
            if (DEVICE_NOT_IN_STATION_MODE == retVal)
                UART_PRINT("Failed to configure the device in its default"
                            " state \n\r");

            LOOP_FOREVER();
        }
    }

    //
    // Set destination IP
    //
    ulDestinationIP = IP_ADDR;

    //
    // Asumption is that the device is configured in station mode already
    // and it is in its default state
    //
    retVal = sl_Start(0, 0, 0);

    //
    // Acknowledge the watchdog so that it doesn't resets
    //
    WatchdogAck();

    if (retVal < 0 || retVal != ROLE_STA)
    {
        UART_PRINT("Failed to start the device \n\r");
        LOOP_FOREVER();
    }

    //
    //Connecting to WLAN AP
    //
    retVal = WlanConnect();

    //
    // Acknowledge the watchdog so that it doesn't resets
    //
    WatchdogAck();

    if(retVal < 0)
    {
        UART_PRINT("Failed to establish connection w/ an AP \n\r");
        LOOP_FOREVER();
    }

    UART_PRINT("Connected to AP    : %s \n\r",SSID_NAME);

    UART_PRINT("Device IP          : %d.%d.%d.%d\n\r\n\r",
                SL_IPV4_BYTE(g_ulIpAddr,3),
                SL_IPV4_BYTE(g_ulIpAddr,2),
                SL_IPV4_BYTE(g_ulIpAddr,1),
                SL_IPV4_BYTE(g_ulIpAddr,0));


    UART_PRINT("\nStarting UDP Client\n\n\r");

    UART_PRINT("Source IP          : %d.%d.%d.%d\n\r"
                 "Destination IP     : %d.%d.%d.%d\n\r"
                 "PORT               : %d\n\r",
                 SL_IPV4_BYTE(g_ulIpAddr,3),
                 SL_IPV4_BYTE(g_ulIpAddr,2),
                 SL_IPV4_BYTE(g_ulIpAddr,1),
                 SL_IPV4_BYTE(g_ulIpAddr,0),
                 SL_IPV4_BYTE(ulDestinationIP,3),
                 SL_IPV4_BYTE(ulDestinationIP,2),
                 SL_IPV4_BYTE(ulDestinationIP,1),
                 SL_IPV4_BYTE(ulDestinationIP,0),
                 g_uiPortNum);


    //
    // Acknowledge the watchdog so that it doesn't resets
    //
    WatchdogAck();

    //
    // Send packets
    //
    BsdUdpClient(PORT_NUM,ulDestinationIP);


    //
    // power off the network processor
    //
    sl_Stop(SL_STOP_TIMEOUT);
    while (1)
    {
        _SlNonOsMainLoopTask();
    }
}
예제 #5
0
파일: main.c 프로젝트: bigcat26/cc3200-sdk
//*****************************************************************************
//
//! \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);
}