Ejemplo n.º 1
0
void led(int mode)
{
	static int toggle;
	static unsigned long led_delay;

	#GLOBAL_INIT{toggle = 0;}

	if(mode == RESET_LED)
	{
		led_delay = MS_TIMER+LED_DELAY;
	  	ledOut(0, 1);
	}
	else if((long) (MS_TIMER - led_delay) >= 0 )
	{
		//update led
		if(toggle)
		{	// turn led OFF
			ledOut(0, 1);
			toggle = 0;
		}
		else
		{	// turn led ON
			ledOut(0, 0);
			toggle = 1;
		}
		// set the interval for the next led update
		led_delay = MS_TIMER+LED_DELAY;
	}
}
Ejemplo n.º 2
0
main()
{

	brdInit();  //must do to initialize board

	for(;;)
	{
		ledOut(DS3, ON);
      msDelay(100);
		ledOut(DS3, OFF);
      msDelay(50);

		ledOut(DS4, ON);
      msDelay(100);
		ledOut(DS4, OFF);
      msDelay(50);

		ledOut(DS5, ON);
      msDelay(100);
		ledOut(DS5, OFF);
      msDelay(50);

		ledOut(DS6, ON);
      msDelay(100);
		ledOut(DS6, OFF);
      msDelay(50);

		ledOut(USERLED, ON);
      msDelay(100);
		ledOut(USERLED, OFF);
      msDelay(50);
	}
}
Ejemplo n.º 3
0
void update_leds()
{
   auto char *ptr[4];
   auto int i;

   ptr[0] = led_LED0;
   ptr[1] = led_LED1;
   ptr[2] = led_LED2;
   ptr[3] = led_LED3;
 
   for(i=0; i< (sizeof(ptr)/2); i++)
   {
		TextGotoXY(&wholewindow,0,i);
      if (strcmp(ptr[i],"ledon.gif") == 0)
      {
      	ledOut(i, 1);
			TextPrintf(&wholewindow, "LED %d on ", i);
      }
      else
      {
      	ledOut(i, 0);
			TextPrintf(&wholewindow, "LED %d off", i);
      }
   }
}
Ejemplo n.º 4
0
/*
 * Check the status of switch 2
 */
cofunc void CheckSwitch2()
{
	if (switchIn(S3))									// wait for switch press
		abort;											// if button not down skip out
	waitfor(DelayMs(50));							// wait 50 ms
	if (switchIn(S3))									// wait for switch press
		abort;											// if button not still down exit

	ledOut(DS4, ON);									// led on
	SendMail(1);										// send email since button was down 50 ms
	ledOut(DS4, OFF);									// led off

	while (1)
	{
		waitfor(switchIn(S3));							// wait for button to go up
		waitfor(DelayMs(200));						// wait additional 200 ms
		if (switchIn(S3))	  							// wait for switch press
			break;										// if button still up break out of while loop
	}
}
Ejemplo n.º 5
0
void main()
{
   // initialize the controller
   brdInit();
   sock_init();
   http_init();
   tcp_reserveport(80);

   // set the initial state of the LED's 
   strcpy(led_DS4,"ledon.gif");  ledOut(DS4, ON);
   strcpy(led_DS5,"ledon.gif");  ledOut(DS5, ON);
   strcpy(led_DS6,"ledoff.gif"); ledOut(DS6, OFF);
   strcpy(led_DS7,"ledon.gif");  ledOut(DS7, ON);
   strcpy(led_DS8,"ledon.gif");  ledOut(DS8, ON);

   // process WEB page requests and update the LED's
   while (1) {
      update_leds();
      http_handler();
   }
}
Ejemplo n.º 6
0
main()
{
   // initialize the controller
   initsystem();

   sock_init();
   http_init();
   tcp_reserveport(80);

   // set the initial state of the LED's 
   strcpy(led_LED0,"ledon.gif");  ledOut(LED0, ON);
   strcpy(led_LED1,"ledon.gif");  ledOut(LED1, ON);
   strcpy(led_LED2,"ledon.gif");  ledOut(LED2, ON);
   strcpy(led_LED3,"ledon.gif");  ledOut(LED3, ON);

   // process WEB page requests and update the LED's
   while (1) {
      update_leds();
      http_handler();
   }
}
Ejemplo n.º 7
0
void update_leds()
{
   auto char *ptr[5];
   auto int i;

   ptr[0] = led_DS4;
   ptr[1] = led_DS5;
   ptr[2] = led_DS6;
   ptr[3] = led_DS7;
   ptr[4] = led_DS8;

   for(i=0; i<5; i++)
   {
       if(strcmp(ptr[i],"ledon.gif") == 0)
       {
           ledOut(i, 1);
       }
       else
       {
           ledOut(i, 0);
       }
   }
}
Ejemplo n.º 8
0
int main()
{
	//Inititialize the base platform
	init_platform();

    //Initialize the hardware devices
    init_devices();

    //The address of the DDR where the partial bitstream is located
    ParAddrMod1 = COUNTUP_BITADDR;
    ParAddrMod2 = COUNTDOWN_BITADDR;

    while(1){
    	btnData = XGpio_DiscreteRead(&xBtn,CHANNEL1); 	//Reads the button input data

        OutPut = Xil_In32(IPTOUSER);	//Reads the output data from the IP

        ledOut(OutPut); //sends the output data to the led
        Xil_Out32(USERTOIP,OutPut);//send the output back into the IP

        delay(DELAY); //delay the system for visibility to the user

		//Whenever a button is pushed the FPGA will switch between the Partial Bits
        if(btnData != ZERO_HEX && btnData != btnOld){
        	if(firstMod){
        		firstMod = 0;
        		status = XDcfg_TransferBitfile(XDcfg_0, ParAddrMod1, (BITFILE_LEN >> 2));
        		if (status != XST_SUCCESS) {return XST_FAILURE;}
        	}else{
        		firstMod = 1;
        		status = XDcfg_TransferBitfile(XDcfg_0, ParAddrMod2, (BITFILE_LEN >> 2));
        		if (status != XST_SUCCESS) {return XST_FAILURE;}
        	}
	        btnOld = btnData;
        }
    }
Ejemplo n.º 9
0
void main(void)
{
	static char display[NUM_DISPLAYLINES][128];
	auto int control_LED, i, temp_int;

	// it's just good practice to initialize Rabbit's board-specific I/O
	brdInit();

	// initialize all controlled LEDs
	for (i = 0; i < NUM_LEDS ; ++i) {
		LEDs_info[i] = LEDs_info_init[i];
		ledOut(LEDs_info[i].channel, LEDs_info[i].state);
	}

	// display User instructions and channel headings
	DispStr(8, 2, "<<< Controlled LEDs' status: >>>");

	// build then display the controlled LEDs names heading
	display[WORK_DispStr][0] = '\0';	// initialize for strcat function
	for (i = 0; i < NUM_LEDS; ++i) {
		sprintf(display[TEMP_DispStr], "%s\t", LEDs_info[i].name);
		strcat(display[WORK_DispStr], display[TEMP_DispStr]);
	}
	DispStr(8, 4, display[WORK_DispStr]);

	// build then display the controlled LEDs names heading separator
	display[WORK_DispStr][0] = '\0';	// initialize for strcat function
	for (i = 0; i < NUM_LEDS; ++i) {
		temp_int = strlen(LEDs_info[i].name);
		memset(display[TEMP_DispStr], '-', temp_int);
		display[TEMP_DispStr][temp_int] = '\t';
		display[TEMP_DispStr][temp_int + 1] = '\0';
		strcat(display[WORK_DispStr], display[TEMP_DispStr]);
	}
	DispStr(8, 5, display[WORK_DispStr]);

	// build the controlled LEDs selection string
	strcpy(display[SELECT_DispStr], "Select");	// init for strcat function
	for (i = 0; i < NUM_LEDS; ++i) {
		sprintf(display[TEMP_DispStr], "%s%c=%s",
		        0 == i ? " " : ", ", LEDs_info[i].select, LEDs_info[i].name);
		strcat(display[SELECT_DispStr], display[TEMP_DispStr]);
	}
	strcat(display[SELECT_DispStr], " LED to control.");

	DispStr(8, 10, "From PC keyboard:");
	DispStr(8, 21, "< Press 'Q' To Quit >");

	// loop until User presses the upper/lower case 'Q' key
	for (;;) {
		// update LEDs' outputs; build then display updated LEDs' status string
		display[WORK_DispStr][0] = '\0';	// initialize for strcat function
		for (i = 0; i < NUM_LEDS; ++i) {
			ledOut(LEDs_info[i].channel, LEDs_info[i].state);
			// format logic level for display
			sprintf(display[TEMP_DispStr], "%s\t",
			        ON == LEDs_info[i].state ? "ON " : "OFF");
			strcat(display[WORK_DispStr], display[TEMP_DispStr]);
		}
		DispStr(8, 6, display[WORK_DispStr]);

		// wait for User to make output channel selection or exit program
		DispStr(8, 12, display[SELECT_DispStr]);
		do {
			temp_int = toupper(getchar());
			// check if it's the upper/lower case 'Q' key
			if ('Q' == temp_int) {
				exit(0);
			}
			for (i = 0; i < NUM_LEDS; ++i) {
				if (temp_int == LEDs_info[i].select) {
					// found our selection, quit looking
					break;
				}
			}
		} while (NUM_LEDS == i);	// I.E.: until temp_int selection is found

		// save the selection, display the channel that the User has selected
		control_LED = i;
		sprintf(display[WORK_DispStr], "Selected %s LED to control.",
		        LEDs_info[control_LED].name);
		DispStr(8, 12, display[WORK_DispStr]);

		// wait for User to select logic level or exit program
		sprintf(display[WORK_DispStr], "Select %d=ON or %d=OFF.", ON, OFF);
		DispStr(8, 13, display[WORK_DispStr]);
		do {
			temp_int = toupper(getchar());
			// check if it's the q or Q key
			if ('Q' == temp_int) {
				exit(0);
			}
			temp_int -= '0';
		} while (ON != temp_int && OFF != temp_int);
		sprintf(display[WORK_DispStr], "Selected %s.",
		        ON == temp_int ? "ON" : "OFF");
		DispStr(8, 13, display[WORK_DispStr]);
		LEDs_info[control_LED].state = temp_int;

		// momentary delay
		msDelay(DELAY_MILLISECONDS);

		// Clear channel and logic level selection prompts
		DispStr(8, 12, "");
		DispStr(8, 13, "");
	}
}