/***************************************************************************** * Initialization function for the App Task. This is called during * initialization and should contain any application specific initialization * (ie. hardware initialization/setup, table initialization, power up * notificaiton. * * Interface assumptions: None * * Return value: None * *****************************************************************************/ void MApp_init(void) { /* The initial application state */ gState = stateInit; /* Reset number of pending packets */ mcPendingPackets = 0; /* Allow sending a poll request */ mWaitPollConfirm = FALSE; /* Initialize the poll interval */ mPollInterval = mDefaultValueOfPollIntervalSlow_c; /* Initialize the MAC 802.15.4 extended address */ Init_MacExtendedAddress(); mTimer_c = TMR_AllocateTimer(); /* register keyboard callback function */ KBD_Init(App_HandleKeys); /* initialize LCD Module */ LCD_Init(); /* initialize LED Module */ LED_Init(); //WSNProject /*initialize the usage of power consumption*/ PWR_CheckForAndEnterNewPowerState_Init(); /* Initialize the UART so that we can print out status messages */ UartX_SetBaud(gUartDefaultBaud_c); UartX_SetRxCallBack(UartRxCallBack); /* Prepare input queues.*/ MSG_InitQueue(&mMlmeNwkInputQueue); MSG_InitQueue(&mMcpsNwkInputQueue); /* Enable MCU interrupts */ IntEnableAll(); /*signal app ready*/ Led1Flashing(); Led2Flashing(); Led3Flashing(); Led4Flashing(); UartUtil_Print("\n\rPress any switch on board to start running the application.\n\r", gAllowToBlock_d); LCD_ClearDisplay(); LCD_WriteString(1,"Press any key"); LCD_WriteString(2,"to start."); }
/************************************************* * Function: MSG_Init() * Description: * Author: cxy * Returns: * Parameter: * History: *************************************************/ void //ICACHE_FLASH_ATTR MSG_Init() { u32 u32Index; MSG_InitQueue(&g_struRecvQueue); MSG_InitQueue(&g_struSendQueue); g_struRecvBuffer.u32Len = 0; g_struRecvBuffer.u8Status = MSG_BUFFER_IDLE; for (u32Index = 0; u32Index < MSG_BUFFER_SEND_MAX_NUM; u32Index++) { g_struSendBuffer[u32Index].u32Len = 0; g_struSendBuffer[u32Index].u8Status = MSG_BUFFER_IDLE; } g_struClientBuffer.u32Len = 0; g_struClientBuffer.u8Status = MSG_BUFFER_IDLE; }