1
0
mirror of git://projects.qi-hardware.com/ben-wpan.git synced 2024-11-25 20:41:55 +02:00

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
This commit is contained in:
Werner Almesberger 2011-05-09 23:52:00 -03:00
parent 6179f31fc0
commit 42dae8dde2
3 changed files with 15 additions and 3 deletions

View File

@ -61,6 +61,12 @@ void reset_rf(void)
} }
void reset_cpu(void)
{
WDTCSR = 1 << WDE;
}
uint8_t read_irq(void) uint8_t read_irq(void)
{ {
return PIN(IRQ_RF); return PIN(IRQ_RF);
@ -90,6 +96,13 @@ void panic(void)
void board_init(void) void board_init(void)
{ {
/* Disable the watchdog timer */
MCUSR = 0; /* Remove override */
WDTCSR |= 1 << WDCE; /* Enable change */
WDTCSR = 1 << WDCE; /* Disable watchdog while still enabling
change */
/* We start with a 1 MHz/8 clock. Disable the prescaler. */ /* We start with a 1 MHz/8 clock. Disable the prescaler. */
CLKPR = 1 << CLKPCE; CLKPR = 1 << CLKPCE;

View File

@ -63,6 +63,7 @@
void reset_rf(void); void reset_rf(void);
void reset_cpu(void);
uint8_t read_irq(void); uint8_t read_irq(void);
void led(int on); void led(int on);

View File

@ -82,12 +82,10 @@ static int my_setup(const struct setup_request *setup)
usb_send(&eps[0], buf+i, size, NULL, NULL); usb_send(&eps[0], buf+i, size, NULL, NULL);
return 1; return 1;
#ifdef NOTYET
case ATUSB_TO_DEV(ATUSB_RESET): case ATUSB_TO_DEV(ATUSB_RESET):
debug("ATUSB_RESET\n"); debug("ATUSB_RESET\n");
RSTSRC = SWRSF; reset_cpu();
while (1); while (1);
#endif
case ATUSB_TO_DEV(ATUSB_RF_RESET): case ATUSB_TO_DEV(ATUSB_RF_RESET):
debug("ATUSB_RF_RESET\n"); debug("ATUSB_RF_RESET\n");