/**************************************************************************** Function ES_Run Parameters None Returns ES_Return_t : FailedRun is any of the run functions failed during execution Description This is the main framework function. It searches through the state machines to find one with a non-empty queue and then executes the state machine to process the event in its queue. while all the queues are empty, it searches for system generated or user generated events. Notes this function only returns in case of an error Author J. Edward Carryer, 10/23/11, ****************************************************************************/ ES_Return_t ES_Run( void ){ // make these static to improve speed uint8_t HighestPrior; static ES_Event ThisEvent; while(1){ // stay here unless we detect an error condition // loop through the list executing the run functions for services // with a non-empty queue. Process any pending ints before testing // Ready while( (_HW_Process_Pending_Ints()) && (Ready != 0)){ HighestPrior = ES_GetMSBitSet(Ready); if ( ES_DeQueue( EventQueues[HighestPrior].pMem, &ThisEvent ) == 0 ){ Ready &= BitNum2ClrMask[HighestPrior]; // mark queue as now empty } if( ServDescList[HighestPrior].RunFunc(ThisEvent).EventType != ES_NO_EVENT) { return FailedRun; } } // all the queues are empty, so look for new user detected events ES_CheckUserEvents(); } }
/**************************************************************************** Function ES_Run Parameters None Returns ES_Return_t : FailedRun is any of the run functions failed during execution Description This is the main framework function. It searches through the state machines to find one with a non-empty queue and then executes the state machine to process the event in its queue. while all the queues are empty, it searches for system generated or user generated events. Notes this function only returns in case of an error Author J. Edward Carryer, 10/23/11, ****************************************************************************/ ES_Return_t ES_Run( void ) { // make these static to improve speed uint8_t HighestPrior; static ES_Event ThisEvent; while(1) { // stay here unless we detect an error condition // loop through the list executing the run functions for services // with a non-empty queue while( Ready != 0) { //printf("Rdy=%X ", Ready); HighestPrior = Byte2MSBitNum[Ready-1]; if ( ES_DeQueue( EventQueues[HighestPrior].pMem, &ThisEvent ) == 0 ) { Ready &= BitNum2ClrMask[HighestPrior]; // mark queue as now empty } if( ServDescList[HighestPrior].RunFunc(ThisEvent).EventType != ES_NO_EVENT) { return FailedRun; } } // all the queues are empty, so look for new system or user detected events if (CheckSystemEvents() == False) ES_CheckUserEvents(); } }