initial
This commit is contained in:
38
time.c
Normal file
38
time.c
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* time.c
|
||||
*
|
||||
* Created on: 20.05.2014
|
||||
* Author: wn
|
||||
*/
|
||||
|
||||
#include <msp430g2553.h>
|
||||
#include <isr_compat.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "time.h"
|
||||
#include "PontCoopScheduler.h"
|
||||
|
||||
|
||||
volatile uint32_t timestamp;
|
||||
|
||||
ISR(TIMER0_A0, TA0_ISR) {
|
||||
timestamp++;
|
||||
schUpdate();
|
||||
}
|
||||
|
||||
void timeInit() {
|
||||
timestamp = 0;
|
||||
|
||||
TACCR0 = 32;
|
||||
TACCTL0 = CCIE;
|
||||
TACTL = MC_1 | ID_0 | TASSEL_1 | TACLR;
|
||||
}
|
||||
|
||||
uint32_t getMillis() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
void ms_active_delay(uint16_t delay) {
|
||||
uint32_t start = timestamp;
|
||||
while (start + delay > timestamp);
|
||||
}
|
Reference in New Issue
Block a user