spi support
[protos/xbee-avr.git] / main.c
diff --git a/main.c b/main.c
index ad94ba8..d12ed7a 100644 (file)
--- a/main.c
+++ b/main.c
@@ -57,6 +57,7 @@
 #include "cmdline.h"
 #include "callout.h"
 #include "rc_proto.h"
+#include "spi_servo.h"
 #include "main.h"
 
 struct xbeeboard xbeeboard;
@@ -499,24 +500,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)
@@ -607,6 +619,7 @@ int main(void)
        int8_t err;
        struct xbee_dev dev;
 
+       spi_servo_init();
 #ifdef USE_USB
        SetupHardware();