]> git.droids-corp.org - protos/xbee-avr.git/commitdiff
fix bootloader for atm2560
authorFabrice Desclaux <serpilliere@droids-corp.org>
Thu, 29 Mar 2012 17:36:14 +0000 (19:36 +0200)
committerFabrice Desclaux <serpilliere@droids-corp.org>
Thu, 29 Mar 2012 17:36:14 +0000 (19:36 +0200)
main.c

diff --git a/main.c b/main.c
index ad94ba86191cbcad3f3235284be1fb6d07942b43..5f7a638848d076b703bf10d549535f77c8d70d5a 100644 (file)
--- a/main.c
+++ b/main.c
@@ -499,24 +499,35 @@ void xbee_unload_timeout(struct xbee_ctx *ctx)
 
 void bootloader(void)
 {
-#define BOOTLOADER_ADDR 0x1f800
+#ifndef USE_USB
+#define BOOTLOADER_ADDR 0x3f000
        if (pgm_read_byte_far(BOOTLOADER_ADDR) == 0xff) {
                printf_P(PSTR("Bootloader is not present\r\n"));
                return;
        }
        cli();
        /* ... very specific :( */
+       TIMSK0 = 0;
+       TIMSK1 = 0;
+       TIMSK2 = 0;
+       TIMSK3 = 0;
+       TIMSK4 = 0;
+       TIMSK5 = 0;
        EIMSK = 0;
+       UCSR0B = 0;
+       UCSR1B = 0;
+       UCSR2B = 0;
+       UCSR3B = 0;
        SPCR = 0;
        TWCR = 0;
        ACSR = 0;
        ADCSRA = 0;
 
-       __asm__ __volatile__ ("ldi r31,0xf0\n");
+       EIND = 1;
+       __asm__ __volatile__ ("ldi r31,0xf8\n");
        __asm__ __volatile__ ("ldi r30,0x00\n");
-       __asm__ __volatile__ ("ijmp\n");
-
-       /* never returns */
+       __asm__ __volatile__ ("eijmp\n");
+#endif
 }
 
 void xbee_mainloop(void)