|
|
|
@ -24,6 +24,9 @@
|
|
|
|
|
#include "hwtimer.h"
|
|
|
|
|
#include "hwtimer_arch.h"
|
|
|
|
|
|
|
|
|
|
#define ENABLE_DEBUG (0)
|
|
|
|
|
#include "debug.h"
|
|
|
|
|
|
|
|
|
|
static uint32_t ticks = 0;
|
|
|
|
|
|
|
|
|
|
extern void (*int_handler)(int);
|
|
|
|
@ -35,11 +38,11 @@ void timerA_init(void)
|
|
|
|
|
{
|
|
|
|
|
volatile unsigned int *ccr;
|
|
|
|
|
volatile unsigned int *ctl;
|
|
|
|
|
ticks = 0; // Set tick counter value to 0
|
|
|
|
|
timer_round = 0; // Set to round 0
|
|
|
|
|
TACTL = TASSEL_1 + TACLR; // Clear the timer counter, set ACLK
|
|
|
|
|
TACTL &= ~TAIFG; // Clear the IFG
|
|
|
|
|
TACTL &= ~TAIE; // Clear the IFG
|
|
|
|
|
ticks = 0; /* Set tick counter value to 0 */
|
|
|
|
|
timer_round = 0; /* Set to round 0 */
|
|
|
|
|
TACTL = TASSEL_1 + TACLR; /* Clear the timer counter, set ACLK */
|
|
|
|
|
TACTL &= ~TAIFG; /* Clear the IFG */
|
|
|
|
|
TACTL |= TAIE; /* Enable TAIE (overflow IRQ) */
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < HWTIMER_MAXTIMERS; i++) {
|
|
|
|
|
ccr = &TACCR0 + (i);
|
|
|
|
@ -55,7 +58,10 @@ void timerA_init(void)
|
|
|
|
|
interrupt(TIMERA0_VECTOR) __attribute__((naked)) timer_isr_ccr0(void)
|
|
|
|
|
{
|
|
|
|
|
__enter_isr();
|
|
|
|
|
timer_round += 1;
|
|
|
|
|
if (overflow_interrupt[0] == timer_round) {
|
|
|
|
|
timer_unset(0);
|
|
|
|
|
int_handler(0);
|
|
|
|
|
}
|
|
|
|
|
__exit_isr();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -64,12 +70,17 @@ interrupt(TIMERA1_VECTOR) __attribute__((naked)) timer_isr(void)
|
|
|
|
|
__enter_isr();
|
|
|
|
|
|
|
|
|
|
short taiv = TAIV;
|
|
|
|
|
if (!(taiv & TAIV_TAIFG)) {
|
|
|
|
|
short timer = taiv / 2;
|
|
|
|
|
if (overflow_interrupt[timer] == timer_round) {
|
|
|
|
|
timer_unset(timer);
|
|
|
|
|
int_handler(timer);
|
|
|
|
|
}
|
|
|
|
|
short timer = taiv / 2;
|
|
|
|
|
/* TAIV = 0x0A means overflow */
|
|
|
|
|
if (taiv == 0x0A) {
|
|
|
|
|
DEBUG("Overflow\n");
|
|
|
|
|
timer_round += 1;
|
|
|
|
|
}
|
|
|
|
|
/* check which CCR has been hit and if the overflow counter for this timer
|
|
|
|
|
* has been reached */
|
|
|
|
|
else if (overflow_interrupt[timer] == timer_round) {
|
|
|
|
|
timer_unset(timer);
|
|
|
|
|
int_handler(timer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
__exit_isr();
|
|
|
|
|