X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=examples%2Ftriface%2Fboot%2Fmain.c;h=a1279ac177b3a98887fc01934feb84ab5a654cfa;hb=ca9fb8575f225fb067db8e4eef201e50e8239c7d;hp=dc105baf0374a10c02de0ee5ce608012b89edc5b;hpb=24c21c92d29b76a3f0de0a107f4bafef7bb0f812;p=bertos.git diff --git a/examples/triface/boot/main.c b/examples/triface/boot/main.c index dc105baf..a1279ac1 100644 --- a/examples/triface/boot/main.c +++ b/examples/triface/boot/main.c @@ -46,21 +46,47 @@ * \author Daniele Basile */ +#include "hw/hw_boot.h" +#include "cfg/cfg_ser.h" + #include + #include #include #include /* BV() */ -#include #include #include #include -#include "hw/hw_boot.h" -#include "cfg/cfg_boot.h" - #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; @@ -77,11 +103,10 @@ int main(void) kdbg_init(); timer_init(); - /* Open the main communication port */ - ser_init(&ser, CONFIG_SER_HOSTPORT); - ser_setbaudrate(&ser, CONFIG_SER_HOSTPORTBAUDRATE); + ser_init(&ser, CONFIG_BOOT_PORT); + ser_setbaudrate(&ser, CONFIG_BOOT_BAUDRATE); xmodem_recv(&ser, &flash.fd); kfile_close(&flash.fd);