X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=examples%2Ftriface%2Fboot%2Fmain.c;h=d84dc2552873aa478e89ea5dd857c18b7626a4de;hb=e1510c810a9169e2aa6661e95c8306cf995ad6cd;hp=f4f05c436ad82ad49d6302502b8cb74d13753828;hpb=b6f9eb45c14010b05db137970a893e9588e8e762;p=bertos.git diff --git a/examples/triface/boot/main.c b/examples/triface/boot/main.c index f4f05c43..d84dc255 100644 --- a/examples/triface/boot/main.c +++ b/examples/triface/boot/main.c @@ -57,18 +57,44 @@ #include #include -#include +#include #include +#include + +/* + * Watchdog disable. + * + * This function disable the watchdog timer early after a reset. + * We must do it very soon because new AVR cores do not disable + * the watchdog timer after a cpu reset. In this way the watchdog + * timer is still enabled, continuously resetting the cpu. This is + * necessary only with new AVR cores, for other cores this code has + * no effect. + * + * \{ + */ +// Function prototype of watchdog reset. +void wdt_init(void) __attribute__((naked)) __attribute__((section(".init3"))); +// Function implementation of watchdog reset. +void wdt_init(void) +{ + MCUSR = 0; + wdt_disable(); + + return; +} +/* \} */ + int main(void) { - FlashAvr flash; + Flash flash; Serial ser; // Set up flash programming functions. - flash_avr_init(&flash); + flash_init(&flash); IRQ_ENABLE; @@ -82,9 +108,10 @@ int main(void) ser_init(&ser, CONFIG_BOOT_PORT); ser_setbaudrate(&ser, CONFIG_BOOT_BAUDRATE); - xmodem_recv(&ser, &flash.fd); + xmodem_recv(&ser.fd, &flash.fd); + kfile_close(&flash.fd); - kfile_close(&ser.fd); + kfile_close(&ser.fd); IRQ_DISABLE;