void main(void){ ES_Event MyEvent; bool bReturn; ES_InitQueue( TestQueue, ARRAY_SIZE(TestQueue) ); MyEvent.EventType = 0; MyEvent.EventParam = 1; bReturn = ES_EnQueueFIFO( TestQueue, MyEvent ); bReturn +=1; // keep that sily optimizer away // Try stuffing one on using the LIFO rule MyEvent.EventType = 10; MyEvent.EventParam = 11; bReturn = ES_EnQueueLIFO( TestQueue, MyEvent ); bReturn +=1; // keep that sily optimizer away // at this point, the events in the queue should be 11,0 // so pull off the 11, leaving 1 entry NumLeft = ES_DeQueue( TestQueue, &MyEvent); if ( NumLeft != 1) bReturn = 0; MyEvent.EventType = 2; MyEvent.EventParam = 3; bReturn = ES_EnQueueFIFO( TestQueue, MyEvent ); bReturn +=1; // keep that sily optimizer away MyEvent.EventType = 4; MyEvent.EventParam = 5; bReturn = ES_EnQueueFIFO( TestQueue, MyEvent ); bReturn +=1; // keep that sily optimizer away // queue is now full so this one should fail MyEvent.EventType = 6; MyEvent.EventParam = 7; bReturn = ES_EnQueueFIFO( TestQueue, MyEvent ); bReturn +=1; // keep that sily optimizer away // at this point, the events in the queue should be 0,2,4 // so pull off the 0, leaving 2 entries NumLeft = ES_DeQueue( TestQueue, &MyEvent); if ( NumLeft != 2) bReturn = 0; // Try stuffing one on using the LIFO rule MyEvent.EventType = 8; MyEvent.EventParam = 9; bReturn = ES_EnQueueLIFO( TestQueue, MyEvent ); bReturn +=1; // keep that sily optimizer away // at this point, the events in the queue should be 8,2,4 // so pull off the 8, leaving 2 entries NumLeft = ES_DeQueue( TestQueue, &MyEvent); NumLeft += 3; //to keep the compiler from optimizing away the last save while(1) ; }
/**************************************************************************** Function ES_Initialize Parameters TimerRate_t the rate at which to initialize the framework timer subsystem Returns ES_Return_t : FailedPointer if any of the function pointers are NULL FailedInit if any of the initialization functions failed Description Initialize all the services and tests for NULL pointers in the array Notes Author J. Edward Carryer, 10/23/11, ****************************************************************************/ ES_Return_t ES_Initialize( TimerRate_t NewRate ){ uint8_t i; ES_Timer_Init( NewRate); // start up the timer subsystem // loop through the list testing for NULL pointers and for ( i=0; i< ARRAY_SIZE(ServDescList); i++) { if ( (ServDescList[i].InitFunc == (pInitFunc)0) || (ServDescList[i].RunFunc == (pRunFunc)0) ) return FailedPointer; // protect against NULL pointers // and initializing the event queues (must happen before running inits) ES_InitQueue( EventQueues[i].pMem, EventQueues[i].Size ); // executing the init functions if ( ServDescList[i].InitFunc(i) != true ) return FailedInit; // this is a failed initialization } return Success; }