| 76 | } |
| 77 | |
| 78 | void jumpToBootloader(void) |
| 79 | { |
| 80 | #if defined(_avr_at_) // AVR |
| 81 | cli(); |
| 82 | // disable watchdog, if enabled |
| 83 | // disable all peripherals |
| 84 | UDCON = 1; |
| 85 | USBCON = (1<<FRZCLK); // disable USB |
| 86 | UCSR1B = 0; |
| 87 | _delay_ms(5); |
| 88 | |
| 89 | #if defined(__AVR_AT90USB162__) // Teensy 1.0 |
| 90 | EIMSK = 0; PCICR = 0; SPCR = 0; ACSR = 0; EECR = 0; |
| 91 | TIMSK0 = 0; TIMSK1 = 0; UCSR1B = 0; |
| 92 | DDRB = 0; DDRC = 0; DDRD = 0; |
| 93 | PORTB = 0; PORTC = 0; PORTD = 0; |
| 94 | asm volatile("jmp 0x3E00"); |
| 95 | #elif defined(__AVR_ATmega32U4__) // Teensy 2.0 |
| 96 | EIMSK = 0; PCICR = 0; SPCR = 0; ACSR = 0; EECR = 0; ADCSRA = 0; |
| 97 | TIMSK0 = 0; TIMSK1 = 0; TIMSK3 = 0; TIMSK4 = 0; UCSR1B = 0; TWCR = 0; |
| 98 | DDRB = 0; DDRC = 0; DDRD = 0; DDRE = 0; DDRF = 0; TWCR = 0; |
| 99 | PORTB = 0; PORTC = 0; PORTD = 0; PORTE = 0; PORTF = 0; |
| 100 | asm volatile("jmp 0x7E00"); |
| 101 | #elif defined(__AVR_AT90USB646__) // Teensy++ 1.0 |
| 102 | EIMSK = 0; PCICR = 0; SPCR = 0; ACSR = 0; EECR = 0; ADCSRA = 0; |
| 103 | TIMSK0 = 0; TIMSK1 = 0; TIMSK2 = 0; TIMSK3 = 0; UCSR1B = 0; TWCR = 0; |
| 104 | DDRA = 0; DDRB = 0; DDRC = 0; DDRD = 0; DDRE = 0; DDRF = 0; |
| 105 | PORTA = 0; PORTB = 0; PORTC = 0; PORTD = 0; PORTE = 0; PORTF = 0; |
| 106 | asm volatile("jmp 0xFC00"); |
| 107 | #elif defined(__AVR_AT90USB1286__) // Teensy++ 2.0 |
| 108 | EIMSK = 0; PCICR = 0; SPCR = 0; ACSR = 0; EECR = 0; ADCSRA = 0; |
| 109 | TIMSK0 = 0; TIMSK1 = 0; TIMSK2 = 0; TIMSK3 = 0; UCSR1B = 0; TWCR = 0; |
| 110 | DDRA = 0; DDRB = 0; DDRC = 0; DDRD = 0; DDRE = 0; DDRF = 0; |
| 111 | PORTA = 0; PORTB = 0; PORTC = 0; PORTD = 0; PORTE = 0; PORTF = 0; |
| 112 | asm volatile("jmp 0x1FC00"); |
| 113 | #endif |
| 114 | |
| 115 | #else |
| 116 | #warning "unsuported platform" |
| 117 | #endif |
| 118 | } |
| 119 | |
| 120 | // Given a sampling array, and the current number of detected keypress |
| 121 | // Add as many keypresses from the sampling array to the USB key send array as possible. |
no outgoing calls
no test coverage detected
searching dependent graphs…