Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The Queue is declared in event.h. Implement the four functions of Queue in event.c. main.c (source code provided below) Copy your code in event.c to
The Queue is declared in event.h. Implement the four functions of Queue in event.c. main.c (source code provided below)
Copy your code in event.c to your report and comment your code.
*************************Event.c*************************
#include "event.h" // same event only exists once in que // initialize all elements in Queue to END void initQueue(Queue* que) { } // test if Queue has pending events bool isEmpty(Queue* que) { } // return the current pending event and replace the current with the next event uint8_t pop(Queue* que) { } // add a new event to Queue. // if ev is not in que, alway append ev to the end of que // if ev is in que already, do not append ev void append(Queue* que, uint8_t ev) { }
*************************Main.c*************************
#include "event.h" Queue queue; int main() { // initialize scheduler initQueue(&queue); while (1) { // queue loop while (!isEmpty(&queue)) { // get the event in queue uint8_t event = pop(&queue); // run state machine on the event // could use any state machine implementation handleEvent(event); } } return 0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started