#include "system.h"
#include "timer.h"

extern volatile uint16_t g_time_out;

#pragma vector=TIMERA0_VECTOR
__interrupt void timer_isr(void)
{
  g_time_out = 1;
  
  TACTL = MC_0;
}

void timer_start(void)
{
  TACTL = MC_0;
  
  TAR = 0;   
  TACTL = TASSEL_2 + MC_1;           // SMCLK, upmode    
}

// SMCLK = 1MHz
void timer_init(void)
{
  TAR = 0; 
  TACCTL0 = CCIE;                    // CCR0 interrupt enabled
  TACCR0 = (50000);                  // 50ms                   
}
