int main() { volatile unsigned char uc1SecFlag = 0; InitDevice(); #if ( _UAP_TYPE == UAP_TYPE_WHART_API ) //SendMessage(STACK_SPECIFIC, HART_RADIO_RESET, API_REQ, 0, 0, NULL); #endif // Rares: Startup Message with useful flags and settings for debug purposes (please do not remove unless you have a good reason) DisplayStartMsg(); for (;;) { g_ucCanSleep = 0; // don't sleep #ifdef TEST_MORE_STATUS // force MORE_STATUS_AVAILABLE condition (to pass UAL048 HCF test) when KBI input is forced to 1 if(GPIO_DATA0_P23) // gGpioPin23_c is KYB1_LINE - initialized as input (STACK line on Adapter board) { APP_SetDeviceStatusFlag(MORE_STATUS_AVAILABLE); g_stCmd48Data.data.standardizedStatus0 = StandardizedStatus0Mask_EnvironmentalConditionsOutOfRange; } #endif //TEST_MORE_STATUS NET_RecvQueueManager(); // rx NET queue handler NET_StateMachine(); // NET join state machine // should be called no more than once at 10ms while using UART1_String(); #ifdef TRANSPORT_EXTRA_BUFFER TL_CheckExtraBuffer(); #endif UART2_CommControl(); DAQ_RxHandler(); HART_CarrierDetectWatch(); ////---- begin 10ms tasks ------------------------------------------------------ if( g_uc10msFlag ) // 10ms Tasks { g_uc10msFlag = 0; // only for AP UART_LINK_Task(); // wired HART HART_DLL_Task(); APP_BurstModeAndEventNotificationTask(); // burst mode task } ////---- end 10ms tasks -------------------------------------------------------- ////++++ begin 250ms tasks +++++++++++++++++++++++++++++++++++++++++++++++++++++ if( g_uc250msFlag ) // 250ms Tasks { static uint8 s_ucCounter250; g_uc250msFlag = 0; if (++uc1SecFlag == 4) { Log("."); uc1SecFlag = 0; } FEED_WDT(); #ifdef LED_CONTROL doLedTask(); // led control task #endif APP_TriggerEvents(); // event triggering APP_PublishAlarmBuffer(); APP_SendHealthReports(); // HealthReports generation APP_SrvcTask(); APP_QueueTask(); REQNM_Task(); #if ( _UAP_TYPE == UAP_TYPE_WHART_API ) DR_Task(); #endif NET_CheckTimers(); TL_doRetry(); // TL retry mechanism NET_CheckOldSessionKeysTimes(); DAQ_TxHandler(); UAP_MainTask(); ////==== begin 1s tasks ====================================================== if ( 0 == ((++s_ucCounter250) & 0x03) ) // 1sec Tasks { #ifdef TEST_HART_MODEM_TX TEST_SendCmd0ToWiredInterface(); #endif /* if( g_ucDllStatus >= DLL_SYNCHRONIZED ) { // Time & Date calculation(synchronous with ASN, max. error = 1s) APP_SetTimeDate(); } */ #ifndef BACKBONE_SUPPORT NET_LoopCheck(); #endif MACA_WatchDog(); } ////==== end 1s tasks ======================================================== // still 250ms zone disconnectTask(); } ////++++ end 250ms tasks +++++++++++++++++++++++++++++++++++++++++++++++++++++++ } // end - for (;;) } // end - main()
/////////////////////////////////////////////////////////////////////////////////// // Name: MAIN Function /////////////////////////////////////////////////////////////////////////////////// void main(void) { IntDisableAll(); WDT_INIT(); Digitals_Init(); ItcInit(); NVM_FlashInit(); CRM_Init(); TMR_Init(); ASM_Init(); UART1_Init(); UART2_Init(); SPI_Init(); PROVISION_Init(); MACA_Init(); DAQ_Init(); DMAP_ResetStack(0); IntEnableAll(); //-------------------------------------------------------------------- // Main Loop //-------------------------------------------------------------------- for (;;) { NLDE_Task(); // as fast as possible, keep this task first on loop DMAP_Task(); // ASLDE_ASLTask(); // UART_LINK_Task(); // UART2_CommControl(); DAQ_RxHandler(); if( g_uc250msFlag ) // 250ms Tasks { g_uc250msFlag = 0; // Handle DAQ after all other stack related tasks. DAQ_TxHandler(); UAP_MainTask(); ARMO_Task(); if( !g_stTAI.m_uc250msStep ) // first 250ms slot from each second -> 1sec Tasks { ASLDE_PerformOneSecondOperations(); DMAP_DMO_CheckNewDevInfoTTL(); DMAP_CheckSecondCounter(); ARMO_OneSecondTask(); SLME_KeyUpdateTask(); DMO_PerformOneSecondTasks(); MACA_WachDog(); } } FEED_WDT(); } }