Revision 176
Fixes #1119. Watchdog timer based reset implemented and added to the common library
trunk/toolbox/bootloader/bootloader.c | ||
---|---|---|
1 | 1 |
#include <avr/io.h> |
2 | 2 |
#include <avr/boot.h> |
3 | 3 |
#include <avr/pgmspace.h> |
4 |
#include <avr/wdt.h> |
|
4 | 5 |
|
5 | 6 |
#include "tooltron.h" |
6 | 7 |
#include "uart.h" |
... | ... | |
219 | 220 |
uint16_t prog_len; |
220 | 221 |
uint8_t i; |
221 | 222 |
uint8_t retries; |
222 |
|
|
223 |
|
|
223 | 224 |
retry_jpnt: |
224 | 225 |
iteration = 0; |
225 | 226 |
retries = 0; |
227 |
|
|
228 |
// Clear the watchdog timer |
|
229 |
MCUSR &= ~_BV(WDRF); |
|
230 |
wdt_disable(); |
|
231 |
WDTCSR = 0; |
|
226 | 232 |
|
233 |
|
|
227 | 234 |
init_uart(51); //MAGIC NUMBER?? |
228 | 235 |
|
229 | 236 |
//set LED pin as output |
trunk/common/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 |
wdt_enabled(WDTO_15MS); |
|
14 |
} |
trunk/common/reset.h | ||
---|---|---|
1 |
#ifndef __RESET_H__ |
|
2 |
#define __RESET_H__ |
|
3 |
|
|
4 |
void reset(void); |
|
5 |
|
|
6 |
#endif |
Also available in: Unified diff