Project

General

Profile

Revision 155

undid hack to main toolbox code
got something of the bootloader working

View differences:

trunk/toolbox/main.c
143 143
	init_pins();		//Set pin directions
144 144
	init_uart(51);		//Set registers for uart
145 145
	/***** End Start-up Sequence *****/
146
    while(1) {
147
      PORTB |= _BV(PORTB1);
148
      _delay_ms(100);
149
      PORTB &= ~_BV(PORTB1);
150
      _delay_ms(100);
151
    }
152 146

  
153 147
    uint8_t r;
154 148
    
trunk/toolbox/bootloader/bootloader.c
90 90
#define LED_PORT PORTB
91 91
#define LED      PORTB1
92 92

  
93
#define PAGE_SIZE 32
94

  
93 95
//Function prototypes
94 96
void flash_led(uint8_t);
95 97
void onboard_program_write(uint32_t page, uint8_t *buf);
96 98
void (*main_start)(void) = 0x0000;
97 99

  
98 100
//Variables
99
uint8_t incoming_page_data[256];
101
uint8_t incoming_page_data[PAGE_SIZE];
100 102
uint8_t page_length;
101 103
uint8_t retransmit_flag = FALSE;
102 104

  
......
112 114
  uint8_t check_sum = 0;
113 115
  uint16_t i;
114 116

  
115
  //  init_uart(51); //MAGIC NUMBER??
117
  init_uart(51); //MAGIC NUMBER??
116 118

  
117 119
  //set LED pin as output
118
  //  LED_DDR |= _BV(LED);
119
  
120
    DDRB = 0x00;
121
    DDRB = _BV(DDB0) | _BV(DDB1) | _BV(DDB2) | _BV(DDB5);
122
    DDRD = _BV(DDB4);
123
    PORTB = 0x00;
120
  LED_DDR |= _BV(LED);
124 121

  
125
    // Clear timmer on OCRA1 Compare match
126
    // No prescale
127
    TCCR1B |= _BV(WGM12) | _BV(CS12);
128
    
129
    // 1 second @ 8MHz clock
130
    OCR1AH =0x7A;
131
    OCR1AL =0x12;
132

  
133
    TIMSK = _BV(OCIE1A);
134

  
135 122
  //flash onboard LED to signal entering of bootloader
136
    while(1) {
137
      PORTB |= _BV(LED);
138
      _delay_ms(100);
139
      PORTB &= ~_BV(LED);
140
      _delay_ms(100);
141
    }
142 123
  flash_led(1);
143 124

  
144 125
  //Start bootloading process
126
   uart_send_byte(5); //Tell the world we can be bootloaded
145 127

  
146
  uart_send_byte(5); //Tell the world we can be bootloaded
147

  
148 128
  //Check to see if the computer responded
149 129
  uint32_t count = 0;
150 130
  uint8_t resp;
......
176 156

  
177 157
    page_length = getch(); //Get the length of this block
178 158
    if (retransmit_flag == TRUE) goto RESTART;
159
    if(page_length > PAGE_SIZE) {
160
      while(1) {
161
	flash_led(1);
162
      }
163
    }
179 164

  
180 165
    if (page_length == 'S') {//Check to see if we are done - this is the "all done" command
181 166
      //boot_rww_enable (); //Wait for any flash writes to complete?

Also available in: Unified diff