1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/cpu/cc430/hwtimer_cc430.c
2014-02-03 00:47:38 +01:00

82 lines
1.6 KiB
C

/*
* Copyright (C) 2014 INRIA
*
* The source code is licensed under the LGPLv2 license,
* See the file LICENSE for more details.
*/
/**
* @ingroup cc430
* @{
*/
/**
* @file
* @brief cc430 hardware timer driver
*
* @author Kévin Roussel <Kevin.Roussel@inria.fr>
* @author Oliver Hahm <oliver.hahm@inria.fr>
* @author Aleksandr Mikoff <sir.enmity@gmail.com>
*
*/
#include <legacymsp430.h>
#include "board.h"
#include "hwtimer.h"
#include "hwtimer_arch.h"
#include "cpu.h"
#define ENABLE_DEBUG (0)
#include "debug.h"
static uint32_t ticks = 0;
extern void (*int_handler)(int);
extern void timer_unset(short timer);
void timerA_init(void)
{
ticks = 0; // Set tick counter value to 0
TA0CTL = TASSEL_1 + TACLR; // Clear the timer counter, set ACLK
TA0CTL &= ~TAIE; // Clear the IFG
volatile unsigned int *ccr = &TA0CCR0;
volatile unsigned int *ctl = &TA0CCTL0;
for (int i = 0; i < ARCH_MAXTIMERS; i++) {
*(ccr + i) = 0;
*(ctl + i) &= ~(CCIFG);
*(ctl + i) &= ~(CCIE);
}
TA0CTL |= MC_2;
}
interrupt(TIMER0_A0_VECTOR) __attribute__((naked)) timer0_a0_isr(void)
{
__enter_isr();
timer_unset(0);
int_handler(0);
__exit_isr();
}
interrupt(TIMER0_A1_VECTOR) __attribute__((naked)) timer0_a1_5_isr(void)
{
__enter_isr();
short taiv = TA0IV;
short timer;
if (taiv & TAIFG) {
DEBUG("Overflow\n");
}
else {
timer = (taiv / 2);
timer_unset(timer);
int_handler(timer);
}
__exit_isr();
}