X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;ds=sidebyside;f=carlfw%2Fsrc%2Fmain.c;h=a9a1306b4693b2fed2ced3c9e95e066b8ac5d484;hb=55af0ecd51af9b85961eccc3b3e9cc9997b60192;hp=bdb68babd58a79bbf583b3314573256cf6fe3a9f;hpb=e72388a0aa23da8bc8e24a0cbe9d523c5a9ce294;p=carl9170fw.git diff --git a/carlfw/src/main.c b/carlfw/src/main.c index bdb68ba..a9a1306 100644 --- a/carlfw/src/main.c +++ b/carlfw/src/main.c @@ -43,15 +43,14 @@ static void init(void) /* 25/50/100ms timer (depends on cpu clock) */ timer_init(0, 50000); - /* turn off all leds */ - led_set(0); + /* USB init */ + usb_init(); + + memset(&dma_mem, 0, sizeof(dma_mem)); /* fill DMA rings */ dma_init_descriptors(); - /* USB init */ - usb_init(); - /* clear all interrupt */ set(AR9170_MAC_REG_INT_CTRL, 0xffff); @@ -76,14 +75,22 @@ static void init(void) down_trigger(); } +static void handle_fw(void) +{ + if (fw.watchdog_enable == 1) + set(AR9170_TIMER_REG_WATCH_DOG, AR9170_WATCH_DOG_TIMER); + + if (fw.reboot) + reboot(); +} + static void __attribute__((noreturn)) main_loop(void) { clock_set(true, AHB_40MHZ_OSC); /* main loop */ while (1) { - if (fw.watchdog_enable == 1) - set(AR9170_TIMER_REG_WATCH_DOG, AR9170_WATCH_DOG_TIMER); + handle_fw(); /* * Due to frame order persevation, the wlan subroutines @@ -115,7 +122,6 @@ void __attribute__((noreturn)) start(void) { /* initialize firmware context and DMA memory */ memset(&fw, 0, sizeof(fw)); - memset(&dma_mem, 0, sizeof(dma_mem)); /* watchdog magic pattern check */ if ((get(AR9170_PWR_REG_WATCH_DOG_MAGIC) & 0xffff0000) == 0x12340000) {