From abc80ba5e48ddbb425d8f0a52e566bcd8b45eb9c Mon Sep 17 00:00:00 2001 From: Thomas Eichinger Date: Thu, 25 Apr 2013 13:32:50 +0200 Subject: [PATCH] added implementation of htimer_arch_set_absolute() --- cpu/mc1322x/hwtimer_cpu.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cpu/mc1322x/hwtimer_cpu.c b/cpu/mc1322x/hwtimer_cpu.c index 2b662c5514..cfb1aedd81 100644 --- a/cpu/mc1322x/hwtimer_cpu.c +++ b/cpu/mc1322x/hwtimer_cpu.c @@ -90,7 +90,19 @@ void hwtimer_arch_set(unsigned long offset, short timer) { /*---------------------------------------------------------------------------*/ void hwtimer_arch_set_absolute(unsigned long value, short timer) { + /* get corresponding struct for the given ::timer parameter */ + TMR_struct* tmr = (void *) TMR_BASE + (timer + TMR_OFFSET); + /* disable IRQs and save the status register */ + unsigned long cpsr = disableIRQ(); + + tmr->COMP1 = value; /* load the value into the compare register */ + tmr->CSCTRLbits.TCF1 = 0; /* reset compare flag */ + tmr->CSCTRLbits.TCF1EN = 1; /* enable intterupts when TCF1 is set \ */ + tmr->SCTRLbits.TCFIE = 1; /* enable interrupts when TCF is one - do we need both?*/ + + /* restor status register */ + restoreIRQ(cpsr); } /*---------------------------------------------------------------------------*/