Beispiel #1
0
void
serial_write_block(unsigned char *ch, int len)
{
#if 1
  while (len--)
    serial_write(*ch++);
  serial_sync ();
#else
  DWORD num;
  if (verbose > 1)
    {
      int i;
      printf("\033[36m[%d]\033[0m", len);
      for (i=0; i<len; i++)
	dw (ch[i]);
    }
  while (len > 32)
    {
      FT_Write (handle, ch, 32, &num);
      ch += 32;
      len -= 32;
      serial_sync ();
    }
  if (len)
    FT_Write (handle, ch, len, &num);
  serial_sync ();
#endif
}
Beispiel #2
0
void
serial_pause (int msec)
{
  serial_sync ();
  if (msec)
    usleep (msec*1000);
}
Beispiel #3
0
void
serial_write (unsigned char ch)
{
  DWORD num;

  if (verbose > 1)
    dw (ch);
  FT_Write (handle, &ch, 1, &num);
  serial_sync ();
  usleep(100);
}
Beispiel #4
0
void
serial_write_string(char *ch)
{
  while (*ch)
    serial_write(*ch++);
  serial_sync ();
#if 0
  DWORD num;
  if (verbose > 1)
    {
      int i;
      for (i=0; ch[i]; i++)
	dw (ch[i]);
    }
  FT_Write (handle, &ch, strlen(ch), &num);
#endif
}
Beispiel #5
0
/////////////////////////////////////////////////////////////////////////////
// Main-Funktion
/////////////////////////////////////////////////////////////////////////////
int main(int argc, const char *argv[])
{

	// Initializations
	//
	// first some basic hardware infrastructure
	
	timer_init();			// Timer Interrupt initialisieren
	led_init();

	provider_init();		// needs to be in the beginning, as other
					// modules like serial register here

	term_init();			// does not need endpoint/provider yet
					// but can take up to a buffer of text


#ifdef __AVR__
	stdout = &term_stdout;          // redirect stdout
#else
	device_setup(argc, argv);
#endif

	// server communication
	uarthw_init();			// first hardware
	provider_t *serial = serial_init();	// then logic layer

	// now prepare for terminal etc
	// (note: in the future the assign parameter could be used
	// to distinguish different UARTs for example)
	void *epdata = serial->prov_assign(NAMEINFO_UNUSED_DRIVE, NULL);
	term_endpoint.provider = serial;
	term_endpoint.provdata = epdata;

	// and set as default
	provider_set_default(serial, epdata);

	// debug output via "terminal"
	term_set_endpoint(&term_endpoint);

	// init file handling (active open calls)
	file_init();
	// buffer structures
	buffer_init();
	// direct buffer handling
	direct_init();
	// relfile handling
	relfile_init();
	// init main channel handling
	channel_init();

	// before we init any busses, we init the runtime config code
	// note it gets the provider to register a listener for X command line params
	rtconfig_init(&term_endpoint);

	// bus init	
	// first the general bus (with bus counter)
	bus_init();		

	// this call initializes the device-specific hardware
	// e.g. IEEE488 and IEC busses on xs1541, plus SD card on petSD and so on
	// it also handles the interrupt initialization if necessary
	device_init();

#ifdef HAS_EEPROM
	// read bus-independent settings from non volatile memory
	nv_restore_common_config();
#endif

	// enable interrupts
	enable_interrupts();

	// sync with the server
	serial_sync();		

	// pull in command line config options from server
	// also send directory charset
	rtconfig_pullconfig(argc, argv);

#ifdef USE_FAT
	// register fat provider
	provider_register("FAT", &fat_provider);
	//provider_assign(0, "FAT", "/");		// might be overwritten when fetching X-commands
	//provider_assign(1, "FAT", "/");		// from the server, but useful for standalone-mode
#endif

	// show our version...
  	ListVersion();
	// ... and some system info
	term_printf((" %u Bytes free"), BytesFree());
	term_printf((", %d kHz"), FreqKHz());
#ifdef __AVR__
	fuse_info();
#endif
	term_putcrlf();
	term_putcrlf();


	while (1)  			// Mainloop-Begin
	{
		// keep data flowing on the serial line
		main_delay();

		if (!is_locked) 
			device_loop();

		// send out log messages
		term_flush();
	}
}