Ejemplo n.º 1
0
/* Processes general command-line arguments (--help and --version). */
static void
process_general_args(args_t *args)
{
	if(args->help)
	{
		show_help_msg(NULL);
		quit_on_arg_parsing(EXIT_SUCCESS);
		return;
	}

	if(args->version)
	{
		show_version_msg();
		quit_on_arg_parsing(EXIT_SUCCESS);
		return;
	}
}
Ejemplo n.º 2
0
static void
parse_args(int argc, char *argv[], const char *dir, char *lwin_path,
		char *rwin_path, int *lwin_handle, int *rwin_handle)
{
	int x;
	int select = 0;

	(void)my_chdir(dir);

	/* Get Command Line Arguments */
	for(x = 1; x < argc; x++)
	{
		if(!strcmp(argv[x], "--select"))
		{
			select = 1;
		}
		else if(!strcmp(argv[x], "--remote"))
		{
			if(!ipc_server())
			{
				ipc_send(argv + x + 1);
				quit_on_invalid_arg();
			}
		}
		else if(!strcmp(argv[x], "-f"))
		{
			cfg.vim_filter = 1;
		}
		else if(!strcmp(argv[x], "--no-configs"))
		{
		}
		else if(!strcmp(argv[x], "--version") || !strcmp(argv[x], "-v"))
		{
			show_version_msg();
			quit_on_invalid_arg();
		}
		else if(!strcmp(argv[x], "--help") || !strcmp(argv[x], "-h"))
		{
			show_help_msg();
			quit_on_invalid_arg();
		}
		else if(!strcmp(argv[x], "--logging"))
		{
			/* do nothing, it's handeled in main() */
		}
		else if(!strcmp(argv[x], "-c"))
		{
			if(x == argc - 1)
			{
				puts("Argument missing after \"-c\"");
				quit_on_invalid_arg();
			}
			/* do nothing, it's handeled in exec_startup_commands() */
			x++;
		}
		else if(argv[x][0] == '+')
		{
			/* do nothing, it's handeled in exec_startup_commands() */
		}
		else if(path_exists(argv[x]) || is_path_absolute(argv[x]) ||
				is_root_dir(argv[x]))
		{
			if(lwin_path[0] != '\0')
			{
				parse_path(dir, argv[x], rwin_path);
				*rwin_handle = !select;
			}
			else
			{
				parse_path(dir, argv[x], lwin_path);
				*lwin_handle = !select;
			}
			select = 0;
		}
		else if(curr_stats.load_stage == 0)
		{
			show_help_msg();
			quit_on_invalid_arg();
		}
		else
		{
			show_error_msgf("--remote error", "Invalid argument: %s", argv[x]);
		}
	}
}
int main()
{

  _delay_ms(1000);
  _delay_ms(1000);
  _delay_ms(1000);

  
  pinMode(BUTTON,INPUT);
  pinMode(LED,OUTPUT);
  digitalWrite(LED,LOW);
  
  // -- set up lines for I2C --
  
  i2cpin(SDA,HIGH);
  i2cpin(SDA,HIGH);
 
  _delay_ms(100);
  
  // check if I2C pullup resistors are doing their job
  if ((bit_is_set(PINB,SDA)) && (bit_is_set(PINB,SDA)))
  {
    i2c_available=1;
  } else {
    i2c_available=0;
  }
  
  
 
  // -- set up control lines for HV parallel programming --
  pinMode(VCC, OUTPUT);
  pinMode(RST, OUTPUT);
  pinMode(DATAOUT, OUTPUT);
  pinMode(INSTOUT, OUTPUT);
  pinMode(CLKOUT, OUTPUT);
  pinMode(DATAIN, OUTPUT);  // configured as input when in programming mode
  
  // Initialize output pins as needed
  digitalWrite(RST, HIGH);  // Level shifter is inverting, this shuts off 12V


  // show welcome message on LCD if attached
  if(i2c_available)
  {
    
    show_title_msg();
    _delay_ms(100);
    show_version_msg();
    _delay_ms(1000);
    show_instructions_msg();
  }
   
  while (1)
  {
  
    // indicate with LED that we are ready
    digitalWrite(LED,HIGH);
    _delay_ms(2000);
    digitalWrite(LED,LOW);
	
    if(i2c_available)
    {
      show_title_msg();
    }
	
    while (bit_is_clear(PINA,BUTTON)) {  }  // wait until keypress is detected     

	if(i2c_available)
    {
      i2c_start(LCD_I2C_DEVICE_ID);
      i2c_tx(12);  // clear lcd
      i2c_stop(); 
    }
	  
	  
    
   
   
    _delay_ms(100);

    int btcounter=0;

    while (bit_is_set(PINA,BUTTON))
    {
      btcounter++;
      _delay_ms(10);
     
    }

    // button has been released

    if (btcounter < 200)
    {
      // short button press detected
   
      if(readFuses())
      {
	    // successfully communicated with target device, blink three times briefly

        digitalWrite(LED,HIGH);
        _delay_ms(50);
        digitalWrite(LED,LOW);
        _delay_ms(300);
		
	    digitalWrite(LED,HIGH);
        _delay_ms(50);
        digitalWrite(LED,LOW);
        _delay_ms(300);

        digitalWrite(LED,HIGH);
        _delay_ms(50);
        digitalWrite(LED,LOW);
   
	  } else {

		// target programming device not found, blink 20x briefly
        blink_nodev_err();
	  
	  }
		
		
	 
    } else {

	  // long button press detected
	
      if(writeFuses())
	  {
	    // successfully communicated with target device, blink three times long
		
		digitalWrite(LED,HIGH);
        _delay_ms(1000);
        digitalWrite(LED,LOW);
        _delay_ms(500);
	  
	    digitalWrite(LED,HIGH);
        _delay_ms(1000);
        digitalWrite(LED,LOW);
        _delay_ms(500);
		
		digitalWrite(LED,HIGH);
        _delay_ms(1000);
        digitalWrite(LED,LOW);
      
		
	  } else {
	  
	    // target programming device not found, blink 20x briefly
	    blink_nodev_err();
	  
	  }

  
    
    }

    _delay_ms(1000);
    _delay_ms(1000);
    _delay_ms(1000);
    _delay_ms(1000);
   

  }

  return 0;

}