Exemple #1
0
int main(void)
{
    initialize_hardware();

    while (1) 
    {
        terminal_idle();  // obsluha terminalu
    }
}
/**
 * \brief Application entry point.
 *
 * \return Unused (ANSI-C compatibility).
 */
int main( void )
{
  // Initialize hardware
  initialize_hardware() ;

  while ( 1 )
  {
  }
}
Exemple #3
0
/** Main program entry point. This routine contains the overall program flow, including initial
 *  setup of all components and the main program loop.
 */
int main(void)
{
  GlobalInterruptEnable();

  initialize_hardware();

  while (true) {
    matrix_scan();
    HID_Device_USBTask(&Keyboard_HID_Interface);
    USB_USBTask();
  }
}
Exemple #4
0
/*******************************************************************************
 * Hlavni funkce
*******************************************************************************/
int main(void)
{
  unsigned int cnt = 0;
  last_ch = 0;
  last_opto = 0;
  isrunning = 0;

  OPTO_dir_in();
  initialize_hardware();
  keyboard_init();

  set_led_d6(1);                       // rozsviceni D6
  set_led_d5(1);                       // rozsviceni D5

  //term_send_crlf();
  //term_send_str(" >");

  /* nastaveni casovace na periodu 10 ms */
  CCTL0 = CCIE;  // enable interrupt               
  CCR0 = 0x80;
  TACTL = TASSEL_1 + MC_2;

  stopwatch_reset();

  while (1)
  {
    delay_ms(1);

    cnt++;
    if (cnt >= 500)
        cnt = 0;

    if (cnt == 0)
    {
      cnt = 0;
      flip_led_d6();                   // negace portu na ktere je LED
    }

    if (cnt % 10 == 1) {
        keyboard_idle();                   // obsluha klavesnice
        terminal_idle();                   // obsluha terminalu
    }
    if (cnt % 100 == 2) {
        display_idle();
    }

    opto_idle();
  }         

  //CCTL0 &= ~CCIE;  // disable interrupt

}
int main(void)
{
	load_settings_from_eeprom();
	initialize_hardware();
   
    while(1)
    {
		//a button was pressed
        if(button_pressed){	
			if(button_pressed == 1){	//up
				if(eeprom_settings[CURRENT_SETTING] < 19) eeprom_settings[CURRENT_SETTING]++;
			} else {					//down
				if(eeprom_settings[CURRENT_SETTING] > 0) eeprom_settings[CURRENT_SETTING]--;
			}
			
			
			//and modify the corresponding phys_setting
			if(CURRENT_SETTING < 2){
				phys_settings[CURRENT_SETTING] = tach_lut[eeprom_settings[CURRENT_SETTING]];
			} else {
				phys_settings[CURRENT_SETTING] = eeprom_settings[CURRENT_SETTING] * 2;
			}
			
			button_pressed = 0;	//release flag so we can service another button press
		}
		
		//when we're not servicing button presses, we're measuring the PWM signal. 
		//this is a very fast signal, so we don't want to use interrupts for this
		//hence we're doing this in the main loop so we can be easily interrupted by more
		//important stuff.
		
		//wait for a leading edge
		temp = 50;
		while(!(PINB & PWM_IN_PIN) && temp){temp++;}	//we include a counter to allow this loop to exit after a short timeout
		temp = 50;	//reset temp
		TCNT0 = 0;	//start the timer
		while(PINB & PWM_IN_PIN && temp){temp++;}
		pwm_duty_m = TCNT0;
			
		//at this time we either have some TCNT value between 0-40(ish) representing the duty cycle of the PWM signal
		//or we have a value of temp=0 because we had a timeout
		if(temp){	//non-timeout
			if(pwm_duty_m < phys_settings[3] && pwm_duty_m > phys_settings[2]){
				OCR1A = pwm_duty_m;				
			}
		}
    }
}
/*******************************************************************************
 * Hlavni funkce
*******************************************************************************/
int main(void)
{
   short counter = 0;
   unsigned long  a, b, c;

   initialize_hardware();
   set_led_d6(1);  //rozsvitit LED D6
   set_led_d5(1);  //rozsvitit LED D5

   /**************************************************************************/
   /*                      Aktualizovany hlavni program                      */
   /**************************************************************************/
   a = 0x12345678;
   b = 0x50000000;
   fpga_write(FPGA_ADDR_A, a);
   fpga_write(FPGA_ADDR_B, b);
   c = fpga_read(FPGA_ADDR_C);

   term_send_hex(a); 
   term_send_str(" + "); 
   term_send_hex(b); 
   term_send_str(" = "); 
   term_send_hex(c); 
   term_send_crlf();

   /**************************************************************************/

   set_led_d5(0);  //zhasnout LED D5

   while (1) {
      delay_ms(1);  //zpozdeni 1ms

      counter++;
      if (counter == 500) {
         flip_led_d6(); //invertovat LED
         counter = 0;
      }

      terminal_idle();  // obsluha terminalu
   }
}
int main(void)
{
  initialize_hardware();
  WDTCTL = WDTPW + WDTHOLD;	 // zastav watchdog
  
  adcInit(); // inicializace AD prevodniku
  
  unsigned char i = 0;
  while(1){
    i++;
    if(i >= interval){
      i = 0;
      flip_led_d6();
      if(!paused){
        voltmeterRefresh();
        voltmeterRedraw();
      }
    }
    terminal_idle();
    delay_ms(1);
  }
}
Exemple #8
0
static int simple_remote_probe(struct platform_device *pdev)
{
	int ret = 0;
	int size;
	void *v;
	struct simple_remote_driver *jack;

	dev_info(&pdev->dev, "**** Registering (headset) driver\n");

	jack = kzalloc(sizeof(struct simple_remote_driver), GFP_KERNEL);

	if (!jack)
		return -ENOMEM;

	mutex_init(&jack->simple_remote_mutex);

	if (!pdev->dev.platform_data)
		goto err_switch_dev_register;


	size = sizeof(*jack->interface) / sizeof(void *);
	v = (void *)pdev->dev.platform_data;

	for (; size > 0; size--)
		if (v++ == NULL)
			goto err_switch_dev_register;

	jack->interface = pdev->dev.platform_data;
	jack->dev = &pdev->dev;

	jack->plug_det_timer.function = simple_remote_plug_detect_tmr_func;
	jack->plug_det_timer.data = (unsigned long)jack;

	init_timer(&jack->plug_det_timer);

	/* Set flags */
	jack->current_accessory_state = NO_DEVICE;
	jack->pressed_button = 0xFF;

	/* Initialize work queue for Simple Remote Driver */
	INIT_WORK(&jack->plug_det_work,
			  simple_remote_plug_det_work);
	INIT_WORK(&jack->btn_det_work,
		  simple_remote_btn_det_work);

	/* device name */
	jack->swdev.name = "h2w";

	/* print function name */
	jack->swdev.print_name = simple_remote_print_name;

	ret = switch_dev_register(&jack->swdev);
	if (ret < 0) {
		dev_err(jack->dev, "switch_dev_register failed\n");
		goto err_switch_dev_register;
	}

	ret = create_sysfs_interfaces(&pdev->dev);
	if (ret) {
		dev_err(jack->dev,
			"create_sysfs_interfaces for input failed\n");
		goto err_switch_dev_register;
	}

	if (initialize_hardware(jack))
		dev_err(jack->dev, "Failed to set default values in HW "
			"components.");

	/* Create input device for normal key events. */
	jack->indev = input_allocate_device();
	if (!jack->indev) {
		ret = -ENOMEM;
		dev_err(jack->dev, "Failed to allocate input device\n");
		goto err_allocate_input_dev;
	}

	jack->indev->name = SIMPLE_REMOTE_NAME;
	jack->indev->evbit[0] = BIT_MASK(EV_KEY);
	jack->indev->keybit[BIT_WORD(KEY_MEDIA)] |= BIT_MASK(KEY_MEDIA);
	jack->indev->keybit[BIT_WORD(BTN_MISC)] |= BIT_MASK(BTN_0) |
		BIT_MASK(BTN_1) | BIT_MASK(BTN_2);

	jack->indev->open = simple_remote_open;
	jack->indev->close = simple_remote_close;

	input_set_drvdata(jack->indev, jack);
	platform_set_drvdata(pdev, jack);

	ret = input_register_device(jack->indev);
	if (ret) {
		dev_err(jack->dev, "input_register_device for input device "
			"failed\n");
		input_free_device(jack->indev);
		goto err_register_input_dev;
	}

	/* Create input device for application key events. */
	jack->indev_appkey = input_allocate_device();
	if (!jack->indev_appkey) {
		ret = -ENOMEM;
		dev_err(jack->dev, "Failed to allocate application key input "
			"device\n");
		goto err_allocate_input_appkey_dev;
	}

	jack->indev_appkey->name = SIMPLE_REMOTE_APPKEY_NAME;
	jack->indev_appkey->evbit[0] = BIT_MASK(EV_KEY);
	jack->indev_appkey->keybit[BIT_WORD(BTN_MISC)] |=
		BIT_MASK(SIMPLE_REMOTE_APPKEY);
	jack->indev_appkey->open = simple_remote_open;
	jack->indev_appkey->close = simple_remote_close;

	input_set_drvdata(jack->indev_appkey, jack);

	ret = input_register_device(jack->indev_appkey);
	if (ret) {
		dev_err(jack->dev, "input_register_device for application key "
				"input device failed\n");
		goto err_register_input_appkey_dev;
	}

	dev_info(jack->dev, "***** Successfully registered\n");

	atomic_set(&jack->initialized, 1);

	return ret;

err_register_input_appkey_dev:
	input_free_device(jack->indev_appkey);
err_allocate_input_appkey_dev:
	input_unregister_device(jack->indev);
err_register_input_dev:
err_allocate_input_dev:
err_switch_dev_register:
	dev_err(&pdev->dev, "***** Failed to initialize\n");
	kzfree(jack);

	return ret;
}
Exemple #9
0
//hlavni funkce starajici se o chod aplikace
int main(int argc, char **argv )
{
	unsigned int cnt = 0,old_score=1;
	char_cnt = 0;
	last_ch = 0;
	//iniciaizace HW
	initialize_hardware();
	keyboard_init();
	
	int random_number,i,j;
	Tshape myshape;
	Tmatrix matrix,pane,pom;
	int pom_matrix[8][8] = {0};
	char c=0;
	int latest_line;

	//srand(2);
	//vytvoreni noveho utvaru
	myshape = create_shape(rand()%8);
	//posun na zacatek
	matrix = move_it(myshape,pom_matrix);
	//ulozeni noveho utvaru
	pane = save_it(matrix,pom_matrix);


	set_led_d6(1);                       // rozsviceni D6
	set_led_d5(1);                       // rozsviceni D5

	//inicializace LED displeje
	P6DIR=0xff;
	P4DIR=0x0f;
	P2DIR=0xf0;
	P4OUT=0x00;
	P2OUT=0x00;
	P6OUT=0xff;
	while (1)
	{
		delay_ms(1);
		cnt++;
		//pri zmacknuti klavesy
		if (c!=last_ch){
			c=last_ch;
			//pokud byla zmacknuta 6
			if (c=='6'){
				//posunu se
				x++;
				//pokusim se ulozit na to misto utvar
				matrix = move_it(myshape,pom_matrix);
				//pokud nelze ulozit	
				if (matrix.count!=4){
					//vratim se
					x--;
					//a ulozim
					matrix = move_it(myshape,pom_matrix);				
				}
			}
			//pri zmacknuti 4  
			else if (c=='4'){
				//posunu se
				x--;
				//pokusim se ulozit
				matrix = move_it(myshape,pom_matrix);
				//pokud bych vypsal mene jak 4 znaky z utvaru
				if (matrix.count!=4){
					//posouvam se zpatky
					x++;
					matrix = move_it(myshape,pom_matrix);
				}
			}
			//pokud nactu 8
			else if (c=='8'){
				//posunu se
				y++;
				//pokusim se ulozit
				matrix = move_it(myshape,pom_matrix);
				if (matrix.count!=4){
					//pokud nelze posun, posunu se nazpet
					y--;
					matrix = move_it(myshape,pom_matrix);
					matrix.last_line = 1;
				}			
			}
			//rotace
			else if (c=='5'){
				//pouzivam prvne rotate_back kvuli "hezci" rotaci
				myshape = rotate_back(myshape);
				//pokusim se ulozit dany utvar
				matrix = move_it(myshape,pom_matrix);
				//pokud pri posunu nelze vypsat vsechny 4 prvky daneho utvaru
				if (matrix.count!=4){
					//posunu se zpatky
					myshape = rotate(myshape);
					matrix = move_it(myshape,pom_matrix);
				}		
			}
			else
			{
				continue;
			}
			//ulozim do vysledneho hraciho pole
			pane = save_it(matrix,pom_matrix);
			//pokud jsem nacetl posledni radek
			if (matrix.last_line==1)
			{
				//ulozim si hraci pole do pomocne matice
				for (i=0;i<8;i++)
				{
					for (j=0;j<8;j++)
					{
						pom_matrix[i][j] = pane.shape[i][j];
					}
				}
				matrix.last_line=0;
				//smazu radky
				pane=delete_rows(pane);

				x=0;
				y=0;
				//vygeneruji novy utvar
				myshape = create_shape(rand()%8);
				int i,t;
				//ulozim do pomocne matice hraci pole
				for (i=0;i<8;i++)
					for (t=0;t<8;t++)
						pom_matrix[i][t]=pane.shape[i][t];
				//posunu nove vygenerovany utvar na zacatek hraciho pole
				matrix = move_it(myshape,pom_matrix);
				//ulozim tento stav
				pane = save_it(matrix,pom_matrix);
				
			}
			c=last_ch;
		}
		//tisknuti skore
		if (old_score!=score && (cnt%100)==0){
			old_score=score;
			print_score("Score: ");
		}
		
		if (cnt > 1000)
		{
			cnt = 0;
			flip_led_d6();                   // negace portu na ktere je LED
		}
		
		print_it(pane.shape);
		keyboard_idle();                   // obsluha klavesnice
		terminal_idle();                   // obsluha terminalu
  } 
	
	return 0;
}
void main(void)
{
#define SWITCHES *(unsigned char volatile *)(0xB580)
#define PORTA *(unsigned char volatile *)(0x1000)
#define TCTL1 *(unsigned char volatile *)(0x1020)
#define DDRD *(unsigned char volatile *)(0x1009)
#define SPCR *(unsigned char volatile *)(0x1028)
#define TCTL2 *(unsigned char volatile *)(0x1021)
#define TMSK2 *(unsigned char volatile *)(0x1024)
#define TIC1 *(unsigned int volatile *)(0x1010)



#define OPTION *(unsigned char volatile *)(0x1039)
#define ADCTL *(unsigned char volatile *)(0x1030)
#define ADR1 *(unsigned char volatile *)(0x1031)
#define ADR2 *(unsigned char volatile *)(0x1032)
#define ADR3 *(unsigned char volatile *)(0x1033)
#define ADR4 *(unsigned char volatile *)(0x1034)
#define TOC2 *(unsigned int volatile *)(0x1018)
#define TCNT *(unsigned int volatile *)(0x100E)
#define TFLG1 *(unsigned char volatile *)(0x1023)
INT16U v1,v2,average,ontime,period,duty,freq;
INT8U voltage, disphigh, displow;
	initialize_hardware();
	display_titles();
	while(1)
	{
		get_voltage_from_sample(&v1, &v2, &average);
		v1 = 2.2*v1;
		v2 = 2.2*v2;
		average = 2*average;
		
		//display average
		dsp(2,3,15);
		dsp(0,((average / 100) %10) + 0x30,0);
		dsp(2,3,17);
		dsp(0,((average / 10) %10) + 0x30,0);
		dsp(0,((average / 1) %10) + 0x30,0);
		
		//display hight voltage
		dsp(2,2,3);
		dsp(0,((v1 / 100) %10) + 0x30,0);
		dsp(2,2,5);
		dsp(0,((v1 / 10) %10) + 0x30,0);
		dsp(0,((v1 / 1) %10) + 0x30,0);
		
		//display low voltage
		dsp(2,3,3);
		dsp(0,((v2 / 100) %10) + 0x30,0);
		dsp(2,3,5);
		dsp(0,((v2 / 10) %10) + 0x30,0);
		dsp(0,((v2 / 1) %10) + 0x30,0);
	
		if(v1 > 350)
		{
			period = measure_period();
			ontime = measure_ontime();
			
			//display duty cycle
			duty = (ontime*10)/(period/10);
			dsp(2,2,15);
			dsp(0,((duty / 100) %10) + 0x30,0);
			dsp(0,((duty / 10) %10) + 0x30,0);
			dsp(0,((duty / 1) %10) + 0x30,0);
			
			period /= 20;
			ontime /= 20;
			
			//display frequency
			freq = 100000/period;
			dsp(2,1,10);
			dsp(0,((freq / 1000) %10) + 0x30,0);
			dsp(0,((freq / 100) %10) + 0x30,0);
			dsp(0,((freq / 10) %10) + 0x30,0);
			dsp(0,((freq / 1) %10) + 0x30,0);
		}
	}
}
int main() {

	//Print status message
	printf("Program Started...\n");
//===================================================================================================
//                              		INITIALIZE HARDWARE
//===================================================================================================

	initialize_hardware();

//	//Print Background
//	int i,j;
//	for (i=0; i<240; i++){
//		for (j=0; j<320; j++){
//			alt_up_pixel_buffer_dma_draw(pixel_buffer, world[i][j], j, i);
//		}
//	}

	//Draws the rectangle for the Game Grid (150 by 150)
	alt_up_pixel_buffer_dma_draw_rectangle(pixel_buffer, 149, 44, 300, 195, 0x3333, 0);

	alt_up_char_buffer_clear(char_buffer);
	alt_up_char_buffer_init(char_buffer);


//===================================================================================================
//===================================================================================================



//===================================================================================================
//                               Game Grid and other initialization
//===================================================================================================

	int GameGrid[GRID_WIDTH][GRID_HEIGHT] = {0};
	int UserHasQuit = 0;
	int GameStatus = 0;

	//===========================================================
	//Create Player 1 struct and initialize positions
	struct Player Player1;
	Player1.CurrentPositionX = 37;
	Player1.CurrentPositionY = 75;

	Player1.PreviousPositionX = 37;
	Player1.PreviousPositionY = 75;

	Player1.DirectionX = 1;
	Player1.DirectionY = 0;


	//===========================================================
	//Create Player 2 struct and initialize positions
	struct Player Player2;
	Player2.CurrentPositionX = 113;
	Player2.CurrentPositionY = 75;

	Player2.PreviousPositionX = 113;
	Player2.PreviousPositionY = 75;

	Player2.DirectionX = -1;
	Player2.DirectionY = 0;


	//===========================================================
	//  Sets the starting position as being filled
	GameGrid[Player1.CurrentPositionX][Player1.CurrentPositionY] = 1;
	GameGrid[Player2.CurrentPositionX][Player2.CurrentPositionY] = 1;

//===================================================================================================
//===================================================================================================



//===================================================================================================
//                               Controls
//===================================================================================================

	alt_up_char_buffer_string(char_buffer, "Press Enter to Start!", 4, 40);
	alt_up_char_buffer_string(char_buffer, "Press 'P' to Pause", 4, 42);

	alt_up_char_buffer_string(char_buffer, "Player 1: RED", 4, 46);
	alt_up_char_buffer_string(char_buffer, "W- Up", 8, 47);
	alt_up_char_buffer_string(char_buffer, "S- Down", 8, 48);
	alt_up_char_buffer_string(char_buffer, "A- Left", 8, 49);
	alt_up_char_buffer_string(char_buffer, "D- Right", 8, 50);


	alt_up_char_buffer_string(char_buffer, "Player 2: BLUE", 4, 53);
	alt_up_char_buffer_string(char_buffer, "Arrow Up- Up", 8, 54);
	alt_up_char_buffer_string(char_buffer, "Arrow Down - Down", 8, 55);
	alt_up_char_buffer_string(char_buffer, "Arrow Left- Left", 8, 56);
	alt_up_char_buffer_string(char_buffer, "Arrow Right- Right", 8, 57);


//===================================================================================================
//									START GAME
//===================================================================================================

	while(UserHasQuit != 1){


	// Function to read when user has pressed entered to start the game
	/*
	if( UserHasPressedEnter )
		GameStatus = 1;
	*/
	// This is the beginning of the game
		while( GameStatus != 1) {

			//Starts the timer to read keyboard inputs until we update the player positions and collisions
			UpdatePlayerMovement(&Player1, &Player2);

			//Updating the collision detection, movement, and screen
			//UpdateGame(&Player1, &Player2, &GameGrid, GameStatus, pixel_buffer);


		}


	}
	return 0;
}
int main( int argc, char* argv[] ) {	
	//test_system_idle_instrumented();
	//bwprintf(COM2, "Starting Kernel!");
	
	//bwsetfifo(COM2,OFF);
	
	//create the globals structure
	struct kern_globals GLOBAL;
	struct request* req;

	//2385260
	//0x2E56C

	/*
	bwprintf(COM2, "TID[%d]\tPC[%d]\tPRIOR[%d]\n\n", GLOBAL.ACTIVE_TASK->task_id, GLOBAL.ACTIVE_TASK->pc, GLOBAL.ACTIVE_TASK->priority);
	bwprintf(COM2, "REQ_NUM[%d]\n", GLOBAL.ACTIVE_TASK->req->req_num);
	bwprintf(COM2, "SND_TID[%d]\n", ((struct request_send*)GLOBAL.ACTIVE_TASK->req)->Tid);
	bwprintf(COM2, "\tSND_STATE[%d]\n", GLOBAL.USER_TDS[((struct request_send*)GLOBAL.ACTIVE_TASK->req)->Tid].td_state);
	bwprintf(COM2, "\tSND_PRIOR[%d]\n", GLOBAL.USER_TDS[((struct request_send*)GLOBAL.ACTIVE_TASK->req)->Tid].priority);
	bwprintf(COM2, "\tSND_PC[%x]\n", GLOBAL.USER_TDS[((struct request_send*)GLOBAL.ACTIVE_TASK->req)->Tid].pc);
	bwprintf(COM2, "\tSND_REQ_NUM[%d]\n", GLOBAL.USER_TDS[((struct request_send*)GLOBAL.ACTIVE_TASK->req)->Tid].req->req_num);
	bwprintf(COM2, "\t\tSND_REQ_MSG[%x]\n", ((struct request_receive*)GLOBAL.USER_TDS[((struct request_send*)GLOBAL.ACTIVE_TASK->req)->Tid].req)->msg);
	bwprintf(COM2, "\t\tSND_REQ_MSG_LEN[%d]\n", ((struct request_receive*)GLOBAL.USER_TDS[((struct request_send*)GLOBAL.ACTIVE_TASK->req)->Tid].req)->msglen);
	bwprintf(COM2, "\t\tSND_REQ_NUM[%d]\n", ((struct request_receive*)GLOBAL.USER_TDS[((struct request_send*)GLOBAL.ACTIVE_TASK->req)->Tid].req)->req_num);
	bwprintf(COM2, "\t\tSND_REQ_TID_POINTER[%x]\n", ((struct request_receive*)GLOBAL.USER_TDS[((struct request_send*)GLOBAL.ACTIVE_TASK->req)->Tid].req)->tid);


	bwprintf(COM2, "ROUTE_SRV_TID[45]\n", GLOBAL.USER_TDS[((struct request_send*)GLOBAL.ACTIVE_TASK->req)->Tid].req->req_num);
	bwprintf(COM2, "\tROUTE_SRV_STACK_BOTTOM[%x]\n", GLOBAL.USER_TDS[45].stack_space_bottom);
	bwprintf(COM2, "\tROUTE_SRV_STACK_TOP[%x]\n", GLOBAL.USER_TDS[45].stack_space_top);
	bwprintf(COM2, "\tROUTE_SRV_STACK_POINTER[%x]\n", GLOBAL.USER_TDS[45].sp);
	//bwprintf(COM2, "\tROUTE_SRV_ROUTE_STRUCT_SIZE[%x]\n");

	bwprintf(COM2, "MSG_POINTER[%x]\n", ((struct request_send*)GLOBAL.ACTIVE_TASK->req)->msg);
	bwprintf(COM2, "\tMSG[0] = [%d]\n", ((int*)((struct request_send*)GLOBAL.ACTIVE_TASK->req)->msg)[0]);
	bwprintf(COM2, "\tMSG[1] = [%d]\n", ((int*)((struct request_send*)GLOBAL.ACTIVE_TASK->req)->msg)[1]);
	bwprintf(COM2, "\tMSG_LEN[%d]\n", ((struct request_send*)GLOBAL.ACTIVE_TASK->req)->msglen);

	bwprintf(COM2, "RPL_POINTER[%d]\n", ((struct request_send*)GLOBAL.ACTIVE_TASK->req)->reply);
	bwprintf(COM2, "\tRPL_LEN[%d]\n", ((struct request_send*)GLOBAL.ACTIVE_TASK->req)->replylen);
	bwgetc(COM2);
	 */

	//loop through all of the tds and find the task id with the greatest
	//number of blocked tasks on it, along with its task id
	/*
	int tdindex = 0;
	int block_max = 0;
	int i = 0;
	for(i = 0; i < TID_INDEX_MASK + 1; i++){
		int sqs = GLOBAL.USER_TDS[i].send_Q_size;
		if(sqs > block_max){
			block_max = sqs;
			tdindex = i;
		}
	}*/

	//bwprintf(COM2, "\n\nBLK[%d] TD_IND[%d] TID[%d] PRIOR[%d]\n\n", block_max, tdindex, GLOBAL.USER_TDS[tdindex].task_id, GLOBAL.USER_TDS[tdindex].priority);
	//bwgetc(COM2);
	
	initialize_globals(&GLOBAL);
	initialize_first_task(&GLOBAL);
	
	initialize_hardware();
	
	while(1){
		req = NULL;
		if(GLOBAL.SCHEDULER.highest_priority == -1){ return 0; } //NO TASKS
		GLOBAL.ACTIVE_TASK = schedule(&GLOBAL);
		req = kerexit(GLOBAL.ACTIVE_TASK);
		//check for quit
		if(req->req_num == SYSCALL_QUIT){ return 0; }
		kernel_assert(req != NULL, "req != NULL")
		handle_request(&GLOBAL, req);
	}
	
	bwprintf(COM2, "GoodBye World\n\n");
	
	cleanup_hardware();
	return 0;

}