diff options
-rw-r--r-- | .gitignore | 11 | ||||
-rw-r--r-- | BootloaderCDC.c | 16 |
2 files changed, 26 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1a20f80 --- /dev/null +++ b/.gitignore @@ -0,0 +1,11 @@ +*.o +*.lst +*.elf +*.eep +*.hex +*.lss +*.map +*.sym +.*.swp +.*.un~ +.dep/ diff --git a/BootloaderCDC.c b/BootloaderCDC.c index 3ea56fc..fbc777f 100644 --- a/BootloaderCDC.c +++ b/BootloaderCDC.c @@ -77,6 +77,11 @@ int main(void) sei(); /* Timer init */ + TCCR0B_backup = TCCR0B; + TCCR0A_backup = TCCR0A; + TIMSK0_backup = TIMSK0; + TIFR0_backup = TIFR0; + TCCR0B = 1 << CS02 | 1 << CS00; // prescaler = / 1024, i.e. 15625 Hz TCCR0A = 0; // 8-bit normal mode TIMSK0 = 1 << TOIE0; // Enable Timer0 @@ -97,7 +102,16 @@ int main(void) /* Jump to main program. */ cli(); - TIMSK0 = 0 << TOIE0; // Disable Timer0 interrupt + + // Restore system state + TCCR0B = TCCR0B_backup; + TCCR0A = TCCR0A_backup; + TIMSK0 = TIMSK0_backup; + TIFR0 = TIFR0_backup; + + MCUCR = (1 << IVCE); + MCUCR = (0 << IVSEL); + __asm("jmp 0x0000"); for (;;); |