MBusLightSensor/src/time.cpp

50 lines
605 B
C++
Raw Normal View History

/*
* time.c
*
* Created on: 20.05.2014
* Author: wn
*/
#include <msp430g2553.h>
#include <isr_compat.h>
#include <stdint.h>
volatile unsigned long timestamp;
ISR(TIMER0_A0, TA0_ISR) {
static uint8_t state = 0;
timestamp++;
switch (state) {
case 0:
P1OUT = BIT0;
state = 1;
break;
case 1:
P1OUT = BIT6;
state = 0;
break;
default:
state = 0;
}
}
void timeInit() {
timestamp = 0;
P1DIR |= BIT6 | BIT0;
P1OUT = 0;
2014-06-05 21:32:13 +02:00
TACCR0 = 32;
TACCTL0 = CCIE;
TACTL = MC_1 | ID_0 | TASSEL_1 | TACLR;
}
unsigned long millis() {
return timestamp;
}