Revision 166
Almost works
bootloader.c | ||
---|---|---|
52 | 52 |
UBRRL = (uint8_t)baud; |
53 | 53 |
|
54 | 54 |
// Enable RX/TX and RX/TX Interrupt |
55 |
UCSRB = _BV(RXCIE) | _BV(RXEN) | _BV(TXCIE) | _BV(TXEN);
|
|
55 |
UCSRB = _BV(RXEN) | _BV(TXEN);
|
|
56 | 56 |
|
57 | 57 |
// Enable the TXEN pin as output |
58 | 58 |
DDRD |= TX_EN; |
59 |
uart_toggle_transmit(UART_TX_OFF); |
|
59 | 60 |
} |
60 | 61 |
|
61 | 62 |
BOOTLOADER_SECTION int8_t uart_get_byte(uint8_t *output_byte) { |
... | ... | |
70 | 71 |
BOOTLOADER_SECTION void uart_send_byte(uint8_t data) { |
71 | 72 |
//Waits until current transmit is done |
72 | 73 |
while (!(UCSRA & _BV(UDRE))); |
74 |
PORTB |= _BV(PORTB2); |
|
73 | 75 |
|
74 | 76 |
// Enable writes and send |
75 | 77 |
uart_toggle_transmit(UART_TX_ON); |
... | ... | |
77 | 79 |
|
78 | 80 |
// Waits until the transmit is done |
79 | 81 |
while(!(UCSRA & _BV(UDRE))); |
82 |
PORTB |= _BV(PORTB1); |
|
83 |
|
|
80 | 84 |
uart_toggle_transmit(UART_TX_OFF); |
81 | 85 |
|
82 | 86 |
return; |
... | ... | |
185 | 189 |
uart_send_byte(SERVER); |
186 | 190 |
uart_send_byte(cmd); |
187 | 191 |
uart_send_byte(ACK_CRC ^ cmd); |
192 |
uart_send_byte(0); |
|
188 | 193 |
} |
189 | 194 |
|
190 | 195 |
//#define SPM_PAGESIZE 32 |
... | ... | |
216 | 221 |
|
217 | 222 |
//set LED pin as output |
218 | 223 |
LED_DDR |= 0x07; |
219 |
PORTB = 0x07;
|
|
224 |
PORTB = 0x00;
|
|
220 | 225 |
|
221 | 226 |
//Start bootloading process |
222 | 227 |
send_packet(TT_BOOT); |
228 |
PORTB |= _BV(PORTB0); |
|
223 | 229 |
|
224 | 230 |
resp = parse_packet(mbuf); |
225 | 231 |
if (resp == TT_PROGM) { |
... | ... | |
250 | 256 |
caddr += PROGD_PACKET_SIZE; |
251 | 257 |
} |
252 | 258 |
} else { |
253 |
main_start(); |
|
259 |
//main_start(); |
|
260 |
while(1); |
|
254 | 261 |
} |
255 | 262 |
|
256 | 263 |
send_packet(TT_ACK); |
257 | 264 |
|
258 | 265 |
if (prog_len <= PROGD_PACKET_SIZE) { |
259 |
send_packet(TT_ACK); |
|
266 |
//send_packet(TT_ACK);
|
|
260 | 267 |
|
261 | 268 |
for (i = 0; i < PROGD_PACKET_SIZE; i++) { |
262 | 269 |
mbuf[i]= 0; |
Also available in: Unified diff