示例#1
0
/** Main program entry point. This routine configures the hardware required by the application, then
 *  starts the scheduler to run the application tasks.
 */
int main(void)
{
	SetupHardware();
	
	LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);

	for (;;)
	{
		MIDI_Task();
		USB_USBTask();
	}
}
/** Main program entry point. This routine configures the hardware required by the bootloader, then continuously
 *  runs the bootloader processing routine until instructed to soft-exit, or hard-reset via the watchdog to start
 *  the loaded application code.
 */
int main(void)
{
	/* Setup hardware required for the bootloader */
	SetupHardware();

	/* Turn on first LED on the board to indicate that the bootloader has started */
	LEDs_SetAllLEDs(LEDS_LED1);

	/* Fill in the UUID Report */
	/* Bootloader ID */
	UUIDReport[0] = BOOTLOADER_ID_SIG >> 8;
	UUIDReport[1] = BOOTLOADER_ID_SIG & 0xFF;
	/* Bootloader Version */
	UUIDReport[2] = BOOTLOADER_VERSION_SIG >> 8;
	UUIDReport[3] = BOOTLOADER_VERSION_SIG & 0xFF;
	/* Device ID */
	for (size_t i = 4; i < UUID_SIZE; i++)
	{
		UUIDReport[i] = eeprom_read_byte((uint8_t*)(intptr_t)(i));
	}

	/* Enable global interrupts so that the USB stack can function */
	GlobalInterruptEnable();

	while (RunBootloader)
	{
		MIDI_Task();
		CDC_Task();
		MIDI_Device_USBTask(&Keyboard_MIDI_Interface);
		USB_USBTask();
	}

	/* Wait a short time to end all USB transactions and then disconnect */
	_delay_us(1000);

	/* Disconnect from the host - USB interface will be reset later along with the AVR */
	USB_Detach();

	/* Unlock the forced application start mode of the bootloader if it is restarted */
	MagicBootKey = MAGIC_BOOT_KEY;

	/* Enable the watchdog and force a timeout to reset the AVR */
	wdt_enable(WDTO_250MS);

	for (;;);
}
示例#3
0
int main(void) {
	
	SetupHardware();
		
	sei();
	
	for (;;) { 
		
		if (CURRENT_MODE == MODE_SERIAL) {
			Serial_Task(); 
		} 
		
		else {
			MIDI_Task();
		}
		
		USB_USBTask();

	}
	
}