Revision 209
Restored reset to pristine state, fixed a bug in the error case for the bootloader
trunk/bootloader/bootloader.h | ||
---|---|---|
9 | 9 |
#include <toolbox_pindefs.h> |
10 | 10 |
#include "rs485_poll.h" |
11 | 11 |
#include "packet.h" |
12 |
#include "reset.h" |
|
12 | 13 |
|
13 | 14 |
#endif |
trunk/bootloader/reset.c | ||
---|---|---|
1 |
#include <avr/wdt.h> |
|
2 |
|
|
3 |
/** |
|
4 |
* This function resets the board, resetting the hardware back to almost the |
|
5 |
* same state as a power on reset. Note that you must do the following in |
|
6 |
* this order upon reset or the process will fail: |
|
7 |
* |
|
8 |
* 1. Reset WDRF in MCUSR to 0 |
|
9 |
* 2. call wdt_diable() to disable the watchdog in the right order |
|
10 |
* 3. Set WDTCSR to clear out all traces of the watchdog timer |
|
11 |
**/ |
|
12 |
void reset(void) { |
|
13 |
//uint8_t count; |
|
14 |
wdt_enable(WDTO_15MS); |
|
15 |
/* |
|
16 |
while(1) { |
|
17 |
if (count == 255) { |
|
18 |
PORTB ^= 0x7; |
|
19 |
} |
|
20 |
count++; |
|
21 |
} |
|
22 |
*/ |
|
23 |
|
|
24 |
} |
trunk/bootloader/packet.c | ||
---|---|---|
118 | 118 |
|
119 | 119 |
case cs: |
120 | 120 |
if (r == crc) { |
121 |
if (cmd == TT_RESET) { |
|
122 |
reset(); |
|
123 |
} |
|
121 | 124 |
return cmd; |
122 | 125 |
} else { |
123 | 126 |
return TT_BAD; |
trunk/bootloader/reset.h | ||
---|---|---|
1 |
#ifndef __RESET_H__ |
|
2 |
#define __RESET_H__ |
|
3 |
|
|
4 |
void reset(void) __attribute__((noreturn)); |
|
5 |
|
|
6 |
#endif |
trunk/bootloader/bootloader.c | ||
---|---|---|
150 | 150 |
// of the bootloader function |
151 | 151 |
if (retries > MAX_RETRIES) { |
152 | 152 |
goto retry_jpnt; |
153 |
} else { |
|
154 |
continue; |
|
153 | 155 |
} |
154 | 156 |
} |
155 | 157 |
|
Also available in: Unified diff