Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. #include rins.h 2 3 4. typedef struct task state = BL LedOff; break; int state; unsigned long period; unsigned long elapsedTime; int (*TickFct) (int);

image text in transcribed

image text in transcribed

1. #include "rins.h" 2 3 4. typedef struct task state = BL LedOff; break; int state; unsigned long period; unsigned long elapsedTime; int (*TickFct) (int); default: state =-1; 7 ) // Transitions 9 task; 84 switch (state) [ case BL Ledoff: 11. task tasks [2]; break; 13. const unsigned char tasksNum 2; 14. const unsigned long periodBlinkLed = 1500; 15. const unsigned long periodThreeLeds = 500; case BL LedOn: break; default: 17. const unsigned long tasks PeriodGCD = 500; break; ) // State actions 19. int TickFct BlinkLed (int state) 20. int TickFct ThreeLeds (int state) return state: 22. unsigned char processingRdyTasks = 0; 23. void TimerISR ) [ 98. enum TL States TL TO, TL T1, TL T2 TL State 99. int TickFct ThreeLeds (int state) unsigned char i; if (processingRdyTasks) /*VARIABLES MUST BE DECLARED STATIC /te.g., static int x 0;*/ /*variables for state machine go here. printf("Period too short "); 102 103 process!ngRdyTasks for (i -0 i 105 state = TL T0; break; tasks [i].period) 107 108 tasks [1].state = case TL TO tasks[i].TickFct (tasks [i].state); tasks [1j, elapsedTime 0; state = TL T1; 110 tasks [1].elapsedTime tasks PeriodGCD, break; += 112 113 case TL T1: process!ngRdyTasks 0; = state = TL T2 ; 115 116 break; unsigned char i-0; tasks [1].state =-1; tasks [1].period = periodBlinkLed; tasks [1].elapsedTime = tasks [1].period; tasks [1].TickFct=&TickFct BlinkLed; case TL T2: 118 119 120 121 122 state = TL T0; 44. break; 122 123 124 125 126 127 default: tasks [1]. state =-1; tasks [i].period = periodThreeLeds ; tasks [1].elapsedTime = tasks [1].period; tasks [1].TickFct = &TickFct ThreeLeds ; switch (state) ( case TL TO: 129 TimerSet (tasksPeriodGCD) 130 54 TimerOn () break; case TL T1: B5-0; 133 135 137 while (1)Sleep) ) return 0; break; case TL T2: 138 61. enum BL States { BL Ledoff, BL Ledon } BL State 62. int TickFct_BlinkLed (int state) /*VARIABLES MUST BE DECLARED STATIC/ 140 64. /*e.g., static int x = 0;*/ 65. /*variables for state machine go here break; default: 143 switch (state) case-1: break; 145 return state; state = BL LedOff; break; case BL Ledoff: state = BL Ledon ; break; case BL LedOn

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Management Systems

Authors: Mark L. Gillenson

2nd Edition

0470624701, 978-0470624708

More Books

Students also viewed these Databases questions

Question

Find the complement and the supplement of the given angle. 18.2

Answered: 1 week ago

Question

How does selection differ from recruitment ?

Answered: 1 week ago