Date:2011-05-10 04:52:00 (8 years 4 months ago)
Author:Werner Almesberger
Commit:42dae8dde24305326ce800ca102687f17f53fa63
Message:atusb/fw: implemented ATUSB_RESET

- board.c (board_init): disable the watchdog timer (tricky !)
- board.h (reset_cpu), board.c: enable the watchdog timer to cause a
CPU reset
- ep0.c (my_setup): uncommented and updated ATUSB_RESET handler
Files: atusb/fw/board.c (2 diffs)
atusb/fw/board.h (1 diff)
atusb/fw/ep0.c (1 diff)

Change Details

atusb/fw/board.c
6161}
6262
6363
64void reset_cpu(void)
65{
66    WDTCSR = 1 << WDE;
67}
68
69
6470uint8_t read_irq(void)
6571{
6672    return PIN(IRQ_RF);
...... 
9096
9197void board_init(void)
9298{
99    /* Disable the watchdog timer */
100
101    MCUSR = 0; /* Remove override */
102    WDTCSR |= 1 << WDCE; /* Enable change */
103    WDTCSR = 1 << WDCE; /* Disable watchdog while still enabling
104                   change */
105
93106    /* We start with a 1 MHz/8 clock. Disable the prescaler. */
94107
95108    CLKPR = 1 << CLKPCE;
atusb/fw/board.h
6363
6464
6565void reset_rf(void);
66void reset_cpu(void);
6667uint8_t read_irq(void);
6768
6869void led(int on);
atusb/fw/ep0.c
8282        usb_send(&eps[0], buf+i, size, NULL, NULL);
8383        return 1;
8484
85#ifdef NOTYET
8685    case ATUSB_TO_DEV(ATUSB_RESET):
8786        debug("ATUSB_RESET\n");
88        RSTSRC = SWRSF;
87        reset_cpu();
8988        while (1);
90#endif
9189
9290    case ATUSB_TO_DEV(ATUSB_RF_RESET):
9391        debug("ATUSB_RF_RESET\n");

Archive Download the corresponding diff file



interactive