Beispiel #1
0
int main(void){        // lab 3 real main
  OS_Init();           // initialize, disable interrupts

  OS_InitSemaphore(&MailBoxEmpty,1);
  OS_InitSemaphore(&MailBoxFull,0);

  DataLost = 0;        // lost data between producer and consumer
  NumSamples = 0;

//********initialize communication channels
  OS_MailBox_Init();
  OS_Fifo_Init(64);    // ***note*** 4 is not big enough*****

//*******attach background tasks***********
  OS_AddButtonTask(&ButtonPush,2);
  OS_AddDownTask(&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
}
Beispiel #2
0
int main6(void){      // Testmain6
  volatile unsigned long delay;
  OS_Init();           // initialize, disable interrupts
  delay = add(3,4);
  SYSCTL_RCGC2_R |= SYSCTL_RCGC2_GPIOB; // activate port B
  delay = SYSCTL_RCGC2_R;     // allow time to finish activating
  GPIO_PORTB_DIR_R |= 0x07;   // make PB2, PB1, PB0 out
  GPIO_PORTB_DEN_R |= 0x07;   // enable digital I/O on PB2, PB1, PB0
  SignalCount1 = 0;   // number of times s is signaled
  SignalCount2 = 0;   // number of times s is signaled
  SignalCount3 = 0;   // number of times s is signaled
  WaitCount1 = 0;     // number of times s is successfully waited on
  WaitCount2 = 0;     // number of times s is successfully waited on
  WaitCount3 = 0;	  // number of times s is successfully waited on
  OS_InitSemaphore(&s,0);	 // this is the test semaphore
  OS_AddPeriodicThread(&Signal1,(799*TIME_1MS)/1000,0);   // 0.799 ms, higher priority
  OS_AddPeriodicThread(&Signal2,(1111*TIME_1MS)/1000,1);  // 1.111 ms, lower priority
  NumCreated = 0 ;
  NumCreated += OS_AddThread(&Thread6,128,6);    	// idle thread to keep from crashing
  NumCreated += OS_AddThread(&OutputThread,128,2); 	// results output thread
  NumCreated += OS_AddThread(&Signal3,128,2); 	// signalling thread
  NumCreated += OS_AddThread(&Wait1,128,2); 	// waiting thread
  NumCreated += OS_AddThread(&Wait2,128,2); 	// waiting thread
  NumCreated += OS_AddThread(&Wait3,128,2); 	// waiting thread
 
  OS_Launch(TIME_1MS);  // 1ms, doesn't return, interrupts enabled in here
  return 0;             // this never executes
}
Beispiel #3
0
int testmain6(void){      // Testmain6
  volatile unsigned long delay;
  OS_Init();           // initialize, disable interrupts
  delay = add(3,4);

  SignalCount1 = 0;   // number of times s is signaled
  SignalCount2 = 0;   // number of times s is signaled
  SignalCount3 = 0;   // number of times s is signaled
  WaitCount1 = 0;     // number of times s is successfully waited on
  WaitCount2 = 0;     // number of times s is successfully waited on
  WaitCount3 = 0;	  // number of times s is successfully waited on
  OS_InitSemaphore(&s,0);	 // this is the test semaphore
  OS_AddPeriodicThread(&Signal1,(799*TIME_1MS)/1000,0);   // 0.799 ms, higher priority
  OS_AddPeriodicThread(&Signal2,(1111*TIME_1MS)/1000,1);  // 1.111 ms, lower priority
  NumCreated = 0 ;
  NumCreated += OS_AddThread(&Thread6,128,6);    	// idle thread to keep from crashing
  NumCreated += OS_AddThread(&OutputThread,128,2); 	// results output thread
  NumCreated += OS_AddThread(&Signal3,128,2); 	// signalling thread
  NumCreated += OS_AddThread(&Wait1,128,2); 	// waiting thread
  NumCreated += OS_AddThread(&Wait2,128,2); 	// waiting thread
  NumCreated += OS_AddThread(&Wait3,128,2); 	// waiting thread
 
  OS_Launch(TIMESLICE);  // 1ms, doesn't return, interrupts enabled in here
  return 0;             // this never executes
}
Beispiel #4
0
//________________________________________________________________________________
int main(void)
{
char i;

	ConfigDevice();
#ifndef SIMULATION
	ConfigDac();
#endif
	FillTableT();
	FillTableInvDV();
	OS_Init();
	OS_Task_Create(ProcessUartMsg, &task0);
	OS_Task_Create(Pid, &task1);
	OS_Sem_Create(&UartRcMsgSem,0);

	PR2     = OS_TMR_TICK;  // timer tick = 1000 instruction cycles=0.1 ms
	T2CON   = 0x05;
	ReportStartUp();
	while (1) 
		{
		if(TMR1IF)
		{
			TMR1IF=0;
			OS_Task_Resume(&task1);
		}
		asm("CLRWDT");
		OS_Scheduler();
		}
}
Beispiel #5
0
void Boot_Init()
{
	SystemInit(); // CMSIS system initialization
	Board_EarlyInit();
	Console_EarlyInit();

	// Libc-provided function to initialize global structures e.g.
	// calling constructors on global C++ objects
	__libc_init_array();

	OS_Init();
	Console_LateInit();
	Board_LateInit();

	if (__main)
		__main();
	int return_code = main(0, NULL, NULL);

	// If main() returns, call the finalizers/destructors
	extern void __libc_fini_array();
	__libc_fini_array();

	// If we have exit() call that
	if (exit)
		exit(return_code);

	// If exit() returns (!) power down the board
	PowerManagement_PowerDown();
}
Beispiel #6
0
int main(void)
{				  
	
	Stm32_Clock_Init(PLL_FACTOR); //?????? 8*9=72Mhz ADC1
	OS_Init();
	Shedule();
		 
}
Beispiel #7
0
int main(void){
    OS_Init();
    LEDsInit();
    switchesInit(&leftSwitch, &rightSwitch, SWITCH_PRIO);
    SBInit(SYS_CLK_FREQ/SBUS_FREQ, SBUS_ID, SBUS_PRIO);
    OS_AddThread(&IdleTask, 128, 7);
    OS_Launch(SYS_CLK_FREQ/OS_FREQ);
    return 0;
}
Beispiel #8
0
int testmain1(void){ 
  OS_Init();           // initialize, disable interrupts
  NumCreated = 0 ;
  NumCreated += OS_AddThread(&Thread1,128,1); 
  NumCreated += OS_AddThread(&Thread2,128,2); 
  NumCreated += OS_AddThread(&Thread3,128,3); 
 
  OS_Launch(TIMESLICE); // doesn't return, interrupts enabled in here
  return 0;             // this never executes
}
Beispiel #9
0
int testmain5(void){       // Testmain5
  volatile unsigned long delay;
  OS_Init();           // initialize, disable interrupts
  NumCreated = 0 ;
  NumCreated += OS_AddThread(&Thread6,128,2); 
  NumCreated += OS_AddThread(&Thread7,128,1); 
  OS_AddPeriodicThread(&TaskA,(TIME_1MS*111)/100,0);           // 1 ms, higher priority
  OS_AddPeriodicThread(&TaskB,TIME_1MS,1);         // 2 ms, lower priority
  OS_Launch(TIMESLICE); // 2ms, doesn't return, interrupts enabled in here
  return 0;             // this never executes
}
Beispiel #10
0
//******************* test main2 **********
// SYSTICK interrupts, period established by OS_Launch
// Timer interrupts, period established by first call to OS_AddPeriodicThread
int testmain2(void){ 
  OS_Init();           // initialize, disable interrupts
  
  NumCreated = 0 ;
// create initial foreground threads
  NumCreated += OS_AddThread(&TestFile,128,1);  
  NumCreated += OS_AddThread(&IdleTask,128,3); 
 
  OS_Launch(10*TIME_1MS); // doesn't return, interrupts enabled in here
  return 0;               // this never executes
}
Beispiel #11
0
int testmain1(void){       // testmain1
  OS_Init();          // initialize, disable interrupts
  NumCreated = 0 ;
  NumCreated += OS_AddThread(&Thread1,128,1); 
  NumCreated += OS_AddThread(&Thread2,128,2); 
  NumCreated += OS_AddThread(&Thread3,128,3); 
  // Count1 runs, Count2 and Count3 are 0 because of starvation
  // change priority to equal to see round robin
  OS_Launch(TIMESLICE); // doesn't return, interrupts enabled in here
  return 0;             // this never executes
}
Beispiel #12
0
// main program to test the file system (eFile.c)
int filesystem_testmain(void) {
  OS_Init();           // initialize, disable interrupts
  
  //*******attach background tasks***********
  OS_AddPeriodicThread(&disk_timerproc,10*TIME_1MS,0);   // time out routines for disk
  
  // TODO - add threads for testing
  
  OS_Launch(TIMESLICE);
  return 0;
}
Beispiel #13
0
// main program to measure the bandwidth of the SD card
// measure the maximum rate at which you can continuously read from the SD card
// output to unused GPIO pins
int read_main(void) {
  OS_Init();           // initialize, disable interrupts
  
  //*******attach background tasks***********
  OS_AddPeriodicThread(&disk_timerproc,10,0);   // time out routines for disk
  
  // add threads for testing
  OS_AddThread(&read_test, 128, 0);
  
  OS_Launch(TIMESLICE);
  return 0;
}
Beispiel #14
0
int testmain2(void){  // testmain2
  OS_Init();           // initialize, disable interrupts
  NumCreated = 0 ;
  NumCreated += OS_AddThread(&Thread1b,128,1); 
  NumCreated += OS_AddThread(&Thread2b,128,1); 
  NumCreated += OS_AddThread(&Thread3b,128,3);
  OS_AddPeriodicThread(&Dummy1, PERIOD, 1);
  OS_AddPeriodicThread(&Dummy2, PERIOD, 2); 
 
  OS_Launch(TIMESLICE); // doesn't return, interrupts enabled in here
  return 0;             // this never executes
}
Beispiel #15
0
int main(void){
    OS_Init();
    PortF_Init();
		Timer5_Init();
//    SW1_Init(&SW1Press,3);
//    SW2_Init(&SW2Press,3);
    PC6_Init(&PC6High,3);
    PC7_Init(&PC7High,3);
    OS_AddThread(&IdleTask, 128, 7);
    OS_Launch(TIMESLICE);
    return 0;
}
Beispiel #16
0
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
}
Beispiel #17
0
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
}
Beispiel #18
0
//******************* Measurement of context switch time**********
// Run this to measure the time it takes to perform a task switch
// UART0 not needed 
// SYSTICK interrupts, period established by OS_Launch
// first timer not needed
// second timer not needed
// select not needed, 
// down not needed
// logic analyzer on PF0 for systick interrupt
//                on PB0 to measure context switch time
int testmain7(void){   // testmain7
  volatile unsigned long delay;
  OS_Init();           // initialize, disable interrupts
  SYSCTL_RCGC2_R |= SYSCTL_RCGC2_GPIOB; // activate port B
  delay = SYSCTL_RCGC2_R;     // allow time to finish activating
  GPIO_PORTB_DIR_R |= 0x07;   // make PB2, PB1, PB0 out
  GPIO_PORTB_DEN_R |= 0x07;   // enable digital I/O on PB2, PB1, PB0
  NumCreated = 0 ;
  NumCreated += OS_AddThread(&Thread6,128,1); // look at Port B0 on scope 
  OS_Launch(TIME_1MS/10);  // 0.1ms, doesn't return, interrupts enabled in here
  return 0;             // this never executes
}
Beispiel #19
0
void main()
{
 CNC_INITIALIZE();                           // Init periphery
 OS_Init();                                  // Init OS

 OS_Task_Create(1,CNC_CONTROL);
 OS_Task_Create(2,STEPPER_CONTROL);
 OS_EI();                            // Enable interrupts

 OS_Run();

}
Beispiel #20
0
// simple test main
int simple_test_main(void) {
  OS_Init();           // initialize, disable interrupts
	UART_Init();
  //*******attach background tasks***********
  OS_AddPeriodicThread(&disk_timerproc,10,0);   // time out routines for disk
  
  OS_AddThread(&TestFile, 128, 1);
  
  OS_Launch(TIMESLICE);
	
	return 0;
}
//******************************************************************************
// -------------------------- main function ---------------------------
//
// Setup the different alarms and start the kernel.
//
//******************************************************************************
void main(void)
{
	while(1)
	{
	  STKPTR = 0;
	  SelectedMode = DEFAULT_MODE;
	  OS_Init();															// PICOS18 Operating System specific Init

	  vscp_init_app();  									// specific application init in init_app()
	  StartOS(SelectedMode);							// Start Operating System
	}
}
Beispiel #22
0
// main program to measure the bandwidth of the SD card
// measure the maximum rate at which you can continuously write to the SD card
// output to unused GPIO pins
int bandwidth_write_testmain(void) {
  OS_Init();           // initialize, disable interrupts
  
  //*******attach background tasks***********
  OS_AddPeriodicThread(&disk_timerproc,10*TIME_1MS,0);   // time out routines for disk
  
  // add threads for testing
  OS_AddThread(&write_test, 128, 0);  // this thread adds SH_Shell when it's done
  
  OS_Launch(TIMESLICE);
  return 0;
}
Beispiel #23
0
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);
}
Beispiel #24
0
//******************* test main2 **********
// SYSTICK interrupts, period established by OS_Launch
// Timer interrupts, period established by first call to OS_AddPeriodicThread
int testmain2(void){ 
  OS_Init();           // initialize, disable interrupts

//*******attach background tasks***********
  OS_AddPeriodicThread(&disk_timerproc,10*TIME_1MS,0);   // time out routines for disk
  
  NumCreated = 0 ;
// create initial foreground threads
  NumCreated += OS_AddThread(&TestFile,128,1);  
  NumCreated += OS_AddThread(&IdleTask,128,3); 
 
  OS_Launch(10*TIME_1MS); // doesn't return, interrupts enabled in here
  return 0;               // this never executes
}
Beispiel #25
0
Datei: Lab3.c Projekt: jrife/rtos
int Testmain5(void){       // Testmain5
  volatile unsigned long delay;
  SYSCTL_RCGC2_R |= SYSCTL_RCGC2_GPIOB; // activate port B
  delay = SYSCTL_RCGC2_R;     // allow time to finish activating
  GPIO_PORTB_DIR_R |= 0x07;   // make PB2, PB1, PB0 out
  GPIO_PORTB_DEN_R |= 0x07;   // enable digital I/O on PB2, PB1, PB0
  OS_Init();           // initialize, disable interrupts
  NumCreated = 0 ;
  NumCreated += OS_AddThread(&Thread6,128,2); 
  NumCreated += OS_AddThread(&Thread7,128,1); 
  OS_AddPeriodicThread(&TaskA,TIME_1MS,0);           // 1 ms, higher priority
  OS_AddPeriodicThread(&TaskB,2*TIME_1MS,1);         // 2 ms, lower priority
 
  OS_Launch(TIMESLICE); // 2ms, doesn't return, interrupts enabled in here
  return 0;             // this never executes
}
void main(void)
{
    clock_int_48MHz();

    PIC_Init();                     // Configurações gerais do PIC
   
    OS_Init();
    TRISB=0b00000000;
    TRISA=0b00000000;

    OS_Task_Create(1,Task_1);       // Criando uma tarefa,  prioridade 1
    OS_Task_Create(2,Task_2);       // Criando uma tarefa,  prioridade 2
    OS_Task_Create(3,Task_3);       // Criando uma tarefa,  prioridade 3
    //OS_Task_Create(4,Task_4);       // Criando uma tarefa,  prioridade 4

    OS_EI();                        // Habilita interrupcoes
    OS_Run();                       // Executa o RTOS
}
int  main (void)
{
    Init();                             // Init periphery


    OS_Init();                          // Init OS

    OS_Task_Create(0, Task_Rolling);    // Create tasks.
    OS_Task_Create(0, Task_SetSpeed);   // 
    OS_Task_Create(0, Task_Button);     // 

    m_cPosition  = 0;                   // rotation phase
    m_cDirection = 1;                   // direction

    OS_EI();                            // Enable interrupts

    OS_Run();                           // Running scheduler
}
void setup()
{
	eBoxInit();
	OS_Init();
	
	uart1.begin(9600);
	uart1.printf("\r\nuart1 9600 ok!");
	
		uart1.printf("\r\nos初始化!");

	OS_TaskCreate(task_1,&TASK_1_STK[TASK_1_STK_SIZE-1],TASK1_PRIO);
	OS_TaskCreate(task_2,&TASK_2_STK[TASK_2_STK_SIZE-1],TASK2_PRIO);
	OS_TaskCreate(task_3,&TASK_3_STK[TASK_3_STK_SIZE-1],TASK3_PRIO);
	uart1.printf("\r\nos创建任务成功");

	OS_Start();

}
Beispiel #29
0
int main(int argc, char** argv)
{
	//int result;
	OS_Init();
	LoggerCreate(TRUE,"log.txt",LOGGER_APPEND,LOGGER_LEVEL_ALL,LOGGER_FORMAT_C);
	LoggerInfo("Initializing game");
	if(SDL_Init(SDL_INIT_EVERYTHING))
		GameCrash("Initialized SDL failed");
	LoggerInfo("SDL initialized");
	MathInit();
	RM_InitResourceManager();
	PMD_Init();
	RE_InitWindow(WINDOW_WIDTH,WINDOW_HEIGHT);
	IN_InitInput();	
	InitEntities();
	InitAttributes();
	GameMainLoop();
	GameClose();
	return 0;
}
Beispiel #30
0
/* Open test document */
Err OpenTestDocument
    ( 
    Char*           name,
    DocumentInfo*   docInfo
    )
{
    Err     err = 1;
    UInt16  i;

    /* Find the data for the given document */
    for ( i = 0; i < sizeof TestDocument / sizeof TestDocument[ 0 ]; i++ ) {
        PluckerDocument* document;

        document = &TestDocument[ i ];

        if ( STREQ( name, document->name ) ) {
            OS_Init();
            ReadPrefs();
            SetStandardFunctions();
        
            DeleteMetaDocument( document->name, 0 );

            StrCopy( docInfo->name, document->name );
            docInfo->cardNo     = document->cardNo;
            docInfo->size       = document->size;
            docInfo->created    = document->created;
            docInfo->attributes = document->attributes;
            docInfo->categories = document->categories;
            docInfo->location   = document->location;
            docInfo->active     = document->active;
            docInfo->timestamp  = document->timestamp;
            docInfo->volumeRef  = document->volumeRef;
            docInfo->numRecords = document->numRecords;
            docInfo->filename   = document->filename;

            err = OpenDocument( docInfo );
        }
    }
    return err;
}