From 86261e03e62436d602beed757644ef80b1c5b374 Mon Sep 17 00:00:00 2001 From: Hauke Petersen Date: Wed, 15 Jul 2015 16:02:43 +0200 Subject: [PATCH 1/4] cpu/nrf51: make use of hwtimer_compat module --- cpu/nrf51/Makefile.include | 3 ++ cpu/nrf51/hwtimer_arch.c | 73 -------------------------------------- 2 files changed, 3 insertions(+), 73 deletions(-) delete mode 100644 cpu/nrf51/hwtimer_arch.c diff --git a/cpu/nrf51/Makefile.include b/cpu/nrf51/Makefile.include index 04c2fd5dd4..da01dcdf4f 100644 --- a/cpu/nrf51/Makefile.include +++ b/cpu/nrf51/Makefile.include @@ -1,3 +1,6 @@ export CPU_ARCH = cortex-m0 +# use hwtimer compatibility module +USEMODULE += hwtimer_compat + include $(RIOTCPU)/Makefile.include.cortexm_common diff --git a/cpu/nrf51/hwtimer_arch.c b/cpu/nrf51/hwtimer_arch.c deleted file mode 100644 index 2e47719dc8..0000000000 --- a/cpu/nrf51/hwtimer_arch.c +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (C) 2014 Freie Universität Berlin - * - * 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_nrf51822 - * @{ - * - * @file - * @brief Implementation of the kernels hwtimer interface - * - * The hardware timer implementation uses a direct mapping to the low-level UART driver. - * - * @author Hauke Petersen - * - * @} - */ - -#include "arch/hwtimer_arch.h" -#include "board.h" -#include "periph/timer.h" -#include "thread.h" - - -void irq_handler(int channel); -void (*timeout_handler)(int); - - -void hwtimer_arch_init(void (*handler)(int), uint32_t fcpu) -{ - (void) fcpu; - timeout_handler = handler; - timer_init(HW_TIMER, 1, &irq_handler); -} - -void hwtimer_arch_enable_interrupt(void) -{ - timer_irq_enable(HW_TIMER); -} - -void hwtimer_arch_disable_interrupt(void) -{ - timer_irq_disable(HW_TIMER); -} - -void hwtimer_arch_set(unsigned long offset, short timer) -{ - timer_set(HW_TIMER, timer, offset); -} - -void hwtimer_arch_set_absolute(unsigned long value, short timer) -{ - timer_set_absolute(HW_TIMER, timer, value); -} - -void hwtimer_arch_unset(short timer) -{ - timer_clear(HW_TIMER, timer); -} - -unsigned long hwtimer_arch_now(void) -{ - return timer_read(HW_TIMER); -} - -void irq_handler(int channel) -{ - timeout_handler((short)(channel)); -} From 809b99f6481fdc30015e91e8dab3b4a7268be230 Mon Sep 17 00:00:00 2001 From: Hauke Petersen Date: Wed, 15 Jul 2015 16:05:28 +0200 Subject: [PATCH 2/4] cpu/atmega2560: make use of hwtimer_compat --- cpu/atmega2560/Makefile.include | 9 ++-- cpu/atmega2560/hwtimer_arch.c | 73 --------------------------------- 2 files changed, 5 insertions(+), 77 deletions(-) delete mode 100644 cpu/atmega2560/hwtimer_arch.c diff --git a/cpu/atmega2560/Makefile.include b/cpu/atmega2560/Makefile.include index 0adb583171..360d0c6b08 100644 --- a/cpu/atmega2560/Makefile.include +++ b/cpu/atmega2560/Makefile.include @@ -1,9 +1,12 @@ - # this CPU implementation is using the new core/CPU interface export CFLAGS += -DCOREIF_NG=1 # tell the build system that the CPU depends on the atmega common files -export USEMODULE += atmega_common +USEMODULE += atmega_common +# use hwtimer compatibility module +USEMODULE += hwtimer_compat +# export the peripheral drivers to be linked into the final binary +export USEMODULE += periph # define path to atmega common module, which is needed for this CPU export ATMEGA_COMMON = $(RIOTCPU)/atmega_common/ @@ -18,8 +21,6 @@ export INCLUDES += -I$(RIOTCPU)/$(CPU)/include # Without this the interrupt vectors will not be linked correctly! export UNDEF += $(BINDIR)cpu/startup.o -# export the peripheral drivers to be linked into the final binary -export USEMODULE += periph # CPU depends on the atmega common module, so include it include $(ATMEGA_COMMON)Makefile.include diff --git a/cpu/atmega2560/hwtimer_arch.c b/cpu/atmega2560/hwtimer_arch.c deleted file mode 100644 index a6bab720a9..0000000000 --- a/cpu/atmega2560/hwtimer_arch.c +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (C) 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 hwtimer interface - * - * The hardware timer implementation uses the ATmega2560 build-in system timer as back-end. - * - * @author Hauke Petersen - * @author Hinnerk van Bruinehsen - * - * @} - */ - -#include "arch/hwtimer_arch.h" -#include "board.h" -#include "periph/timer.h" -#include "thread.h" - - -void irq_handler(int channel); -void (*timeout_handler)(int); - - -void hwtimer_arch_init(void (*handler)(int), uint32_t fcpu) -{ - timeout_handler = handler; - timer_init(HW_TIMER, 1, &irq_handler); -} - -void hwtimer_arch_enable_interrupt(void) -{ - timer_irq_enable(HW_TIMER); -} - -void hwtimer_arch_disable_interrupt(void) -{ - timer_irq_disable(HW_TIMER); -} - -void hwtimer_arch_set(unsigned long offset, short timer) -{ - timer_set(HW_TIMER, timer, offset); -} - -void hwtimer_arch_set_absolute(unsigned long value, short timer) -{ - timer_set_absolute(HW_TIMER, timer, value); -} - -void hwtimer_arch_unset(short timer) -{ - timer_clear(HW_TIMER, timer); -} - -unsigned long hwtimer_arch_now(void) -{ - return timer_read(HW_TIMER); -} - -void irq_handler(int channel) -{ - timeout_handler((short)(channel)); -} From 7173b41069430f438bf4caa08e27d180327d716e Mon Sep 17 00:00:00 2001 From: Hauke Petersen Date: Wed, 15 Jul 2015 16:06:08 +0200 Subject: [PATCH 3/4] cpu/lpc1768: use hwtimer_compat module --- cpu/lpc1768/Makefile.include | 3 ++ cpu/lpc1768/hwtimer_arch.c | 70 ------------------------------------ 2 files changed, 3 insertions(+), 70 deletions(-) delete mode 100644 cpu/lpc1768/hwtimer_arch.c diff --git a/cpu/lpc1768/Makefile.include b/cpu/lpc1768/Makefile.include index f16ada89b8..99de28dcc7 100644 --- a/cpu/lpc1768/Makefile.include +++ b/cpu/lpc1768/Makefile.include @@ -1,3 +1,6 @@ export CPU_ARCH = cortex-m3 +# use hwtimer compatibility module +USEMODULE += hwtimer_compat + include $(RIOTCPU)/Makefile.include.cortexm_common diff --git a/cpu/lpc1768/hwtimer_arch.c b/cpu/lpc1768/hwtimer_arch.c deleted file mode 100644 index 1587efef1d..0000000000 --- a/cpu/lpc1768/hwtimer_arch.c +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (C) 2014 Freie Universität Berlin - * - * 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_lpc1768 - * @{ - * - * @file - * @brief Implementation of the kernel's hwtimer interface - * - * The hardware timer implementation uses the Cortex build-in system timer as back-end. - * - * @author Hauke Petersen - * - * @} - */ - -#include "arch/hwtimer_arch.h" -#include "periph/timer.h" -#include "board.h" -#include "thread.h" - -void irq_handler(int channel); -void (*timeout_handler)(int); - -void hwtimer_arch_init(void (*handler)(int), uint32_t fcpu) -{ - timeout_handler = handler; - timer_init(HW_TIMER, 1, &irq_handler); -} - -void hwtimer_arch_enable_interrupt(void) -{ - timer_irq_enable(HW_TIMER); -} - -void hwtimer_arch_disable_interrupt(void) -{ - timer_irq_disable(HW_TIMER); -} - -void hwtimer_arch_set(unsigned long offset, short timer) -{ - timer_set(HW_TIMER, timer, offset); -} - -void hwtimer_arch_set_absolute(unsigned long value, short timer) -{ - timer_set_absolute(HW_TIMER, timer, value); -} - -void hwtimer_arch_unset(short timer) -{ - timer_clear(HW_TIMER, timer); -} - -unsigned long hwtimer_arch_now(void) -{ - return timer_read(HW_TIMER); -} - -void irq_handler(int channel) -{ - timeout_handler((short)(channel)); -} From 25abd13fb5971a6f3ed3bbe07f5a9757a5bdd307 Mon Sep 17 00:00:00 2001 From: Hauke Petersen Date: Wed, 15 Jul 2015 16:06:34 +0200 Subject: [PATCH 4/4] cpu/sam3: use hwtimer_compat module --- cpu/sam3/Makefile.include | 3 ++ cpu/sam3/hwtimer_arch.c | 72 --------------------------------------- 2 files changed, 3 insertions(+), 72 deletions(-) delete mode 100644 cpu/sam3/hwtimer_arch.c diff --git a/cpu/sam3/Makefile.include b/cpu/sam3/Makefile.include index f16ada89b8..99de28dcc7 100644 --- a/cpu/sam3/Makefile.include +++ b/cpu/sam3/Makefile.include @@ -1,3 +1,6 @@ export CPU_ARCH = cortex-m3 +# use hwtimer compatibility module +USEMODULE += hwtimer_compat + include $(RIOTCPU)/Makefile.include.cortexm_common diff --git a/cpu/sam3/hwtimer_arch.c b/cpu/sam3/hwtimer_arch.c deleted file mode 100644 index bcf558aa10..0000000000 --- a/cpu/sam3/hwtimer_arch.c +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (C) 2014 Freie Universität Berlin - * - * 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_sam3 - * @{ - * - * @file - * @brief Implementation of the kernels hwtimer interface - * - * The hardware timer implementation uses the Cortex build-in system timer as back-end. - * - * @author Hauke Petersen - * - * @} - */ - -#include "arch/hwtimer_arch.h" -#include "board.h" -#include "periph/timer.h" -#include "thread.h" - - -void irq_handler(int channel); -void (*timeout_handler)(int); - - -void hwtimer_arch_init(void (*handler)(int), uint32_t fcpu) -{ - timeout_handler = handler; - timer_init(HW_TIMER, 1, &irq_handler); -} - -void hwtimer_arch_enable_interrupt(void) -{ - timer_irq_enable(HW_TIMER); -} - -void hwtimer_arch_disable_interrupt(void) -{ - timer_irq_disable(HW_TIMER); -} - -void hwtimer_arch_set(unsigned long offset, short timer) -{ - timer_set(HW_TIMER, timer, offset); -} - -void hwtimer_arch_set_absolute(unsigned long value, short timer) -{ - timer_set_absolute(HW_TIMER, timer, value); -} - -void hwtimer_arch_unset(short timer) -{ - timer_clear(HW_TIMER, timer); -} - -unsigned long hwtimer_arch_now(void) -{ - return timer_read(HW_TIMER); -} - -void irq_handler(int channel) -{ - timeout_handler((short)(channel)); -}