Skip to content
Snippets Groups Projects
Commit 0921bce5 authored by Kaspar Schleiser's avatar Kaspar Schleiser
Browse files

sys: add hwtimer layer for periph timers

parent 74e076d3
No related branches found
No related tags found
No related merge requests found
......@@ -137,6 +137,9 @@ endif
ifneq (,$(filter ng_udp,$(USEMODULE)))
DIRS += net/transport_layer/ng_udp
endif
ifneq (,$(filter hwtimer_compat,$(USEMODULE)))
DIRS += compat/hwtimer
endif
DIRS += $(dir $(wildcard $(addsuffix /Makefile, ${USEMODULE})))
......
include $(RIOTBASE)/Makefile.base
MODULE = hwtimer_compat
include $(RIOTBASE)/Makefile.base
/*
* Copyright (C) 2015 Kaspar Schleiser <kaspar@schleiser.de>
* 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 sys_compat
* @{
*
* @file hwtimer_arch.c
* @brief Implementation of the kernels hwtimer interface over periph timers
*
* This hwtimer implementation wraps one periph timer
*
* @author Thomas Eichinger <thomas.eichinger@fu-berlin.de>
* @author Kaspar Schleiser <kaspar@schleiser.de>
*
* @}
*/
#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));
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment