//******** Display *************** // foreground thread, accepts data from consumer // displays calculated results on the LCD // inputs: none // outputs: none void Display(void){ unsigned long data,voltage; oLED_Message(0,0,"Run length is",(RUNLENGTH)/1000); // top half used for Display while(NumSamples < RUNLENGTH) { oLED_Message(0,1,"Time left is",(RUNLENGTH-NumSamples)/1000); // top half used for Display data = OS_MailBox_Recv(); voltage = 3000*data/1024; // calibrate your device so voltage is in mV oLED_Message(0,2,"v(mV) =",voltage); } OS_Kill(); // done }
//------------------Task 2-------------------------------- // background thread executes with select button // one foreground task created with button push // foreground treads run for 2 sec and die // ***********ButtonWork************* void ButtonWork(void){ unsigned long i; unsigned long myId = OS_Id(); oLED_Message(1,0,"NumCreated =",NumCreated); if(NumSamples < RUNLENGTH){ // finite time run for(i=0;i<20;i++){ // runs for 2 seconds //OS_Sleep(20); // set this to sleep for 0.1 sec } } oLED_Message(1,1,"PIDWork =",PIDWork); oLED_Message(1,2,"DataLost =",DataLost); oLED_Message(1,3,"Jitter(us) =",MaxJitter-MinJitter); OS_Kill(); // done }
//------------------Task 2-------------------------------- // background thread executes with select button // one foreground task created with button push // foreground treads run for 2 sec and die // ***********ButtonWork************* void ButtonWork(void){ unsigned long i; unsigned long myId = OS_Id(); oLED_Message(1,0,"NumCreated =",NumCreated); if(NumSamples < RUNLENGTH){ // finite time run for(i=0;i<40;i++){ // runs for 2 seconds OS_Sleep(50); // sleep for 50ms } } oLED_Message(1,1,"PIDWork =",PIDWork); oLED_Message(1,2,"DataLost =",DataLost); oLED_Message(1,3,"0.1u Jitter=",MaxJitter1-MinJitter1); OS_Kill(); // done }
void Thread7(void){ // foreground thread //print("\n\rEE345M/EE380L, Lab 3 Preparation 2\n\r"); oLED_Message(1,0,"\n\rEE345M/EE380L, Lab 3 Preparation 2\n\r",-0); OS_Sleep(5000); // 10 seconds Jitter(); // print jitter information printf("\n\r\n\r"); OS_Kill(); }
// ******** Jitter **************** // prints the jitter info for the both periodic background thread void Jitter(void) { oLED_Message(1, 2, "0.1u Jitter1=", MaxJitter1 - MinJitter1); oLED_Message(1, 3, "0.1u Jitter2=", MaxJitter2 - MinJitter2); }
void Jitter(void){ oLED_Message(1,3,"Jitter(us) =", MaxJitter-MinJitter); }