//*******************final user main DEMONTRATE THIS TO TA********** int mainmain(void){ // lab 3 real main OS_Init(); // initialize, disable interrupts DataLost = 0; // lost data between producer and consumer NumSamples = 0; MaxJitter = 0; // OS_Time in 20ns units MinJitter = 10000000; //********initialize communication channels OS_MailBox_Init(); OS_Fifo_Init(32); // ***note*** 4 is not big enough***** //*******attach background tasks*********** OS_AddButtonTask(&ButtonPush,2); OS_AddButtonTask(&DownPush,3); OS_AddPeriodicThread(&DAS,PERIOD,1); // 2 kHz real time sampling NumCreated = 0 ; // create initial foreground threads NumCreated += OS_AddThread(&Interpreter,128,2); NumCreated += OS_AddThread(&Consumer,128,1); NumCreated += OS_AddThread(&PID,128,3); OS_Launch(TIMESLICE); // doesn't return, interrupts enabled in here return 0; // this never executes }
//*******************final user main DEMONTRATE THIS TO TA********** int main(void){ // Set the clocking to run from PLL at 50 MHz SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ); OS_Init(); // initialize, disable interrupts DataLost = 0; // lost data between producer and consumer NumSamples = 0; MaxJitter = 0; // OS_Time in 20ns units MinJitter = 10000000; //********initialize communication channels OS_MailBox_Init(); OS_Fifo_Init(32); // ***note*** 4 is not big enough***** //*******attach background tasks*********** OS_AddButtonTask(&ButtonPush,2); OS_AddPeriodicThread(&DAS,PERIOD,0); // 2 kHz real time sampling NumCreated = 0 ; // create initial foreground threads NumCreated += OS_AddThread(&Interpreter,128,2); NumCreated += OS_AddThread(&Consumer,128,1); NumCreated += OS_AddThread(&PID,128,3); OS_Launch(TIMESLICE); // doesn't return, interrupts enabled in here return 0; // this never executes }
int testmain4(void){ // Testmain4 Count4 = 0; OS_Init(); // initialize, disable interrupts NumCreated = 0 ; OS_AddPeriodicThread(&BackgroundThread1d,1,PERIOD,0); OS_AddButtonTask(&BackgroundThread5d,2); NumCreated += OS_AddThread(&Thread2d,128,2); NumCreated += OS_AddThread(&Thread3d,128,3); NumCreated += OS_AddThread(&Thread4d,128,3); OS_Launch(TIMESLICE/16); // doesn't return, interrupts enabled in here return 0; // this never executes }
int testmain3(void){ // Testmain3 Count4 = 0; OS_Init(); // initialize, disable interrupts // Count2 + Count5 should equal Count1 (Count5 may be zero) NumCreated = 0 ; OS_AddButtonTask(&BackgroundThread5c,2); NumCreated += OS_AddThread(&Thread2c,128,3); NumCreated += OS_AddThread(&Thread3c,128,3); NumCreated += OS_AddThread(&Thread4c,128,3); OS_Launch(TIMESLICE); // doesn't return, interrupts enabled in here return 0; // this never executes }
int main2(void) { #if PROFILING == 1 volatile unsigned long delay; #endif /* Initialize 8MHz clock */ SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_XTAL_8MHZ | SYSCTL_OSC_MAIN); OLED_Init(15); ADC_Init(1000); ADC_Open(0); ADC_Open(1); SH_Init(); OS_Init(); OS_MailBox_Init(); SH_Init(); //********initialize communication channels OS_MailBox_Init(); OS_Fifo_Init(32); NumCreated = 0; NumSamples = 0; MaxJitter = 0; // OS_Time in 20ns units MinJitter = 10000000; #if PROFILING // intialize port b pins as specified by PINS mask // for digital output for use in profiling threads SYSCTL_RCGC2_R |= SYSCTL_RCGC2_GPIOB; delay = SYSCTL_RCGC2_R; GPIO_PORTB_DIR_R |= PINS; GPIO_PORTB_DEN_R |= PINS; GPIO_PORTB_DATA_R &= ~PINS; #endif // testing/debugging stuff OS_Add_Periodic_Thread(&DAS,2,1); // OS_AddButtonTask(&dummyButtonTask, 1); OS_AddButtonTask(&ButtonPush, 1); OS_AddDownTask(&ButtonPush, 1); // NumCreated += OS_AddThread(&jerkTask, 0, 6); // NumCreated += OS_AddThread(&dummyTask3, 0, 7); // NumCreated += OS_AddThread(&dummyTask1, 0, 2); NumCreated += OS_AddThread(&PID, 128, 5); // NumCreated += OS_AddThread(&dummyTask2, 0, 2); NumCreated += OS_AddThread(&Consumer, 128, 0); NumCreated += OS_AddThread(&SH_Shell, 128, 6); OS_Launch(TIMESLICE); /* Loop indefinitely */ while(1); }
//*******************lab 5 main ********** int realmain(void){ // lab 5 real main OS_Init(); // initialize, disable interrupts Running = 0; // robot not running DataLost = 0; // lost data between producer and consumer NumSamples = 0; //********initialize communication channels // OS_Fifo_Init(512); // ***note*** 4 is not big enough***** // ADC_Collect(0, 1000, &Producer); // start ADC sampling, channel 0, 1000 Hz //*******attach background tasks*********** OS_AddButtonTask(&ButtonPush,2); OS_AddButtonTask(&DownPush,3); OS_AddPeriodicThread(disk_timerproc,10*PERIODIC_TIME_1MS,5); NumCreated = 0 ; // create initial foreground threads NumCreated += OS_AddThread(&Interpreter,128,2); NumCreated += OS_AddThread(&IdleTask,128,7); // runs when nothing useful to do OS_Launch(TIMESLICE); // doesn't return, interrupts enabled in here return 0; // this never executes }
//******************* test main1 ********** // SYSTICK interrupts, period established by OS_Launch // Timer interrupts, period established by first call to OS_AddPeriodicThread int testmain1(void){ // testmain1 OS_Init(); // initialize, disable interrupts //*******attach background tasks*********** OS_AddPeriodicThread(&disk_timerproc,TIME_1MS,0); // time out routines for disk OS_AddButtonTask(&RunTest,2); NumCreated = 0 ; // create initial foreground threads NumCreated += OS_AddThread(&TestFile,128,1); NumCreated += OS_AddThread(&IdleTask,128,1); OS_Launch(TIME_1MS); // doesn't return, interrupts enabled in here return 0; // this never executes }