#include rims. 4. typedef struct task State unsigned long period; unsigned long
ID: 3834003 • Letter: #
Question
#include rims. 4. typedef struct task State unsigned long period; unsigned long elapsed Time. int TickFct. int task 11. task tasks C2 13. cons unsi gned char tasks Num const unsigned long periodBlinkLed 14 1500 15. cons unsigned long periodThreeLeds 50 const unsign ed long tasks riodGCD 500 19. int TickFct BlinkLed (in t state ickFct ThreeLeds (int state int T 21 22. u signed char processingRdyTasks 23. void TimerISR 24 unsigned char i if processingRdy"Tasks 25 26 printf ("Period too short ") 27 processingRay Tasks 1; 29 for i tasks Num ++i 30 if tasks [i] elapsed Time tasks [i period 31 tasks Ei State tasks [i TickFct. tasks [i state 32 tasks [i elapsed Time 0; 34 tasks elapsedTime tasks PeriodGCD; 35 processingRdyTasks 0; 36 37 38. int main 39 40 unsigned char i 0 41 tasks sta te tasks [i period period BlinkLed; 42 tasks [i].elapsedrime asks Lil period 43 44 tasks [i] .TickFct &Tick; Fct BlinkLed. 45 46 ++i, 47 tasks [i ta 48 tasks [i period od Three Leeds peril tasks [i] period 49 tasks [i elapsedTime 50 tasks Lij.TickFct sTickFct ThreeLeds 51 52 53 Timerset (tasks PeriodGCD) 54 Timer on 55 56 while (1 Sleep 57 58 return 0 59 60 61. enum BIL States BL Ledoff BI, Ledon. BL S ta 62. int Tick Fct B. link Led (int state VARIABLES MUST BE DECLARED STATIC* 63 64 /*e.g., static in x o here 65. variables for state machine g 66 itch (state 67 BL Ledoff State 69 break 70 BL Ledoff Case 71 f (A7 72 BL Leedon; sta tee 73 74 break 75 case BL Ledon. 76 if (1 77 BL Ledoff state 78 79 break 80 default 81 state 82 Transitions 83 84 switch (state) 85 case BL Ledoff 86 0 0 87 break. 88 case BL Ledon 89 90 break. 91 default 92 break State actions 93 94 return state 95 96 97 98 TL TO, T T1 TI, T2 TL State enum TL States 99. int TickFct Three Leds (int state VARIABLES MUST BE DECLARED STATIC 100 /*e.g static int x 101 102 /*variables for state machine go here 103 switch (state) 104 case -1: 105 TL T0 State 106 break. 07 case TL TO if 108 109 TI, T1 State 110 break 112 case TL T1 113 if 114 state T2 115 116 brea case TLT2 118 if 119 State TL TO 120 121 break 122 default 123 state 124 125 126 switch (state 127 case TL TO 12B B5 1 129 130 B7 0 131 break 132 case TT, T1 133 B5-0 134 B6-1 135 136 break 137 case TLT 138 B5m0 139 140 7-l 141 break. 142 default 143 break 144 145 sta 146 14Explanation / Answer
Please find the answer below: (upto 4 points) :)
1. Line #4
2. Struvt VAriable task and parameter passed to tock function pointing is state
3 Line# 11
4. See a variable is used so that in future if its value changes we don't have to change whole code, that's why just declare a vary-able (variable) and use it instead of hardcoding.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.