Esempio n. 1
0
/*
 * Initialization of Serail communication
 */
struct RS232 initRS232() {
	struct RS232 com_local;
	com_local.receivePackets = initQueue();
	com_local.sendPackets = initQueue();
	com_local.pendingPacketSize = initQueue();
	com_local.client_ack = 0;
	com_local.host_ack = 0;
	com_local.isRdySend = 0;
	com_local.failReceive = 0;
	com_local.stateMachine = (enum States*)malloc(sizeof(enum States));
	com_local.pastState = (enum States*)malloc(sizeof(enum States));
	*com_local.stateMachine = startInit;
	*com_local.pastState = startInit;
	com_local.num_packets = com_local.index_packets = 0;
	com_local.num_send_packets = com_local.index_send_packets = 0;
	com_local.packetBuf = NULL;

	printf("UART Initialization\n");
	alt_up_rs232_dev* uart = alt_up_rs232_open_dev(RS232_0_NAME);
	up_dev.RS232_dev = uart;

	printf("Clearing read buffer to start\n");
	while (alt_up_rs232_get_used_space_in_read_FIFO(uart)) {
		alt_up_rs232_read_data(uart, &com.data[0], &com.parity);
	}
	alt_alarm_start(&alarm, alt_ticks_per_second(), RS232_ISR, (void*)&up_dev);

	printf("UART Initialization finished\n");
	return com_local;
}
Esempio n. 2
0
int main ()
{
    /* set interrupt capability for the Button PIO. */
    IOWR_ALTERA_AVALON_PIO_IRQ_MASK(DE2_PIO_KEYS4_BASE, 0xf);
    /* Reset the edge capture register. */
    IOWR_ALTERA_AVALON_PIO_EDGE_CAP(DE2_PIO_KEYS4_BASE, 0x0);
    // Register the ISR for buttons
    alt_irq_register(DE2_PIO_KEYS4_IRQ, NULL, Key_InterruptHandler);

    /* The alarm for calling the timer function */
    static alt_alarm alarm;
    /* Register the flashing function for the timer */
    if (alt_alarm_start (&alarm,alt_ticks_per_second(),show,NULL) < 0)
    {
        printf ("No system clock available\n");
    }

    int current_prime = 0;
    while (TRUE)
    {
        current_prime = next_prime(current_prime);
        printf("\nNext Prime is %d",current_prime);
    }

    return 0;
}
Esempio n. 3
0
void promptSDcard(struct Env* p, alt_up_sd_card_dev* device_reference) {
	/*
	 * Loading Screen if SD card is not presented
	 */

	int frame = 25;
	struct animation* b = initAnimation((int*)pacman01, 1);
	addImage(b, initAnimation((int*)pacman02, 0));
	addImage(b, initAnimation((int*)pacman03, 0));
	addImage(b, initAnimation((int*)pacman04, 0));
	struct Object *face;
	face= initObject(80, 120, 10, b, NULL);
	addToEnv(p, face);

	alt_alarm_start (&alarm,alt_ticks_per_second(),my_alarm_callback,(void*)p);


	while(!loadSDCard(device_reference)) {
		displayString("Please insert the SD card to start", frame, 30);
		frame++;
		setXY(face, face->x+4, face->y);
		if(face->x >245) face->x = 0;
		if(frame > 61) frame = 0;

		usleep(300000);
	}alt_up_char_buffer_clear(char_buffer);
	killAnimation(b);
	removeFromEnv(p, face);
	alt_alarm_stop(&alarm);
	alt_up_pixel_buffer_dma_clear_screen(pixel_buffer, 0);
}
Esempio n. 4
0
// Our operating system prototype
void prototype_os()
{
	nextBufferIndex = 0;
	full = mysem_create(0);
	empty = mysem_create(BUFFER_SIZE);
	mutex = mysem_create(1);
	int i = 0;
	running_thread[1] = NULL;
	TCB *threads[NUM_THREADS];
	for (i = 0; i < NUM_THREADS; i++)
	{
		// Here: call mythread_create so that the TCB for each thread is created
		TCB *tcb = (TCB *) malloc(sizeof(TCB));
		if (i % 2 == 0)
			mythread_create(tcb, &consumer, i);
		else
			mythread_create(tcb, &producer, i);
		threads[i] = tcb;
	}
	// Here: initialize the timer and its interrupt handler as is done in Project I
	alt_alarm * myAlarm;
	alt_alarm_start( &myAlarm, ALARMTICKS(QUANTUM_LENGTH), &mythread_handler, NULL);
	for (i = 0; i < NUM_THREADS; i++)
	{
		// Here: call mythread_join to suspend prototype_os
		mythread_join(i);
	}

	while (TRUE)
	{
		alt_printf ("This is the OS prototype for my exciting CSE351 course projects!\n");
		int j = 0;
		for (j = 0 ; j < MAX * 10; j++);
	}
}
/*
 * lcd_16207_init is called at boot time to initialise the LCD driver
 */
void alt_lcd_16207_init(alt_LCD_16207_dev * dev)
{
  unsigned int base = dev->base;

  /* Mark the device as functional */
  dev->broken = 0;

  ALT_SEM_CREATE (&dev->write_lock, 1);

  /* TODO: check that usleep can be called in an initialisation routine */

  /* The initialisation sequence below is copied from the datasheet for
   * the 16207 LCD display.  The first commands need to be timed because
   * the BUSY bit in the status register doesn't work until the display
   * has been reset three times.
   */

  /* Wait for 15 ms then reset */
  usleep(15000);
  IOWR_ALTERA_AVALON_LCD_16207_COMMAND(base, LCD_CMD_FUNCTION_SET | LCD_CMD_8BIT);

  /* Wait for another 4.1ms and reset again */
  usleep(4100);
  IOWR_ALTERA_AVALON_LCD_16207_COMMAND(base, LCD_CMD_FUNCTION_SET | LCD_CMD_8BIT);

  /* Wait a further 1 ms and reset a third time */
  usleep(1000);
  IOWR_ALTERA_AVALON_LCD_16207_COMMAND(base, LCD_CMD_FUNCTION_SET | LCD_CMD_8BIT);

  /* Setup interface parameters: 8 bit bus, 2 rows, 5x7 font */
  lcd_write_command(dev, LCD_CMD_FUNCTION_SET | LCD_CMD_8BIT | LCD_CMD_TWO_LINE);

  /* Turn display off */
  lcd_write_command(dev, LCD_CMD_ONOFF);

  /* Clear display */
  lcd_clear_screen(dev);

  /* Set mode: increment after writing, don't shift display */
  lcd_write_command(dev, LCD_CMD_MODES | LCD_CMD_MODE_INC);

  /* Turn display on */
  lcd_write_command(dev, LCD_CMD_ONOFF | LCD_CMD_ENABLE_DISP);

  dev->esccount = -1;
  memset(dev->escape, 0, sizeof(dev->escape));

  dev->scrollpos = 0;
  dev->scrollmax = 0;
  dev->active = 0;

  dev->period = alt_ticks_per_second() / 10; /* Call every 100ms */

  alt_alarm_start(&dev->alarm, dev->period, &alt_lcd_16207_timeout, dev);

  /* make the device available to the system */
  alt_dev_reg(&dev->dev);
}
Esempio n. 6
0
static void IoInit(void)
{
   //uart0_init(115200);

   /* Init diskio interface */
   ffs_DiskIOInit();

   /* Init timer system */
   alt_alarm_start(&alarm, 1, &TimerFunction, NULL);

} /* IoInit */
Esempio n. 7
0
void prototype_os() {
	//thread initialized on creation..I want to bring back the initialize function
	ThreadControlBlock *newThread;
	initialize(mainThreadQueue);
	int i, j;
	for (i = 0; i < num_threads; i++) {
		// Here: do whatever you need
		// Here: call mythread_create so that the TCB for each thread is created
		//assembly calls
		newThread = mythread_create(i, 4096, mythread);
		// Here: call mythread_join to make each thread runnable/ready
		mythread_join(newThread);
	}
	// Here: initialize the timer and its interrupt handler as is done in Project I
	alt_alarm_start(&alarm, ALARMTICKS(x), mythread_handler, NULL);

	while (1) {
		alt_printf(
				"This is the OS prototype for my exciting CSE351 course projects!\n");
		for (j = 0; j < MAX; j++);
	}
}
Esempio n. 8
0
int main()
{ 
	int result;
	alt_alarm seven_seg_alarm;
	alt_alarm one_second_alarm;
	volatile alt_u32 seven_seg_context = 0;
	volatile alt_u32 one_second_context = 0;
	alt_u32 last_second_value = 0;
	char hex_string[9];
	alt_u32 one_second_update_active = 1;
	alt_u32 next_command;
	
	// start the seven segment alarm to paint the seven segment display
	result = alt_alarm_start (
					&seven_seg_alarm,			// alt_alarm* alarm,
					SEVEN_SEG_TIMOUT,			// alt_u32 nticks,
					&seven_seg_alarm_callback,	// alt_u32 (*callback) (void* context),
					(void*)&seven_seg_context	// void* context
				);

	if(result) {
		while(1);
	}

	// start the one second alarm
	result = alt_alarm_start (
					&one_second_alarm,			// alt_alarm* alarm,
					ONE_SECOND_TIMOUT,			// alt_u32 nticks,
					&one_second_alarm_callback,	// alt_u32 (*callback) (void* context),
					(void*)&one_second_context	// void* context
				);

	if(result) {
		while(1);
	}

	// initialize gfx display
	init_gfx_display();
	clear_gfx_buffer();
	copy_gfx_buffer_to_gfx_display();
	
	// initialize chr display
	init_chr_display();
	clear_chr_buffer();
	copy_chr_buffer_to_chr_display();
	
	// display some stuff
	chr_display_put_str("\nWind River Linux");
	chr_display_put_str("\n  for Nios II");
	
	// display some stuff
	gfx_display_put_str("\nID: 0x");
	convert_hex_word(hex_string, IORD_32DIRECT(SYSID_BASE, 0));
	gfx_display_put_str(hex_string);
	gfx_display_put_str("\nTS: 0x");
	convert_hex_word(hex_string, IORD_32DIRECT(SYSID_BASE, 4));
	gfx_display_put_str(hex_string);
	gfx_display_put_str(LINE_3_TXT);
	gfx_display_put_str(LINE_4_TXT);
	gfx_display_put_str(LINE_5_TXT);
			
	// start the seven segment display
	set_seven_seg_vector((alt_u32*)&seven_seg_context, 0x00F00000);
	
	// event loop never exits
	while(1) {
		// service the one second display on seven segments
		if(last_second_value != one_second_context) {
				last_second_value = one_second_context;
				if(one_second_update_active) {
					set_seven_seg_display((alt_u32*)&seven_seg_context, last_second_value, 0x0F, 0x00, 0x00);
			}
		}
		
		// monitor the fifo for display commands
		if(IORD_32DIRECT(DISPLAY_FIFO_IN_CSR_BASE, 0)) {
			next_command = IORD_32DIRECT(DISPLAY_FIFO_OUT_BASE, 0);
			switch((next_command & COMMAND_MASK) >> COMMAND_OFST) {
			case(COMMAND_7SEG):
				one_second_update_active = 0;
				set_seven_seg_vector((alt_u32*)&seven_seg_context, next_command & ~COMMAND_MASK);
				break;
			case(COMMAND_CHR):
				hex_string[0] = next_command & 0xFF;
				hex_string[1] = '\0';
				chr_display_put_str(hex_string);
				break;
			case(COMMAND_GFX):
				hex_string[0] = next_command & 0xFF;
				hex_string[1] = '\0';
				gfx_display_put_str(hex_string);
				break;
			case(COMMAND_NOP):
				if(next_command == 0x0A55A55A) {
					// initialize gfx display
					init_gfx_display();
					clear_gfx_buffer();
					copy_gfx_buffer_to_gfx_display();
					
					// initialize chr display
					init_chr_display();
					clear_chr_buffer();
					copy_chr_buffer_to_chr_display();
					
					// display some stuff
					chr_display_put_str("\nWind River Linux");
					chr_display_put_str("\n  for Nios II");
					
					// display some stuff
					gfx_display_put_str("\nID: 0x");
					convert_hex_word(hex_string, IORD_32DIRECT(SYSID_BASE, 0));
					gfx_display_put_str(hex_string);
					gfx_display_put_str("\nTS: 0x");
					convert_hex_word(hex_string, IORD_32DIRECT(SYSID_BASE, 4));
					gfx_display_put_str(hex_string);
					gfx_display_put_str(LINE_3_TXT);
					gfx_display_put_str(LINE_4_TXT);
					gfx_display_put_str(LINE_5_TXT);
							
					// start the seven segment display
					set_seven_seg_vector((alt_u32*)&seven_seg_context, 0x00F00000);
					
					one_second_update_active = 1;
				}
				break;
			default:
				break;
			}
		}
	}
Esempio n. 9
0
/*
 * Main Game Loop
 */
int main()
{
	// Use the name of your pixel buffer DMA core
	pixel_buffer =alt_up_pixel_buffer_dma_open_dev("/dev/pixel_buffer_dma_0");

	initVGA();
	usleep(5000000);
	ps2 = alt_up_ps2_open_dev("/dev/ps2_0");
	ps2->timeout = 2000000;
		alt_up_ps2_clear_fifo(ps2);
		alt_up_ps2_init(ps2);

		unsigned char byte1;
		while(alt_up_ps2_read_data_byte(ps2, &byte1)!=0);

	char_lcd_dev = alt_up_character_lcd_open_dev ("/dev/character_lcd_0");
	alt_up_character_lcd_init (char_lcd_dev);

	char_buffer  = alt_up_char_buffer_open_dev("/dev/char_drawer");
	alt_up_char_buffer_init(char_buffer);

	alt_up_sd_card_dev *device_reference = NULL;
	struct Env* p = initEnv();
	initGameInfo();

	struct Collidable* collisionChecker = initCollidable();
	addCollisionToEnv(p, collisionChecker);

	promptSDcard(p, device_reference);

	usleep(1000);
	alt_up_char_buffer_string(char_buffer, "Loading ", 40, 30);

	  unsigned end_time, start_time;
	  int count = 0; lock = 0;

	struct animation* starAnimation = loadSDImageSeq("ST0.BMP", 2, 8);
	struct animation* star2Animation = loadSDImageSeq("ST00.BMP", 3, 7);
	struct animation* alien0 = loadSDImageSeq("A100.BMP", 2, 2); //2 images where first 2 characters are prefix
	struct animation* alien1 = loadSDImageSeq("A000.BMP", 2, 15);
	struct animation* ship0 = loadSDImageSeq("S00.BMP", 2, 16);
	struct animation* ship1 = loadSDImageSeq("S10.BMP", 2, 27);
	struct animation* bossAnimate = loadSDImageSeq("BO00.BMP", 2, 28);
	struct animation* ship2 = loadSDImageSeq("S20.BMP", 2, 35);
	struct animation* ship3 = loadSDImageSeq("S30.BMP", 2, 30);
	struct animation* ship4 = loadSDImageSeq("S40.BMP", 2, 10);

	struct animation* explode1 = initAnimation((int*)explode01, 1);
	addImage(explode1, initAnimation((int*)explode02, 0));
	addImage(explode1, initAnimation((int*)explode03, 0));
	addImage(explode1, initAnimation((int*)explode04, 0));
	addImage(explode1, initAnimation((int*)explode05, 0));

	struct animation** shipAnimationCollection = (struct animation**)malloc(sizeof(struct animation*)*5);
	shipAnimationCollection[0] = ship0;
	shipAnimationCollection[1] = ship1;
	shipAnimationCollection[2] = ship2;
	shipAnimationCollection[3] = ship3;
	shipAnimationCollection[4] = ship4;

	initWeapon(collisionChecker, p);

	struct Cursor* mouse = initCursor(p, collisionChecker);
	addToEnv(p, mouse->super);
	addObjToCollide(collisionChecker, mouse->super);
	setCursor(p, mouse);

	struct KeyController* keyController = initKeyController();
	struct SwitchController* switchController = initSwitchController();
	struct CursorController* ctrl = initCursorController(mouse->super, switchController, keyController);

	alt_up_char_buffer_string(char_buffer, "Loading Sounds            ", 30, 30);
	audioController = initAudioController();
	loadSound( audioController, LOOP_ONE );
	loadSound( audioController, LASER_SOUND );
	alt_irq_register(AUDIO_IRQ, audioController, (void*) audio_ISR);
	alt_irq_enable(AUDIO_IRQ);
	play_background_loop( audioController, LOOP_ONE );
	enableAudioController( audioController );

	printhex(info.score);

	mainMenu(mouse, ctrl, p);

	disableAudioController(audioController);
	stop_background_loop(audioController);
	unloadSoundById(audioController, LASER_SOUND);
	unloadSoundById(audioController, LOOP_ONE);
	alt_up_char_buffer_string(char_buffer, "Loading Sounds           ", 30, 30);
	//loadSound(audioController, WIN_SOUND);
	//loadSound(audioController, LOSE_SOUND);
	loadSound( audioController, TOWER_UPGRADE_SOUND );
	loadSound( audioController, LOOP_TWO );
	play_background_loop(audioController, LOOP_TWO);
	enableAudioController( audioController );
	alt_up_char_buffer_clear(char_buffer);
	//usleep(1000);
	struct Alien* testAlienCollection[60];
	gameSetup(p, shipAnimationCollection, mouse, starAnimation, star2Animation);

	usleep(500000); //time delay for panel to be drawn
//
	char LPS[50]; float lps_;

	int n = 0;

	for(n = 0; n < 20; n++) {
		testAlienCollection[n] =initAlien(n, 10*n, 10, alien0, explode1, "IdontKnow", 1.4, 150, 500, collisionChecker);
		addToEnvNR(p, testAlienCollection[n]->super);
	}
	for(n = 0; n < 20; n++) {
		testAlienCollection[n+20] =initAlien(10*n, n, 10, alien1, explode1, "whatName", 1.4, 190, 850, collisionChecker);
		addToEnvNR(p, testAlienCollection[n+20]->super);
	}
	for(n = 0; n < 20; n++) {
		testAlienCollection[n+40] =initAlien(10*n, n, 20, bossAnimate, explode1, "IamBoss", 1.6, 800, 1500, collisionChecker);
		testAlienCollection[n+40]->score = 300;
		addToEnvNR(p, testAlienCollection[n+40]->super);
	}
	int stage = 0;
	/*
	 * Game Starts!!!!!!
	 */
	alt_alarm_start (&alarm,alt_ticks_per_second(),my_alarm_callback,(void*)p);

	int startTimer = 0;
	char second_row1[15];
	alt_up_character_lcd_set_cursor_pos(char_lcd_dev, 0, 1);
	  sprintf(second_row1, "wave# %d  ", stage);
	  alt_up_character_lcd_string(char_lcd_dev, second_row1);

  while(1) {
	  alt_timestamp_start();
	  start_time = (unsigned)alt_timestamp();

/*-----------------------------------------------------------------------------------------------*/

	  checkCollision(collisionChecker); //a major function that check each collision happen between each object

	  updateCursorController(ctrl, 1);

	  count++;

	  if (startTimer > count)
		  info.startButton = false;
	  else {
		  if(stage == 7)
			info.isWin = true;
		  else if(startTimer == count){
			//play_background_loop(audioController, LOOP_TWO);
			enableAudioController( audioController );
		  }
	  }
	  if (info.startButton){
			disableAudioController(audioController);
			//stop_background_loop(audioController);
		    startTimer = count + 15000;
	  		checkStages(testAlienCollection, stage%7, collisionChecker);
			stage++;
			//if(stage > 6) stage = 0;
			info.startButton = false;
		  	  alt_up_character_lcd_set_cursor_pos(char_lcd_dev, 0, 1);
		  	  sprintf(second_row1, "wave# %d  ", stage);
		  	  alt_up_character_lcd_string(char_lcd_dev, second_row1);
	  }

	  if(info.isEnd || info.isWin) {

			disableAudioController(audioController);
			stop_background_loop(audioController);
		  endGame(testAlienCollection, collisionChecker, p, mouse, ctrl, keyController);
	  }
/*-----------------------------------------------------------------------------------------------*/



	  end_time = (unsigned)alt_timestamp();
	  lps_ = (float)alt_timestamp_freq()/(float)(end_time - start_time);

	  sprintf(LPS, "The current LPS is %.2f", lps_);
	  alt_up_char_buffer_string(char_buffer, LPS, 3, 2);
  }
  return 0;
}
Esempio n. 10
0
/*
 * Starting point for SimpleFlightController
 */
int main(void) {

	printf("Starting Program\n");
	printf("initialize components...");
	DriverInit();

	INT8U err = OS_NO_ERR; //error variable for init errors

	/*
	 * create mutex and semaphores
	 */
	loggerQsem = OSQCreate((void*) &loggerQmessageTable, LOGGER_Q_SIZE); //create Message Queue for LOGGER

	sensorDataMutex = OSMutexCreate(SENSOR_DATA_MUTEX_PRIORITY, &err); // Used to synchronize Main task and SensorDataManager
	rcReceiverMutex = OSMutexCreate(RC_RECEIVER_MUTEX_PRIORITY, &err); // Used to synchronize Main task and RCTask

	mainTaskSem = OSSemCreate(0);		//used to make the MainTask periodic
	sensorDataManageTaskSem = OSSemCreate(0); //used to make the SensorDataMgr periodic
	rcTaskSem = OSSemCreate(0); 		//used to make the RcReciever periodic

	/*
	 * init state -> wait 2 seconds (alt_ticks_per_second() * 2) until every task starts
	 */
	alt_alarm_start(&periodicMainTaskAlarm, alt_ticks_per_second() * MAIN_TASK_DELAY,
			mainTasktimerCallback, NULL); // periodic timer for MainTask

	alt_alarm_start(&periodicRCReceiverTaskAlarm, alt_ticks_per_second() * RC_TASK_DELAY,
			RCReceiverTaskTasktimerCallback, NULL); // periodic timer for RCTask

	alt_alarm_start(&periodicSensorDataManagerTasktimerAlarm,
			alt_ticks_per_second() * SENSORDATA_TASK_DELAY, SensorDataManagerTasktimerCallback,
			NULL); // periodic timer for SensorDataManagerTask

	printf("Init done\n");

	/*
	 * create RCReceiver Task
	 */
	OSTaskCreateExt(RCReceiverTask,
	NULL, (void *) &RCReceiverTask_stk[TASK_STACKSIZE - 1],
	RC_TASK_PRIORITY,
	RC_TASK_PRIORITY, RCReceiverTask_stk,
	TASK_STACKSIZE,
	NULL, 0);

	/*
	 * create SensorDataManagerTask
	 * Task is in an external Task
	 * declared in SensorDataManager.h
	 */
	err = OSTaskCreateExt(SensorDataManagerTask,
	NULL, (void *) &SensorDataManagerTask_stk[TASK_STACKSIZE - 1],
	SDM_TASK_PRIORITY,
	SDM_TASK_PRIORITY, SensorDataManagerTask_stk,
	TASK_STACKSIZE,
	NULL, 0);

	/*
	 * create LoggerTask
	 */
	err = OSTaskCreateExt(LoggerTask,
	NULL, (void *) &LoggerTask_stk[TASK_STACKSIZE - 1],
	LOGGER_TASK_PRIORITY,
	LOGGER_TASK_PRIORITY, LoggerTask_stk,
	TASK_STACKSIZE,
	NULL, 0);

	/*
	 * create MainTask
	 */
	err = OSTaskCreateExt(MainTask,
	NULL, (void *) &MainTask_stk[TASK_STACKSIZE - 1],
	MAIN_TASK_PRIORITY,
	MAIN_TASK_PRIORITY, MainTask_stk,
	TASK_STACKSIZE,
	NULL, 0);

	OSStart();
	return 0;

}
void StartTask(void* pdata)
{
  INT8U err;
  void* context;
   

  static alt_alarm alarm;     /* Is needed for timer ISR function */
  
  /* Base resolution for SW timer : HW_TIMER_PERIOD ms */
  //delay = alt_ticks_per_second() * HW_TIMER_PERIOD / 1000; 
 // printf("delay in ticks %d\n", delay);

  /* 
   * Create Hardware Timer with a period of 'delay' 
   */
  if (alt_alarm_start (&alarm,
      delay,
      alarm_handler,
      context) < 0)
      {
          printf("No system clock available!n");
      }

  /* 
   * Create and start Software Timer 
   */

  /*
   * Creation of Kernel Objects
   */
  
  // Mailboxes
  Mbox_Throttle = OSMboxCreate((void*) 0); /* Empty Mailbox - Throttle */
  Mbox_Velocity = OSMboxCreate((void*) 0); /* Empty Mailbox - Velocity */
   
  /*
   * Create statistics task
   */

  OSStatInit();

  /* 
   * Creating Tasks in the system 
   */


  err = OSTaskCreateExt(
       ControlTask, // Pointer to task code
       NULL,        // Pointer to argument that is
                    // passed to task
       &ControlTask_Stack[ControlTask_STACKSIZE-1], // Pointer to top
                             // of task stack
       CONTROLTASK_PRIO,
       CONTROLTASK_PRIO,
       (void *)&ControlTask_Stack[0],
       ControlTask_STACKSIZE,
       (void *) 0,
       OS_TASK_OPT_STK_CHK);

  err = OSTaskCreateExt(
       VehicleTask, // Pointer to task code
       NULL,        // Pointer to argument that is
                    // passed to task
       &VehicleTask_Stack[VehicleTask_STACKSIZE-1], // Pointer to top
                             // of task stack
       VEHICLETASK_PRIO,
       VEHICLETASK_PRIO,
       (void *)&VehicleTask_Stack[0],
       VehicleTask_STACKSIZE,
       (void *) 0,
       OS_TASK_OPT_STK_CHK);
       
    err = OSTaskCreateExt(
       ButtonIO, // Pointer to task code
       NULL,        // Pointer to argument that is
                    // passed to task
       &ButtonIO_Stack[ButtonIO_STACKSIZE-1], // Pointer to top
                             // of task stack
       ButtonIO_PRIO,
       ButtonIO_PRIO,
       (void *)&ButtonIO_Stack[0],
       ButtonIO_STACKSIZE,
       (void *) 0,
       OS_TASK_OPT_STK_CHK);
  
   err = OSTaskCreateExt(
        SwitchIO, // Pointer to task code
       NULL,        // Pointer to argument that is
                    // passed to task
       &SwitchIO_Stack[SwitchIO_STACKSIZE-1], // Pointer to top
                             // of task stack
       SwitchIO_PRIO,
       SwitchIO_PRIO,
       (void *)&SwitchIO_Stack[0],
       SwitchIO_STACKSIZE,
       (void *) 0,
       OS_TASK_OPT_STK_CHK);
       
   err = OSTaskCreateExt(
        WatchDog, // Pointer to task code
       NULL,        // Pointer to argument that is
                    // passed to task
       &WatchDog_Stack[WatchDog_STACKSIZE-1], // Pointer to top
                             // of task stack
       WatchDog_PRIO,
       WatchDog_PRIO,
       (void *)&WatchDog_Stack[0],
       WatchDog_STACKSIZE,
       (void *) 0,
       OS_TASK_OPT_STK_CHK);
       
    err = OSTaskCreateExt(
        OLD, // Pointer to task code
       NULL,        // Pointer to argument that is
                    // passed to task
       &OLD_Stack[OLD_STACKSIZE-1], // Pointer to top
                             // of task stack
       OLD_PRIO,
       OLD_PRIO,
       (void *)&OLD_Stack[0],
       OLD_STACKSIZE,
       (void *) 0,
       OS_TASK_OPT_STK_CHK);
      
     err = OSTaskCreateExt(
        DYNAMIC_UTI, // Pointer to task code
       NULL,        // Pointer to argument that is
                    // passed to task
       &DYNAMIC_UTI_Stack[DYNAMIC_UTI_STACKSIZE-1], // Pointer to top
                             // of task stack
       DYNAMIC_UTI_PRIO,
       DYNAMIC_UTI_PRIO,
       (void *)&DYNAMIC_UTI_Stack[0],
       DYNAMIC_UTI_STACKSIZE,
       (void *) 0,
       OS_TASK_OPT_STK_CHK);
       
  printf("All Tasks and Kernel Objects generated!\n");
  

  /* Task deletes itself */

  OSTaskDel(OS_PRIO_SELF);
}