From c62803d243ff3f557fae7895529de679b5de5952 Mon Sep 17 00:00:00 2001 From: Jon Thacker Date: Tue, 20 Dec 2016 17:19:05 -0600 Subject: [PATCH] atmega_common: disable interrupts prior to rebooting If the watchdog is being reset in another thread, then the reboot will never take place. This commit disables interrupts prior to setting the watchdog timer to 250ms. This functionallity was common to all Atmega CPUs, so it was moved to atmega_common. --- cpu/atmega2560/reboot_arch.c | 35 ------------------- cpu/atmega328p/reboot_arch.c | 35 ------------------- .../reboot_arch.c | 3 +- 3 files changed, 2 insertions(+), 71 deletions(-) delete mode 100644 cpu/atmega2560/reboot_arch.c delete mode 100644 cpu/atmega328p/reboot_arch.c rename cpu/{atmega1281 => atmega_common}/reboot_arch.c (93%) diff --git a/cpu/atmega2560/reboot_arch.c b/cpu/atmega2560/reboot_arch.c deleted file mode 100644 index 1f8f61569f..0000000000 --- a/cpu/atmega2560/reboot_arch.c +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2016 Kaspar Schleiser - * 2014 Freie Universität Berlin, Hinnerk van Bruinehsen - * - * This file is subject to the terms and conditions of the GNU Lesser - * General Public License v2.1. See the file LICENSE in the top level - * directory for more details. - */ - -/** - * @ingroup cpu_atmega2560 - * @{ - * - * @file - * @brief Implementation of the kernels reboot interface - * - * @author Hinnerk van Bruinehsen - * @author Kaspar Schleiser - * - * @} - */ - -#include - -#include "cpu.h" - -void reboot(void) -{ - /* - * Since the AVR doesn't support a real software reset, we set the Watchdog - * Timer on a 250ms timeout. Consider this a kludge. - */ - wdt_enable(WDTO_250MS); - while(1); -} diff --git a/cpu/atmega328p/reboot_arch.c b/cpu/atmega328p/reboot_arch.c deleted file mode 100644 index 802e592632..0000000000 --- a/cpu/atmega328p/reboot_arch.c +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2016 Kaspar Schleiser - * 2014 Freie Universität Berlin, Hinnerk van Bruinehsen - * - * This file is subject to the terms and conditions of the GNU Lesser - * General Public License v2.1. See the file LICENSE in the top level - * directory for more details. - */ - -/** - * @ingroup cpu_atmega328p - * @{ - * - * @file - * @brief Implementation of the kernels reboot interface - * - * @author Hinnerk van Bruinehsen - * @author Kaspar Schleiser - * - * @} - */ - -#include - -#include "cpu.h" - -void reboot(void) -{ - /* - * Since the AVR doesn't support a real software reset, we set the Watchdog - * Timer on a 250ms timeout. Consider this a kludge. - */ - wdt_enable(WDTO_250MS); - while(1); -} diff --git a/cpu/atmega1281/reboot_arch.c b/cpu/atmega_common/reboot_arch.c similarity index 93% rename from cpu/atmega1281/reboot_arch.c rename to cpu/atmega_common/reboot_arch.c index 78954c6287..c828264a2b 100644 --- a/cpu/atmega1281/reboot_arch.c +++ b/cpu/atmega_common/reboot_arch.c @@ -8,7 +8,7 @@ */ /** - * @ingroup cpu_atmega1281 + * @ingroup cpu_atmega_common * @{ * * @file @@ -30,6 +30,7 @@ void reboot(void) * Since the AVR doesn't support a real software reset, we set the Watchdog * Timer on a 250ms timeout. Consider this a kludge. */ + irq_disable(); wdt_enable(WDTO_250MS); while(1); }