Пример #1
0
int main( void )
{
	cli();

	setup_clock();

	InitBuffer(&ab);

	//Don't touch any PORTB below 4, those are for printf
//	SetupPrintf();

	USB_ZeroPrescaler();
	USB_Init();

	DDRC = 0x0;

	SPI_MasterInit();

//	_delay_ms(10); //wait for tiny 44 to be ready for data
//	setup_timers();

	setup_channel_interrupt();

	DDRD |= _BV(PD6);

	sei();

//	testAsm();
//	if (testPtr == 'w') PORTD |= _BV(PD6);

	while(1)
	{
		UENUM = 4; //interrupts can change this

		//these if statements can take a bit of time so run them and save the
		//result for future use
		if ( USB_READY(UEINTX) && (BytesFree(&ab) >= 8) )
			dataState=1;
		else if ( BytesUsed(&ab) >= 2)
			dataState=2;
		else
			dataState=0;

		while (needAudioFlag==0);
cli();
		needAudioFlag=0;

		DoAudioState();
sei();
	}

	return 0;
}
Пример #2
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();
	}
}