예제 #1
0
파일: main.c 프로젝트: doopai/gh60
int main(void)
{
    setup_mcu();
    keyboard_setup();
    setup_usb();
    sei();
    /* init modules */
    serial_init();
    keyboard_init();
    host_set_driver(&lufa_driver);
#ifdef SLEEP_LED_ENABLE
    sleep_led_init();
#endif
    print("Keyboard start.\n");
    while (1) {
        while (USB_DeviceState == DEVICE_STATE_Suspended) {
            print("[s]");
            matrix_power_down();
            suspend_power_down();
            if (USB_Device_RemoteWakeupEnabled && suspend_wakeup_condition()) {
                    USB_Device_SendRemoteWakeup();
            }
        }

        keyboard_task();

#if !defined(INTERRUPT_CONTROL_ENDPOINT)
        USB_USBTask();
#endif
    }
}
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();
	}
}
예제 #3
0
파일: main.c 프로젝트: 0xdec/tmk_keyboard
int main(void)
{
    SetupHardware();
    sei();

    /* wait for USB startup to get ready for debug output */
    uint8_t timeout = 255;  // timeout when USB is not available(Bluetooth)
    while (timeout-- && USB_DeviceState != DEVICE_STATE_Configured) {
        wait_ms(4);
#if defined(INTERRUPT_CONTROL_ENDPOINT)
        ;
#else
        USB_USBTask();
#endif
    }
    print("\nUSB init\n");

    rn42_init();
    rn42_task_init();
    print("RN-42 init\n");

    /* init modules */
    keyboard_init();

    if (!rn42_rts()) {
        host_set_driver(&rn42_driver);
    } else {
        host_set_driver(&lufa_driver);
    }

#ifdef SLEEP_LED_ENABLE
    sleep_led_init();
#endif

    print("Keyboard start\n");
    while (1) {
        while (rn42_rts() && // RN42 is off
                USB_DeviceState == DEVICE_STATE_Suspended) {
            print("[s]");
            matrix_power_down();
            suspend_power_down();
            suspend_power_down();
            suspend_power_down();
            suspend_power_down();
            suspend_power_down();
            suspend_power_down();
            suspend_power_down();
            if (USB_Device_RemoteWakeupEnabled && suspend_wakeup_condition()) {
                    USB_Device_SendRemoteWakeup();
            }
        }

        keyboard_task();

#if !defined(INTERRUPT_CONTROL_ENDPOINT)
        USB_USBTask();
#endif

        rn42_task();
    }
}