X-Git-Url: http://git.droids-corp.org/?p=protos%2Fxbee-avr.git;a=blobdiff_plain;f=main.c;h=d12ed7af5288c90c49fc7253126790184501e1ff;hp=ad94ba86191cbcad3f3235284be1fb6d07942b43;hb=f97044f0c5ecbbc665bd7ac1d454fd9479476a78;hpb=df3e1edad5cbbc0cba317a5088bf9fdcfba85c0e diff --git a/main.c b/main.c index ad94ba8..d12ed7a 100644 --- 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();