Ejemplo n.º 1
0
Archivo: note.c Proyecto: Hylian/sdvx
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);

  GlobalInterruptEnable();

  while(1)
  {
    DebounceUpdate();
    EncoderUpdate();
    LedUpdate();

    SendSerial();

    /* 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);
    HID_Device_USBTask(&Mouse_HID_Interface);
    HID_Device_USBTask(&Keyboard_HID_Interface);

    USB_USBTask();
  }
}
int
main(void)
{
	initHardware();
	sei();

	kbdInit();
	scanInit();
	layersInit();
	macrosInit();
	expLoad();

	_delay_ms(5);

	scanEnable();

	/* try loading vref from eeprom; if set to 0xffff, run calibration */
	vrefLoad();
	if (vrefGet() == 0xffff)
		kbdCalibrate();

	for (;;) {
		/* try to keep updates synchronous; we don't want to update
		 * bitmap if we haven't sent the last report yet.
		 */
		if (( usingNKROReport() && !updateNKROReport) ||
		    (!usingNKROReport() && !updateKeyboardReport)) {
			bool needsUpdate = false;

			needsUpdate |= kbdUpdateSCBmp();
			needsUpdate |= macrosProcessScan();
			needsUpdate |= expProcessScan(needsUpdate);

			if (needsUpdate) {
				updateKeyboardReport = true;
				updateNKROReport     = true;
				updateSystemReport   = true;
				updateConsumerReport = true;
			}
			layersProcessScan();
		}

		if (USB_DeviceState == DEVICE_STATE_Unattached ||
		    USB_DeviceState == DEVICE_STATE_Suspended)
			if (USB_Device_RemoteWakeupEnabled && kbdWantsWakeup())
				USB_Device_SendRemoteWakeup();

		HID_Device_USBTask(&keyboardHIDIface);
		HID_Device_USBTask(&genericHIDIface);
		HID_Device_USBTask(&nkroHIDIface);
		HID_Device_USBTask(&extrakeyHIDIface);
		USB_USBTask();
	}
}
Ejemplo n.º 3
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);

	for (;;)
	{
		HID_Device_USBTask(&Keyboard_HID_Interface);
		HID_Device_USBTask(&Mouse_HID_Interface);
		USB_USBTask();
	}
}
Ejemplo n.º 4
0
/**
 * @brief Main program entry point
 * @return Will not return
 * @note  This routine contains the overall program flow, including initial
 * setup of all components and the main program loop
 */
int main(void)
{
	SetupHardware();

	for (;; ) {
		#if defined(USB_DEVICE_ROM_DRIVER)
		USB_MouseReport_Data_t report;
		uint16_t reportsize;
		uint8_t reportID = 0;

		memset(&report, 0, sizeof(USB_MouseReport_Data_t));
		CALLBACK_HID_Device_CreateHIDReport(&Mouse_HID_Interface, &reportID, HID_REPORT_ITEM_In, &report, &reportsize);
		if (memcmp(&report, Mouse_HID_Interface.Config.PrevReportINBuffer,
				   Mouse_HID_Interface.Config.PrevReportINBufferSize)) {
			memcpy(Mouse_HID_Interface.Config.PrevReportINBuffer,
				   &report,
				   Mouse_HID_Interface.Config.PrevReportINBufferSize);
			CALLBACK_UsbdHid_SetReportChange(true);
		}
		#else
		HID_Device_USBTask(&Mouse_HID_Interface);
		USB_USBTask(Mouse_HID_Interface.Config.PortNumber, USB_MODE_Device);
		#endif
	}
}
/** 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)
{
	stdout=&mystdout;
	stdin=&mystdin;

	SetupHardware();

	//LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
	GlobalInterruptEnable();

	//Eval Prototype Sharp Reset Pin
	//DDRB &= ~RESET_PIN; //Set Input
	//PORTB |= RESET_PIN; //Set High
	//DDRB |= RESET_PIN; //Set Output

	//Drude Sharp LCD Reset PIN
	PORTF |= RESETN_PIN; //Set High
	DDRF |= RESETN_PIN; //Set Output
	
	//Digitizer Interrupt
	//DDRB &= ~(_BV(7)); //PB7 input
	//PORTB &= ~(1<<PB7); //PB7 low
	PORTB |= (_BV(7)); //Set high (input pullup)
	
	//IP4787CZ32Y HDMI ESD interface chip (HDMI_ACT PIN) Active-High (Test-Point 12)
	PORTF |= (_BV(PF1)); //Set high (input pullup)
	
	//Toshiba Interrupt Pin
	PORTE |= (_BV(PE6)); //Set high (input pullup)
	//Toshiba Standby Pin
	PORTF |= (_BV(PF4)); //Set high (input pullup)
	//Toshiba Reset Pin - Active Low
	PORTC |= (_BV(PC7)); //Set high (input pullup)

	//LCD-CABC
	//PORTF |= (_BV(PF7)); //Set high (defaults to input pullup)
	//DDRF &= ~(_BV(PF7)); //Set output
	//PORTF |= (_BV(PF7)); //Set low

	//LED-PWM
	PORTD |= (_BV(PD6)); //Set high (defaults to input pullup)
	//PORTD &= ~(_BV(PD6)); //Set low
	//DDRD &= ~(_BV(PD6)); //Set output


	RingBuffer_InitBuffer(&FromHost_Buffer, FromHost_Buffer_Data, sizeof(FromHost_Buffer_Data));

	init_screen(0x1F); //magic number!
	
	mxt_list_types();

	for (;;)
	{
		HandleSerial();
		CDC_Device_USBTask(&VirtualSerial_CDC_Interface);
		HID_Device_USBTask(&Digitizer_HID_Interface);
		USB_USBTask();
		HandleDigitizer();
	}
}
Ejemplo n.º 6
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();

	puts_P(PSTR(ESC_FG_CYAN "Mouse Host/Device Demo running.\r\n" ESC_FG_WHITE));

	LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
	sei();

	for (;;)
	{
		/* Determine which USB mode we are currently in */
		if (USB_CurrentMode == USB_MODE_Host)
		{
			MouseHostTask();
			HID_Host_USBTask(&Mouse_HID_Host_Interface);
		}
		else
		{
			HID_Device_USBTask(&Mouse_HID_Device_Interface);
		}

		USB_USBTask();
	}
}
/** 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();

    RingBuffer_InitBuffer(&USARTtoUSB_Buffer);

    sei();

    for (;;) 
    {
		HID_Device_USBTask(&Surface_HID_Interface);
		USB_USBTask();
	
		/* Turn off the Tx LED when the tick count reaches zero */
		if (led1_ticks) 
		{
			led1_ticks--;
			if (led1_ticks == 0) 
			{
				LEDs_TurnOffLEDs(LEDS_LED1);
			}
		}
		
		/* Turn off the Rx LED when the tick count reaches zero */
		if (led2_ticks) 
		{
			led2_ticks--;
			if (led2_ticks == 0) 
			{
				LEDs_TurnOffLEDs(LEDS_LED2);
			}
		}
    }
}
Ejemplo n.º 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)
{
  uint32_t last = 0;

  /* init fifo */
  fifo_init(&fifo, fifo_buffer, sizeof(fifo_buffer));

  /* setup hardware (button, LED, rtc...) */
  SetupHardware();

  /* enable interrupts */
  sei();


  /* main loop */
  while(1)
  {
    /* if button pressed */
    if (!(BUTTON_PIN & (1 << BUTTON)))
    {
      /* ignore if last button was pressed less than DELTA_T */
      if(get_time() > (last+DELTA_T))
      {
        /* generate token and send it to host */
        token();
        last = get_time();
      }
    }

    /* USB tasks */
    HID_Device_USBTask(&Keyboard_HID_Interface);
    USB_USBTask();
  }
}
Ejemplo n.º 9
0
int main(void)
{
	USB_Init();
	
	colors[0] = rgb8(0x30, 0x30, 0x30);
	colors[1] = rgb8(0x30, 0x30, 0x30);
	colors[2] = rgb8(0x30, 0x30, 0x30);
	
	DDRC = _BV(DDC6);
	PORTC = 0;

	DDRD = _BV(DDD6);
	
	//set SS, SCK, and MOSI to outputs
	DDRB |= _BV(DDB0) | _BV(DDB1) | _BV(DDB2);
	
	//SS low
	PORTB &= ~_BV(PORTB0);
	
	//clock normally low, clocked on rising edges, at osc/2
	SPSR = 0; //_BV(SPI2X);
	SPCR = _BV(SPIE) | _BV(MSTR) | _BV(SPE) | _BV(SPR0);

	//16M / (2083 * 64) = 120.02hz
	OCR3A = 2082;
	
	//interrupt on overflow
	TIMSK3 = _BV(OCIE3A);

	//do nothing on counter match
	//CTC, TOP is OCR3A
	//timer prescale is 64
	TCCR3A = 0;
	TCCR3C = 0;
	TCCR3B = _BV(WGM32) | _BV(CS31) | _BV(CS30);
	sei();

	while(true) {
		if (refreshFrame) {
			PORTC |= _BV(PORTC6);
			
			//copy out of volatile
			unsigned long now = millis;
			
			float scale = 0.1f + 0.9f * (sin(2.0 * M_PI * now / 3000.0f) + 1.0) / 2.0;
			for (unsigned char i = 0, idx = 0; i < 32; ++i) {
				buffer[idx++] = colors[i].b * scale;
				buffer[idx++] = colors[i].g * scale;
				buffer[idx++] = colors[i].r * scale;
			}
			
			PORTC &= ~_BV(PORTC6);
			refreshFrame = false;
		}
		HID_Device_USBTask(&Generic_HID_Interface);
		USB_USBTask();
		//sleep_mode();
	}
}
Ejemplo n.º 10
0
int main(void) {
  SetupHardware();
  
  GlobalInterruptEnable();
  
  for (;;) {
    HID_Device_USBTask(&Joystick_HID_Interface);
    USB_USBTask();
  }
}
Ejemplo n.º 11
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();
}
Ejemplo n.º 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();
	init_CIM_frame();


	LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
	sei();

	for (;;)
	{
	    parse_CIM_protocol();
		HID_Device_USBTask(&Keyboard_HID_Interface);
	    parse_CIM_protocol();
		HID_Device_USBTask(&Mouse_HID_Interface);
	    parse_CIM_protocol();
		HID_Device_USBTask(&Joystick_HID_Interface);
	    parse_CIM_protocol();
		USB_USBTask();
	}
}
Ejemplo n.º 13
0
Archivo: keyboard.c Proyecto: mxkl/gh60
/** 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)
{
  GlobalInterruptEnable();

  initialize_hardware();

  while (true) {
    matrix_scan();
    HID_Device_USBTask(&Keyboard_HID_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();

	LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
	sei();

	for (;;)
	{
		HID_Device_USBTask(&MediaControl_HID_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();

	LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
	GlobalInterruptEnable();

	for (;;)
	{
		HID_Device_USBTask(&Device_HID_Interface);
		USB_USBTask();
	}
}
Ejemplo n.º 16
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();
    RingBuffer_InitBuffer(&USARTtoUSB_Buffer);
    
    sei();
    
    for (;;)
    {
        HID_Device_USBTask(&Joystick_HID_Interface);
        USB_USBTask();
    }
}
Ejemplo n.º 17
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)
{
	HidApp_Init();

	GlobalInterruptEnable();

	for (;;)
	{
		HID_Device_USBTask(&Generic_HID_Interface);
		USB_USBTask();
		Encoder_Task();
		Leds_Task();
	}
}
Ejemplo n.º 18
0
int
main(void) {
    MCUSR &= ~(1 << WDRF);
    wdt_disable();
    clock_prescale_set(clock_div_1);
    USB_Init();
    PORTD |= _BV(PORTD5) | _BV(PORTD6) | _BV(PORTD7);	// pull up

    sei();
    for (;;) {
        HID_Device_USBTask(&stateMachine);
        USB_USBTask();
    }
}
Ejemplo n.º 19
0
int main(void) {
    hardwareInit();
    initLEDs();
    setOutputBit(&kOrangeLED, 1);

    sei();

    USB_Init();

    while (1) {
        HID_Device_USBTask(&mouseHIDInterface);
        USB_USBTask();
    }
}
Ejemplo n.º 20
0
/**********************************************************
 * Main function
 **********************************************************/
int main(void){

    //initialize
    initialize();

    //main loop
    while (1)
    {
        /**LUFA usb related tasks*/
		HID_Device_USBTask(&Keyboard_HID_Interface);
        USB_USBTask();

    }
    return 0;
}
Ejemplo n.º 21
0
Archivo: usb.c Proyecto: 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();
}
Ejemplo n.º 22
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();
	
	for (uint8_t Buffer = 0; Buffer < TOTAL_TRACKS; Buffer++)
	  BitBuffer_Init(&TrackDataBuffers[Buffer]);

	for (;;)
	{
		if (Magstripe_GetStatus() & MAG_CARDPRESENT)
		  ReadMagstripeData();

		HID_Device_USBTask(&Keyboard_HID_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();

	LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
	GlobalInterruptEnable();

	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);
		HID_Device_USBTask(&Mouse_HID_Interface);
		USB_USBTask();
	}
}
Ejemplo n.º 24
0
int main(void)
{
  SetupHardware();
  GlobalInterruptEnable();
  _delay_ms(10);
  for (;;)
  {
    if ((PIND & 1) == 0) {
      if (state == 1) {
        pressed = true;
        state = 0;
      }
    } else {
      state = 1;
    }

    HID_Device_USBTask(&Keyboard_HID_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();
	}
}
Ejemplo n.º 26
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();
	}
}