This commit is contained in:
2016-09-19 13:18:18 +02:00
commit 7a68d8cb3f
6 changed files with 221 additions and 0 deletions

37
src/main.c Normal file
View File

@ -0,0 +1,37 @@
/*
* main.c
*
* Created on: 19.09.2016
* Author: wn
*/
#include <msp430g2553.h>
#include <stdint.h>
#include <intrinsics.h>
#include <stdlib.h>
#include <stdbool.h>
#include "time.h"
int main() {
WDTCTL = WDTPW | WDTHOLD;
// highest possible system clock
DCOCTL = DCO0 | DCO1 | DCO2;
BCSCTL1 = XT2OFF | RSEL0 | RSEL1 | RSEL2 | RSEL3;
BCSCTL2 = 0;
BCSCTL3 = 0;
timeInit();
__enable_interrupt();
while (1) {
}
}

38
src/time.c Normal file
View 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);
}

19
src/time.h Normal file
View File

@ -0,0 +1,19 @@
/*
* time.h
*
* Created on: 20.05.2014
* Author: wn
*/
#ifndef TIME_H_
#define TIME_H_
#include <stdint.h>
void timeInit();
uint32_t getMillis();
void ms_active_delay(uint16_t delay);
#endif /* TIME_H_ */