Revision 207

trunk/toolbox/reset.c (revision 207)
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_enable(WDTO_15MS);
14
    while(1);
15
}
trunk/toolbox/reset.h (revision 207)
1
#ifndef __RESET_H__
2
#define __RESET_H__
3

  
4
void reset(void) __attribute__((noreturn));
5

  
6
#endif
trunk/toolbox/main.c (revision 207)
32 32
#include <tooltron.h>
33 33
#include <toolbox_pindefs.h>
34 34
#include "jumptable.h"
35
#include "reset.h"
36 35

  
37 36
/***
38 37
 * TWAIT - minutes to wait before green button is pressed to kill power
......
46 45
uint8_t sec;
47 46
uint8_t min;
48 47

  
49
typedef struct {
50
    uint8
51

  
52 48
typedef enum {
53 49
    wait,   // wait for a turn on packet
54 50
    pwron,  // poweron
......
198 194
                    toggle_led(LED_YELLOW, ON);
199 195
                    state = pwron;
200 196
                    reset_timer();
201
                // Reset the board
202
                } else if (resp == TT_RESET) {
203
                    send_packet(TT_ACK, addr);
204
                    reset();
205 197
                }
206 198
                break;
207 199
            case pwron:

Also available in: Unified diff