Revision 183 trunk/bootloader/bootloader.c

bootloader.c (revision 183)
1 1
#include <avr/io.h>
2 2
#include <avr/boot.h>
3
#include <avr/pgmspace.h>
4 3
#include <avr/wdt.h>
5

  
6 4
#include <tooltron.h>
7 5
#include "uart.h"
8 6

  
9
#define TRUE	0
10
#define FALSE	1
11

  
12 7
#define ADDR    18
13 8

  
14

  
15 9
// Error thresholds
16 10
#define MAX_TIMEOUT 60000   // Seconds to wait before exiting bootloader mode
17 11
#define MAX_RETRIES 5       // Number of times to retry before giving up
18 12

  
19
// Memory locations
20
#define MAIN_ADDR 0x000     // Where the user code starts
21
#define BOOT_START 0x400    // Where the bootloader starts
22

  
23 13
//Status LED
24 14
#define LED_DDR  DDRB
25 15
#define LED_PORT PORTB
......
28 18
//Function prototypes
29 19
void (*main_start)(void) = BOOT_START/2 - 1;
30 20

  
31
// Packet handler states
32
typedef enum {
33
    sd,
34
    src,
35
    dest,
36
    comd,
37
    read,
38
    cs,
39
    ack
40
} state_t;
41

  
42 21
typedef union {
43 22
    uint8_t bytes[2];
44 23
    int16_t sword;

Also available in: Unified diff