This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[CC3200MOD] Request to check the hibernation code

Guru 24520 points


Hi TI Experts,

Please check whether there is any problem for my below code.

It seems that this code worked fine, but I would like to know whether the setting of WLAN is correct process.

If you have any advice or find bugs in my code, please let me know.

Best regards.

Kaka

**************************************************************

void HIB_oobTask(void *pvParameters)
{
long lRetVal;
unsigned int uiConnectTimeoutCnt =0;
unsigned char ucConfigOpt = 0;
unsigned char macAddressVal[SL_MAC_ADDR_LEN];
unsigned char macAddressLen = SL_MAC_ADDR_LEN;

if(MAP_PRCMSysResetCauseGet() == 0)
{
// Start the driver
//
lRetVal = sl_Start(0,0,0);
ASSERT_ON_ERROR(lRetVal);

ConfigureMode(ROLE_STA);

/* Disable scan */
ucConfigOpt = SL_SCAN_POLICY(0);
sl_WlanPolicySet(SL_POLICY_SCAN , ucConfigOpt, NULL, 0);
/* Set PM policy to normal */
sl_WlanPolicySet(SL_POLICY_PM , SL_NORMAL_POLICY, NULL, 0);
/* Unregister mDNS services */
sl_NetAppMDNSUnRegisterService(0, 0);
/* disable mdns */
sl_NetAppStop(SL_NET_APP_MDNS_ID);
/* Set connection policy to Auto + fast connect in */
sl_WlanPolicySet(SL_POLICY_CONNECTION, SL_CONNECTION_POLICY(1, 1, 0, 0, 0), NULL, 0);
sl_Stop(10);
}

lRetVal = sl_Start(NULL,NULL,NULL);
ASSERT_ON_ERROR(lRetVal);
//waiting for the device to Auto Connect
while(uiConnectTimeoutCnt<AUTO_CONNECTION_TIMEOUT_COUNT &&
((!IS_CONNECTED(g_ulStatus)) || (!IS_IP_ACQUIRED(g_ulStatus))))
{
//Turn RED LED On
GPIO_IF_LedOn(MCU_RED_LED_GPIO);
osi_Sleep(50);

//Turn RED LED Off
GPIO_IF_LedOff(MCU_RED_LED_GPIO);
osi_Sleep(50);

uiConnectTimeoutCnt++;
}

if(uiConnectTimeoutCnt == AUTO_CONNECTION_TIMEOUT_COUNT)
{
UART_PRINT("Connection to AP failed\n\r",lRetVal);
GPIO_IF_LedOn(MCU_RED_LED_GPIO);
}
else
{
sl_NetCfgGet(SL_MAC_ADDRESS_GET,NULL,&macAddressLen,(unsigned char *)macAddressVal);
sprintf(macAddr, "%02x%02x%02x%02x%02x%02x", macAddressVal[0],macAddressVal[1],macAddressVal[2],macAddressVal[3],macAddressVal[4],macAddressVal[5]);

//
// Stop the driver
//
lRetVal = sl_WlanDisconnect();
if(lRetVal < 0)
{
UART_PRINT("Failed to stop SimpleLink Device\n\r");
LOOP_FOREVER();
}
UART_PRINT("Disconnect WLAN \n\r");
}
sl_Stop(SL_STOP_TIMEOUT);
//
// Enter HIB here configuring the wakeup-timer
//
EnterHIBernate();
}

void EnterHIBernate()
{
#define SLOW_CLK_FREQ (32*1024)
//
// Configure the HIB module RTC wake time (s)
//
MAP_PRCMHibernateIntervalSet(600 * SLOW_CLK_FREQ);

//
// Enable the HIB RTC
//
MAP_PRCMHibernateWakeupSourceEnable(PRCM_HIB_SLOW_CLK_CTR);

UART_PRINT("HIB: Entering HIBernate...\n\r");
MAP_UtilsDelay(80000);

//
// powering down SPI Flash to save power
//
Utils_SpiFlashDeepPowerDown();
//
// Enter HIBernate mode
//
MAP_PRCMHibernateEnter();
}