示例#1
0
/** Main program entry point. This routine contains the overall program flow, including initial
 *  setup of all components and the main program loop.
 */
int main(void)
{
  unsigned char i;

	// set for 16 MHz clock, and make sure the LED is off
	CPU_PRESCALE(0);
	LED_CONFIG;
	LED_OFF;
	
	// Justy's bootup LED hack
  int d,e;
	for (d=0; d<100; d++) {
    LED_ON;
		_delay_ms(1+.1*d);
  LED_OFF;
  _delay_ms(21-.1*d);
	}
	
	
	SetupHardware();

	LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
	sei();

	for (;;)
	{
		MS_Device_USBTask(&Disk_MS_Interface);
		USB_USBTask();
	}
}
示例#2
0
/** USB device mode management task. This function manages the Mass Storage Device class driver when the device is
 *  initialized in USB device mode.
 */
void USBDeviceMode_USBTask(void)
{
	if (USB_CurrentMode != USB_MODE_DEVICE)
	  return;

	MS_Device_USBTask(&Disk_MS_Interface);
}
示例#3
0
/** Main program entry point. This routine configures the hardware required by the application, then
 *  enters a loop to run the application tasks in sequence.
 */
int main(void)
{
	SetupHardware();

	LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
	GlobalInterruptEnable();

	while (RunBootloader || TicksSinceLastCommand++ < 0xFF)
	{
		MS_Device_USBTask(&Disk_MS_Interface);
		USB_USBTask();
	}

	/* 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;

	/* blink bootloader led couple of times */
	for (int i=0; i<2; i++)	{

		PORTE &= 0b10111111; //led low
		_delay_ms(250);
		PORTE |= 0b01000000; //led high
		_delay_ms(250);

	}	PORTE &= 0b10111111; //led low
	
	/* Enable the watchdog and force a timeout to reset the AVR */
	wdt_enable(WDTO_250MS);

	for (;;);
}
示例#4
0
/** Main program entry point. This routine configures the hardware required by the application, then
 *  enters a loop to run the application tasks in sequence.
 */
int main(void)
{
	SetupHardware();

	LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
	GlobalInterruptEnable();

	while (RunBootloader || TicksSinceLastCommand++ < 0xFF)
	{
		MS_Device_USBTask(&Disk_MS_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 (;;);
}
示例#5
0
/** USB device mode management task. This function manages the Mass Storage Device class driver when the device is
 *  initialized in USB device mode.
 */
void USBDeviceMode_USBTask(void)
{
	if (USB_CurrentMode != USB_MODE_Device)
	  return;

	uIPManagement_ManageNetwork();

	RNDIS_Device_USBTask(&Ethernet_RNDIS_Interface_Device);
	MS_Device_USBTask(&Disk_MS_Interface);
}
示例#6
0
void usb_tasks(void)
{
  MS_Device_USBTask(&Disk_MS_Interface);
  CDC_Device_USBTask(&VirtualSerial_CDC_Interface);
  HID_Device_USBTask(&Keyboard_HID_Interface);
  USB_USBTask();

  if(usb_keyboard_sending_string_GLOBAL)
    usb_keyboard_service_write();
}
示例#7
0
/** Main program entry point. This routine contains the overall program flow, including initial
 *  setup of all components and the main program loop.
 */
int main(void)
{
	SetupHardware();

	LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
	sei();

	for (;;)
	{
		MS_Device_USBTask(&Disk_MS_Interface);
		USB_USBTask();
	}
}
示例#8
0
/** Main program entry point. This routine contains the overall program flow, including initial
 *  setup of all components and the main program loop.
 */
int main(void)
{
	SetupHardware();

	LED_off();
	sei();

	for (;;)
	{
		MS_Device_USBTask(&Disk_MS_Interface);
		USB_USBTask();
	}
}
示例#9
0
/** Main program entry point. This routine contains the overall program flow, including initial
 *  setup of all components and the main program loop.
 */
int main(void)
{
	SetupHardware();

	LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
	GlobalInterruptEnable();

	for (;;)
	{
		MS_Device_USBTask(&Disk_MS_Interface);
		HID_Device_USBTask(&Keyboard_HID_Interface);
		USB_USBTask();
	}
}
示例#10
0
文件: usb.c 项目: JohnOH/phatio
void usb_task(void)
{

     //CDC_Device_ReceiveByte(&VirtualSerial_CDC_Interface);
//     uint16_t got = CDC_Device_ReceiveByte(&VirtualSerial_CDC_Interface);
//     if (got > 0) {
//          CDC_Device_SendByte(&VirtualSerial_CDC_Interface, got &0xFF);
//          CDC_Device_Flush(&VirtualSerial_CDC_Interface);
//     }

//     CDC_Device_USBTask(&serial_device);
     MS_Device_USBTask(&ms_device);
     HID_Device_USBTask(&keyboard_device);
     USB_USBTask();
}
示例#11
0
/**
 *  @brief  Main program entry point
 *  @return Will never return
 *  @note   This routine contains the overall program flow, including initial
 *  setup of all components and the main program loop.
 */
int main(void)
{
	SetupHardware();
	iap_init();

#ifdef WITH_USB	

	xprintf("\nLet's see some usb stuff");
	
	int i;
	// initially expect USB connection
	for (i = 0; ; i++) {
		#if !defined(USB_DEVICE_ROM_DRIVER)
		MS_Device_USBTask(&Disk_MS_Interface);
		USB_USBTask(Disk_MS_Interface.Config.PortNumber, USB_MODE_Device);
		#endif
		//if (i > 350000 && !USBConnected) break;
		if (i > 600000 && !USBConnected) break;
	}
#endif
	// if USB is unplugged, serve the vectrex bus
	PrepareLoader(DataRam_GetScratchRAM());

	xprintf("\nLOADER.BIN ROMBase=%x\n", ROMBase);
	void *loader = ROMBase;
	SelectROM(DataRam_GetScratchRAM(), 1); 
	xprintf("1 ROMBase=%x\nServing...", ROMBase);
	ROMBase = loader;

    NVIC_DisableIRQ(UART0_IRQn);
	UART0_UnInit();		
	VectrexBusInit();


	//SelectROM(DataRam_GetScratchRAM(), 1); -- this works
	int romIndex = VectrexBusSlave();	
	//VectrexBusHold();

	SelectROM(DataRam_GetScratchRAM(), romIndex); 

	//VectrexBusUnhold();
	//VectrexNMI();
	for(;;)
		VectrexBusSlave();
}
示例#12
0
/** Main program entry point. This routine contains the overall program flow, including initial
 *  setup of all components and the main program loop.
 */
int main(void)
{
	SetupHardware();

	/* Create a regular character stream for the interface so that it can be used with the stdio.h functions */
	CDC_Device_CreateStream(&VirtualSerial_CDC_Interface, &USBSerialStream);

	LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
	sei();

	for (;;)
	{
		CheckJoystickMovement();

		/* Must throw away unused bytes from the host, or it will lock up while waiting for the device */
		CDC_Device_ReceiveByte(&VirtualSerial_CDC_Interface);

		CDC_Device_USBTask(&VirtualSerial_CDC_Interface);
		MS_Device_USBTask(&Disk_MS_Interface);
		USB_USBTask();
	}
}
/** Main program entry point. This routine contains the overall program flow, including initial
 *  setup of all components and the main program loop.
 */
int main(void)
{
	SetupHardware();

	/* Fetch logging interval from EEPROM */
	LoggingInterval500MS_SRAM = eeprom_read_byte(&LoggingInterval500MS_EEPROM);

	/* Check if the logging interval is invalid (0xFF) indicating that the EEPROM is blank */
	if (LoggingInterval500MS_SRAM == 0xFF)
	  LoggingInterval500MS_SRAM = DEFAULT_LOG_INTERVAL;

	/* Mount and open the log file on the Dataflash FAT partition */
	OpenLogFile();

	LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
	sei();

	for (;;)
	{
		MS_Device_USBTask(&Disk_MS_Interface);
		HID_Device_USBTask(&Generic_HID_Interface);
		USB_USBTask();
	}
}
示例#14
0
/** Main program entry point. This routine contains the overall program flow, including initial
 *  setup of all components and the main program loop.
 */
int main(void)
{
	SetupHardware();

	/* Fetch logging interval from EEPROM */
	LoggingInterval500MS_SRAM = eeprom_read_byte(&LoggingInterval500MS_EEPROM);

	/* Mount and open the log file on the dataflash FAT partition */
	OpenLogFile();

	LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
	sei();

	/* Discard the first sample from the temperature sensor, as it is generally incorrect */
	volatile uint8_t Dummy = Temperature_GetTemperature();
	(void)Dummy;
	
	for (;;)
	{
		MS_Device_USBTask(&Disk_MS_Interface);
		HID_Device_USBTask(&Generic_HID_Interface);
		USB_USBTask();
	}
}
示例#15
0
void DiskDevice_USBTask(void)
{
	MS_Device_USBTask(&DiskDevice_MS_Interface);
}