Пример #1
0
int main(void)
{
    // set for 16 MHz clock
    CPU_PRESCALE(0);

    // Initialize the USB, and then wait for the host to set configuration.
    // If the Teensy is powered without a PC connected to the USB port,
    // this will wait forever.
    usb_init();
    while (!usb_configured()) /* wait */ ;

    keyboard_init();
    host_set_driver(pjrc_driver());
#ifdef SLEEP_LED_ENABLE
    sleep_led_init();
#endif
    while (1) {
        while (suspend) {
            suspend_power_down();
            if (remote_wakeup && suspend_wakeup_condition()) {
                usb_remote_wakeup();
            }
        }

        keyboard_task(); 
    }
}
Пример #2
0
int main(void)
{
    // set for 16 MHz clock
    CPU_PRESCALE(0);

    // Initialize the USB, and then wait for the host to set configuration.
    // If the Teensy is powered without a PC connected to the USB port,
    // this will wait forever.
    usb_init();
    while (!usb_configured()) /* wait */ ;

    print_set_sendchar(sendchar);

    keyboard_init();
    host_set_driver(pjrc_driver());
#ifdef SLEEP_LED_ENABLE
    sleep_led_init();
#endif

    while (1) {

		uint32_t mtl_time = timer_read32();
		for ( int i = 0; i < 1000; i++ ) {

			/*print( "Main loop: i = " );*/
			/*phex( (uint8_t) ( i >> 8 ) & 0xff );*/
			/*phex( (uint8_t) ( i >> 0 ) & 0xff );*/
			/*print( "\n" );*/

        while (suspend) {
            suspend_power_down();
            if (remote_wakeup && suspend_wakeup_condition()) {
                usb_remote_wakeup();
            }
        }

        keyboard_task(); 

		}
		mtl_time = timer_elapsed32( mtl_time );
		// No TP: 247 ms
		// TP full: 10820 ms
		// No usb report: same as TP full
//		print( "Time for 1,000 keyboard_tasks: " );
//		phex( (uint8_t) ( mtl_time >> 24 ) & 0xff );
//		phex( (uint8_t) ( mtl_time >> 16 ) & 0xff );
//		phex( (uint8_t) ( mtl_time >>  8 ) & 0xff );
//		phex( (uint8_t) ( mtl_time >>  0 ) & 0xff );
//		print( "\n" );
	}


}
Пример #3
0
int main(void)
{
    DEBUG_LED_CONFIG;
    DEBUG_LED_OFF;

    // set for 16 MHz clock
    CPU_PRESCALE(0);

    // Initialize the USB, and then wait for the host to set configuration.
    // If the Teensy is powered without a PC connected to the USB port,
    // this will wait forever.
    usb_init();
    while (!usb_configured()) /* wait */ ;

    keyboard_init();
    matrix_scan();
    if (matrix_key_count() >= 3) {
#ifdef DEBUG_LED
        for (int i = 0; i < 6; i++) {
            DEBUG_LED_CONFIG;
            DEBUG_LED_ON;
            _delay_ms(500);
            DEBUG_LED_OFF;
            _delay_ms(500);
        }
#else
        _delay_ms(5000);
#endif
        print_enable = true;
        debug_enable = true;
        debug_matrix = true;
        debug_keyboard = true;
        debug_mouse = true;
        print("debug enabled.\n");
    }
    if (matrix_key_count() >= 4) {
        print("jump to bootloader...\n");
        _delay_ms(1000);
        bootloader_jump(); // not return
    }


    host_set_driver(pjrc_driver());
    while (1) {
       keyboard_proc(); 
    }
}